/** * Tests whether this topic is a topic type. * * @return true if this is a topic type. */ public boolean isTopicType() { TopicIF type = topicIF.getTopicMap().getTopicBySubjectIdentifier(PSI.ON_TOPIC_TYPE); return topicIF.getTypes().contains(type); }
public static Collection<OccurrenceIF> getOccurrencesOfType(TopicIF topic, TopicIF occType) { List<OccurrenceIF> result = new ArrayList<OccurrenceIF>(); for (Iterator<OccurrenceIF> iter = topic.getOccurrences().iterator(); iter.hasNext();) { OccurrenceIF occurrence = iter.next(); TopicIF otype = occurrence.getType(); if (otype != null && otype .equals(occType)) result.add(occurrence); } return result; }
public static List<TopicNameIF> findTopicNames(TopicIF nType, TopicIF topicIF) { 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)) result.add(nameIF); } return result; }
private Collection<AssociationRoleIF> getTopicRoles(TopicIF topic, TopicIF roleType, TopicIF associationType) { if (roleType == null) { return topic.getRoles(); } else { if (associationType == null) { return topic.getRolesByType(roleType); } else { return topic.getRolesByType(roleType, associationType); } } }
private void addIdentities(TopicIF t, DataPool dp, int count) { for (int i=0; i < count; i++) { t.addSubjectIdentifier(URILocator.create("http://example.org/foo/" + t.getObjectId() + "/" + (i+1))); } }
private void verifySingleTopicName(TopicIF topic, String name) { Assert.assertTrue("topic has spurious children", topic.getTypes().size() == 0 && topic.getRoles().size() == 0 && topic.getOccurrences().size() == 0); Assert.assertTrue("topic has wrong number of base names", topic.getTopicNames() .size() == 1); TopicNameIF basename = (TopicNameIF) topic.getTopicNames().iterator() .next(); Assert.assertTrue("wrong basename value: '" + basename.getValue() + "'", basename .getValue().equals(name)); Assert.assertTrue("basename has spurious children", basename.getVariants().size() == 0); Assert.assertTrue("basename has spurious themes", basename.getScope().size() == 0); }
private String getTopicId(TopicIF topic) { LocatorIF baseaddr = topic.getTopicMap().getStore().getBaseAddress(); if (baseaddr != null) { String base = baseaddr.getAddress(); Iterator it = topic.getItemIdentifiers().iterator(); while (it.hasNext()) { String extractedId = extractRelativeId(base, (LocatorIF) it.next()); if (extractedId != null) return extractedId; } } return "id" + topic.getObjectId(); }
public Collection getPagesFor(TopicIF topic) { TopicIndexIF ix = ((RemoteTopicMapStore) topicmap.getStore()) .getTopicIndex(); return ix.getTopicPages(topic.getSubjectIdentifiers(), topic.getItemIdentifiers(), topic.getSubjectLocators()); }
public static List<AssociationRoleIF> findRoles(TopicIF aType, TopicIF rType, TopicIF player) { List<AssociationRoleIF> result = new ArrayList<AssociationRoleIF>(); Iterator<AssociationRoleIF> it = player.getRoles().iterator(); while (it.hasNext()) { AssociationRoleIF role = it.next(); AssociationIF association = role.getAssociation(); if (Objects.equals(role.getType(), rType) && Objects.equals(association.getType(), aType)) result.add(role); } return result; }
@Override public TypedIF getTyped(TopicIF topic) { if (topic.getTopicNames().size() == 0) { return null; } TopicNameIF name = topic.getTopicNames().iterator().next(); if (name.getType().getSubjectIdentifiers().contains(PSI.getSAMNameType())) { return null; } return name; } });
/** * PUBLIC: Remove all duplicated characteristics of the given topic, * except for duplicate associations the topic may participate in. */ public static void removeDuplicates(TopicIF topic) { // base name duplicates removeDuplicateTopicNames(topic.getTopicNames()); // occurrence duplicates removeDuplicateOccurrences(topic.getOccurrences()); // duplicate association roles are not removed here; that job must // be done by removing duplicate associations globally }
/** * Tests whether this datatype is xsd:number. * * @return true if the datatype is xsd:number. */ public boolean isNumber() { return getTopicIF().getSubjectIdentifiers().contains(DataTypes.TYPE_DECIMAL); }
/** * Gets the id of this topic. * * @return the id of this topic. */ public String getId() { return getTopicIF().getObjectId(); }
private void registerSubjectIndicator(TopicIF topic, LocatorIF psi) { TopicIF other = topicmap.getTopicBySubjectIdentifier(psi); if (other == null) { topic.addSubjectIdentifier(psi); return; } if (!other.equals(topic)) MergeUtils.mergeInto(topic, other); }
public void setSubjectLocators(TopicIF object, Topic pojo) { if (pojo.getSubjectLocators() != null) { Collection<LocatorIF> toRemove = CollectionUtils.subtract(object.getSubjectLocators(), pojo.getSubjectLocators()); for (LocatorIF sl : pojo.getSubjectLocators()) { object.addSubjectLocator(sl); } for (LocatorIF sl : toRemove) { object.removeSubjectLocator(sl); } } }
private String get(TopicIF topic, LocatorIF psi) { for (OccurrenceIF occ : topic.getOccurrences()) { TopicIF type = occ.getType(); if (type.getSubjectIdentifiers().contains(psi)) return occ.getValue(); } return null; }
protected TopicIF resolveResourceRef(LocatorIF locator) { // Look up in the topic map to see if a topic with the identity already exist TopicIF topic = topicmap.getTopicBySubjectLocator(locator); if (topic != null) return topic; // If there is no such topic create a new one with the given subject indicator. topic = builder.makeTopic(); // log.debug("New topic (resourceRef): " + locator); // Set addressable subject topic.addSubjectLocator(locator); return topic; }
/** * INTERNAL: Serialize the subject locators of a {@link TopicIF}. If the * object does not have a subject locator, nothing will be serialized. * * @param topic the {@link TopicIF} to be serialized. */ private void serializeSubjectLocators(TopicIF topic) throws IOException { Collection<LocatorIF> slocs = topic.getSubjectLocators(); serializeIdentifiers("subject_locators", slocs); }
private AResource getResource(TopicIF topic) { LocatorIF locator = null; if (locator == null && !topic.getSubjectLocators().isEmpty()) locator = (LocatorIF) topic.getSubjectLocators().iterator().next(); if (locator == null && !topic.getSubjectIdentifiers().isEmpty()) locator = (LocatorIF) topic.getSubjectIdentifiers().iterator().next(); if (locator != null) return new AResourceWrapper(locator.getExternalForm()); return makeAnonymousNode(topic); }
@Override public void run() { TopicIF t = getTopic(); t.addSubjectLocator(URILocator.create("x:subject")); this.objectId = t.getObjectId(); } });