net.ontopia.topicmaps.nav2.portlets.pojos
Class MenuUtils

java.lang.Object
  extended by net.ontopia.topicmaps.nav2.portlets.pojos.MenuUtils

public class MenuUtils
extends java.lang.Object

INTERNAL: Helper methods for Menu.


Field Summary
static boolean DOWN
           
static boolean UP
           
 
Constructor Summary
MenuUtils()
           
 
Method Summary
static Menu.Heading createHeading(TopicIF topic, java.lang.String title)
          Create new Heading as child of the given parent
static Menu.Item createItem(TopicIF topic, java.lang.String title)
          Create new Item as child of the given parent
static java.lang.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, java.lang.String query)
          Test if the given query returns any result rows.
static java.util.List getResultValues(TopicIF topic, ParsedQueryIF parsedQuery)
          Get the values of a given query with a given %topic% parameter as a List
static void moveOne(TopicIF topic, boolean up)
          Move the given child one step up or down the list of children on the parent
protected static ParsedQueryIF optimisticParse(java.lang.String query, TopicMapIF tm)
          Parse the given query for the given topic map.
protected static DeclarationContextIF optimisticParse(TopicMapIF tm, java.lang.String query)
          Parse the given declaration-context-query for the given topic map.
static void setUniqueAssociation(TopicIF player1, java.lang.String rType1Id, java.lang.String aTypeId, java.lang.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, java.lang.String typeId, java.lang.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, java.lang.String baseName)
          Set the basename of a given topic, removing any old basenames.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UP

public static final boolean UP
See Also:
Constant Field Values

DOWN

public static final boolean DOWN
See Also:
Constant Field Values
Constructor Detail

MenuUtils

public MenuUtils()
Method Detail

getFirstValue

public static java.lang.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 java.util.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,
                                    java.lang.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,
                                         java.lang.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,
                                   java.lang.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,
                                      java.lang.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,
                                       java.lang.String typeId,
                                       java.lang.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,
                                        java.lang.String rType1Id,
                                        java.lang.String aTypeId,
                                        java.lang.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(java.lang.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,
                                                      java.lang.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.


Copyright © 2000-2012 Ontopia.