Class MenuUtils
- java.lang.Object
-
- net.ontopia.topicmaps.nav2.portlets.pojos.MenuUtils
-
public class MenuUtils extends Object
INTERNAL: Helper methods for Menu.
-
-
Constructor Summary
Constructors Constructor Description MenuUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Menu.Heading
createHeading(TopicIF topic, String title)
Create new Heading as child of the given parentstatic Menu.Item
createItem(TopicIF topic, String title)
Create new Item as child of the given parentstatic Object
getFirstValue(TopicIF topic, ParsedQueryIF pq)
Runs the given query with the given topic as parameter %topic% and returns the first value (of the first collumn) in the result collection.static boolean
getResultTrue(TopicIF topic, String query)
Test if the given query returns any result rows.static List
getResultValues(TopicIF topic, ParsedQueryIF parsedQuery)
Get the values of a given query with a given %topic% parameter as a Liststatic void
moveOne(TopicIF topic, boolean up)
Move the given child one step up or down the list of children on the parentprotected static ParsedQueryIF
optimisticParse(String query, TopicMapIF tm)
Parse the given query for the given topic map.protected static DeclarationContextIF
optimisticParse(TopicMapIF tm, String query)
Parse the given declaration-context-query for the given topic map.static void
setUniqueAssociation(TopicIF player1, String rType1Id, String aTypeId, String rType2Id, TopicIF player2)
Set the binary association with given role types, association types and players, removing any existing associations with the same role types and association type on player1.static void
setUniqueOccurrence(TopicIF topic, String typeId, String value)
Set the occurrence of a given type on a given topic, removing any existing occurrences of the same type on that topic.static void
setUniqueTopicName(TopicIF topic, String baseName)
Set the basename of a given topic, removing any old basenames.
-
-
-
Field Detail
-
UP
public static final boolean UP
- See Also:
- Constant Field Values
-
DOWN
public static final boolean DOWN
- See Also:
- Constant Field Values
-
-
Method Detail
-
getFirstValue
public static Object getFirstValue(TopicIF topic, ParsedQueryIF pq)
Runs the given query with the given topic as parameter %topic% and returns the first value (of the first collumn) in the result collection.- Parameters:
topic
- The parameter refered to as %topic% in the query.pq
- The query that genereates the result.- Returns:
- The first value returned by the query.
-
getResultValues
public static List getResultValues(TopicIF topic, ParsedQueryIF parsedQuery)
Get the values of a given query with a given %topic% parameter as a List- Parameters:
topic
- The topic parameter represened by %topic% in the query.parsedQuery
- The query.- Returns:
- the first result column values of the query, as a List.
-
getResultTrue
public static boolean getResultTrue(TopicIF topic, String query)
Test if the given query returns any result rows.- Parameters:
topic
- The %topic% parameter in the query.query
- The query.- Returns:
- true if query returns one or more result rows. Otherwise, false.
-
createHeading
public static Menu.Heading createHeading(TopicIF topic, String title)
Create new Heading as child of the given parent- Parameters:
topic
- Represents the parent.title
- The title of the Heading.- Returns:
- The Heading that was created.
-
createItem
public static Menu.Item createItem(TopicIF topic, String title)
Create new Item as child of the given parent- Parameters:
topic
- Represents the parent.title
- The title of the Item.- Returns:
- The Item that was created.
-
moveOne
public static void moveOne(TopicIF topic, boolean up)
Move the given child one step up or down the list of children on the parent- Parameters:
topic
- Represents the chils.up
- use UP or DOWN to move up or down the list, respectively.
-
setUniqueTopicName
public static void setUniqueTopicName(TopicIF topic, String baseName)
Set the basename of a given topic, removing any old basenames.- Parameters:
topic
- The topic.baseName
- The new basename.
-
setUniqueOccurrence
public static void setUniqueOccurrence(TopicIF topic, String typeId, String value)
Set the occurrence of a given type on a given topic, removing any existing occurrences of the same type on that topic.- Parameters:
topic
- The topic that should have the occurrence.typeId
- The type, as refered to in the query (e.g. "menu:link")value
- The value of the occurrence.
-
setUniqueAssociation
public static void setUniqueAssociation(TopicIF player1, String rType1Id, String aTypeId, String rType2Id, TopicIF player2)
Set the binary association with given role types, association types and players, removing any existing associations with the same role types and association type on player1.- Parameters:
player1
- The first player, for which old associations are removed.rType1Id
- The first role type, as a string (e.g. "menu:item")aTypeId
- The association type, as a string (e.g. "menu:item-topic")rType2Id
- The second role type, as a string (e.g. "menu:topic")player2
- The second player.
-
optimisticParse
protected static ParsedQueryIF optimisticParse(String query, TopicMapIF tm)
Parse the given query for the given topic map. InvalidQueryExceptions thrown during the parse process are caught and re-thrown with an additional message as OntopiaRuntimeExceptions. This avoids external try {} catch() {} blocks around this method.- Parameters:
query
- The query to parse.tm
- The topicmap used by the query.- Returns:
- A ParsedQueryIF representing the parsed query.
-
optimisticParse
protected static DeclarationContextIF optimisticParse(TopicMapIF tm, String query)
Parse the given declaration-context-query for the given topic map. InvalidQueryExceptions thrown during the parse process are caught and re-thrown with an additional message as OntopiaRuntimeExceptions. This avoids external try {} catch() {} blocks around this method.- Parameters:
tm
- The topicmap used by the query.query
- The query to parse.- Returns:
- A DeclarationContextIF representing the parsed query.
-
-