@Override public Collection process(Collection topics) throws JspTagException { // find all subject addresses of all topics in collection List subjectAddresses = new ArrayList(); if (topics != null) { Iterator iter = topics.iterator(); while (iter.hasNext()) { TopicIF topic = null; try { topic = (TopicIF) iter.next(); } catch (ClassCastException e) { continue; // non-topic objects have no subject address } // get subject address for specified topic if (topic != null) { LocatorIF subject_address = (LocatorIF)CollectionUtils.getFirst(topic.getSubjectLocators()); if (subject_address != null) subjectAddresses.add(subject_address); } } } return subjectAddresses; }
public static List<OccurrenceIF> findOccurrences(TopicIF oType, TopicIF topicIF, Collection<TopicIF> scope) { List<OccurrenceIF> result = new ArrayList<OccurrenceIF>(); Iterator<OccurrenceIF> it = topicIF.getOccurrences().iterator(); while (it.hasNext()) { OccurrenceIF occurIF = it.next(); if (Objects.equals(occurIF.getType(), oType) && CollectionUtils.equalsUnorderedSet(occurIF.getScope(), scope)) result.add(occurIF); } return result; }
@Override public Object get(Object key) { Collection coll = (Collection) super.get(key); if (coll == null) return null; return CollectionUtils.getFirstElement(coll); } }
private void addOccurrences(TopicIF t, DataPool dp, int count) { for (int i=0; i < count; i++) { OccurrenceIF occ = b.makeOccurrence(t, (TopicIF)CollectionUtils.getRandom(dp.occurrenceTypes), "occurrence-" + (i+1)); } }
public NamedLockManager() { locked = CollectionUtils.createConcurrentMap(); nameLocks = CollectionUtils.createConcurrentMap(); userLocks = CollectionUtils.createConcurrentMap(); objectLocks = CollectionUtils.createConcurrentMap(); logger.info("NamedLockManager initialised"); }
if (relnames.length > 0) { relations = new HashSet(relnames.length); CollectionUtils.addAll(relations, relnames);
private void addNames(TopicIF t, DataPool dp, int count) { // typed name for (int i=0; i < count; i++) { TopicNameIF bn = b.makeTopicName(t, (TopicIF)CollectionUtils.getRandom(dp.nameTypes), "topicname-" + (i+1)); } }
private TopicIF getTopicFor(TopicMapIF aTopicmap, Collection indicators, Collection locators, Collection subjects) { RemoteTopicMapStore store = (RemoteTopicMapStore) aTopicmap.getStore(); RemoteTopicIndex tindex = store.getTopicIndex(); Collection topics; if (!indicators.isEmpty() || !locators.isEmpty() || !subjects.isEmpty()) topics = tindex.getTopics(indicators, locators, subjects); else return null; if (topics == null || topics.isEmpty()) return null; return (TopicIF) CollectionUtils.getFirst(topics); }
public static List<TopicNameIF> findTopicNames(TopicIF nType, TopicIF topicIF, Collection<TopicIF> scope) { List<TopicNameIF> result = new ArrayList<TopicNameIF>(); Iterator<TopicNameIF> it = topicIF.getTopicNames().iterator(); while (it.hasNext()) { TopicNameIF nameIF = it.next(); if (Objects.equals(nameIF.getType(), nType) && CollectionUtils.equalsUnorderedSet(nameIF.getScope(), scope)) result.add(nameIF); } return result; }
@Override public Object get(Object key) { Collection coll = ctxtMgr.getValue((String) key); if (coll.isEmpty()) throw new VariableNotSetException((String) key); return CollectionUtils.getFirstElement(coll); }
private void addRoles(TopicIF t, DataPool dp, int count) { for (int i=0; i < count; i++) { TopicIF atype = (TopicIF)CollectionUtils.getRandom(dp.associationTypes); AssociationIF a = b.makeAssociation(atype); List rtypes = (List)dp.roleTypes.get(atype); Iterator iter = rtypes.iterator(); while (iter.hasNext()) { TopicIF rtype = (TopicIF)iter.next(); TopicIF player = (TopicIF)CollectionUtils.getRandom(dp.topics); b.makeAssociationRole(a, rtype, player); } } }
private void addSubjectTreeNodeTo(DefaultMutableTreeNode parent) { LocatorIF subject = (LocatorIF)CollectionUtils.getFirst(target.getSubjectLocators()); // NOTE: gets only the first one if (subject == null) return; String subjectAddress = subject.getAddress(); if (subjectAddress != null) { DefaultMutableTreeNode root = new DefaultMutableTreeNode(Messages .getString("Viz.PropertiesSubject")); root.add(new DynamicUtilTreeNode(subjectAddress, null)); parent.add(root); } }
public static List<OccurrenceIF> findOccurrences(TopicIF oType, TopicIF topicIF, String value, Collection<TopicIF> scope) { List<OccurrenceIF> result = new ArrayList<OccurrenceIF>(); Iterator<OccurrenceIF> it = topicIF.getOccurrences().iterator(); while (it.hasNext()) { OccurrenceIF occurIF = it.next(); if (Objects.equals(occurIF.getValue(), value) && Objects.equals(occurIF.getType(), oType) && CollectionUtils.equalsUnorderedSet(occurIF.getScope(), scope)) result.add(occurIF); } return result; }
protected NameField getDefaultNameField() { TopicMap tm = this; NameType nameType = new NameType(OntopolyModelUtils.getTopicIF(tm, PSI.TMDM_TOPIC_NAME), tm); Collection<NameField> nameFields = nameType.getDeclaredByFields(); return CollectionUtils.getFirstElement(nameFields); }
if (i % 100 == 0 && i != 0) System.out.println("I: " + i + " " + dp.topics.size()); TopicIF t = makeTopic("i"); t.addType((TopicIF)CollectionUtils.getRandom(dp.topicTypes));
/** * PUBLIC: Returns the first value in the collection bound to a * specific variable in the current scope. The value returned will * be null if the variable is unknown or if the collection is empty. * @since 2.2.1 */ public static Object getSingleValue(String name, ServletRequest request) { NavigatorPageIF ctxt = (NavigatorPageIF) request.getAttribute(NavigatorApplicationIF.CONTEXT_KEY); if (ctxt == null) throw new OntopiaRuntimeException("Could not find navigator context."); Collection coll = ctxt.getContextManager().getValue(name); return CollectionUtils.getFirst(coll); }
public static List<TopicNameIF> findTopicNames(TopicIF nType, TopicIF topicIF, Collection<TopicIF> scope) { List<TopicNameIF> result = new ArrayList<TopicNameIF>(); Iterator<TopicNameIF> it = topicIF.getTopicNames().iterator(); while (it.hasNext()) { TopicNameIF nameIF = it.next(); if (ObjectUtils.equals(nameIF.getType(), nType) && CollectionUtils.equalsUnorderedSet(nameIF.getScope(), scope)) result.add(nameIF); } return result; }
protected NameField getDefaultNameField() { TopicMap tm = this; NameType nameType = new NameType(OntopolyModelUtils.getTopicIF(tm, PSI.TMDM_TOPIC_NAME), tm); Collection<NameField> nameFields = nameType.getDeclaredByFields(); return CollectionUtils.getFirstElement(nameFields); }
result = filterIs(tmObjects, isKind); else if (randomElement) { result = Collections.singleton(CollectionUtils.getRandom(tmObjects));