public static TopicIF getTopicIF(TopicMap tm, LocatorIF subjectIdentifier, boolean mustExist) { TopicIF t = tm.getTopicMapIF().getTopicBySubjectIdentifier(subjectIdentifier); if (t == null && mustExist) throw new RuntimeException("Topic not found by subject identifier: " + subjectIdentifier); return t; }
private static TopicIF topicByPSI(LocatorIF psiloc, TopicMapIF tm) throws MalformedURLException { TopicIF topic = tm.getTopicBySubjectIdentifier(psiloc); if (topic == null) throw new OntopiaRuntimeException("Could not find topic with PSI '" + psiloc + "'"); return topic; }
/** * Tests whether this topic is a topic map. * * @return true if this is a topic map. */ public boolean isTopicMap() { TopicIF type = topicIF.getTopicMap().getTopicBySubjectIdentifier(PSI.ON_TOPIC_MAP); return topicIF.getTypes().contains(type); }
/** * Tests whether this topic is an association type. * * @return true if this is an association type. */ public boolean isAssociationType() { TopicIF type = topicIF.getTopicMap().getTopicBySubjectIdentifier(PSI.ON_ASSOCIATION_TYPE); return topicIF.getTypes().contains(type); }
/** * Tests whether this topic is a role type. * * @return true if this is a role type. */ public boolean isRoleType() { TopicIF type = topicIF.getTopicMap().getTopicBySubjectIdentifier(PSI.ON_ROLE_TYPE); return topicIF.getTypes().contains(type); }
/** * 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); }
/** * Tests whether this topic is an occurrence type. * * @return true if this is an occurrence type. */ public boolean isOccurrenceType() { TopicIF type = topicIF.getTopicMap().getTopicBySubjectIdentifier(PSI.ON_OCCURRENCE_TYPE); return topicIF.getTypes().contains(type); }
private static TopicIF registerAssociationType(TopicIF atype, TopicMapIF tm) throws MalformedURLException { // topic to be an instance of on:association-type TopicIF assocType = tm.getTopicBySubjectIdentifier(psibase.resolveAbsolute("association-type")); atype.addType(assocType); return atype; }
private static TopicIF registerNameType(TopicIF ntype, TopicMapIF tm) throws MalformedURLException { // topic to be an instance of on:name-type TopicIF nameType = tm.getTopicBySubjectIdentifier(psibase.resolveAbsolute("name-type")); ntype.addType(nameType); return ntype; }
private static TopicIF registerRoleType(TopicIF rtype, TopicMapIF tm) throws MalformedURLException { // topic to be an instance of on:role-type TopicIF roleType = tm.getTopicBySubjectIdentifier(psibase.resolveAbsolute("role-type")); rtype.addType(roleType); return rtype; }
protected static void removeTopicIfExist(TopicMapIF topicmap, LocatorIF base_on, String ref) { LocatorIF loc = base_on.resolveAbsolute(ref); TopicIF topic = topicmap.getTopicBySubjectIdentifier(loc); if (topic != null) topic.remove(); }
private static TopicIF getDefaultNameType(Context ctx) { // if the default topic name type doesn't exist this will return nothing. // that's OK, because in that case there will be no existing names with // this type, either. return ctx.getTopicMap().getTopicBySubjectIdentifier(PSI.getSAMNameType()); }
private static void registerTopicType(TopicIF topic, TopicMapIF tm) throws MalformedURLException { // topic to be an instance of on:topic-type TopicIF topicType = tm.getTopicBySubjectIdentifier(psibase.resolveAbsolute("topic-type")); topic.addType(topicType); }
/** * Returns the default createa action (popup) */ public static CreateAction getDefaultCreateAction(TopicMap tm) { return new CreateAction(tm.getTopicMapIF().getTopicBySubjectIdentifier(PSI.ON_CREATE_ACTION_POPUP), tm); }
private TopicIF getLastModifiedTopic(TopicMapIF topicmap) { TopicIF lastmod = topicmap.getTopicBySubjectIdentifier(psi); if (lastmod == null) { lastmod = topicmap.getBuilder().makeTopic(); lastmod.addSubjectIdentifier(psi); } return lastmod; }
public TopicIF getTopicIFById(String id) { // look up topic by object id or subject identifier TopicIF topic = (TopicIF)getTopicMapIF().getObjectById(id); if (topic == null) { try { return topicMapIF.getTopicBySubjectIdentifier(URILocator.create(id)); } catch (Exception e) { return null; } } return topic; }
protected static TopicIF getTopic(TopicMapIF topicmap, LocatorIF base_on, String ref) { LocatorIF loc = base_on.resolveAbsolute(ref); TopicIF topic = topicmap.getTopicBySubjectIdentifier(loc); if (topic == null) throw new OntopiaRuntimeException("Cannot find topic with id " + loc.getAddress()); else return topic; }
private TopicIF getPasswordTopic(TopicMapIF topicmap) { TopicIF passwd = topicmap.getTopicBySubjectIdentifier(psi); if (passwd == null) { passwd = topicmap.getBuilder().makeTopic(); passwd.addSubjectIdentifier(psi); } return passwd; }
protected static void removeTopic(TopicMapIF topicmap, LocatorIF base_on, String ref) { LocatorIF loc = base_on.resolveAbsolute(ref); TopicIF topic = topicmap.getTopicBySubjectIdentifier(loc); if (topic == null) throw new OntopiaRuntimeException("Cannot find topic with id " + loc.getAddress()); else topic.remove(); }
private static TopicIF registerOccurrenceType(TopicIF otype, TopicIF datatype, TopicMapIF tm) throws MalformedURLException { // topic to be an instance of on:occurrence-type TopicIF occType = tm.getTopicBySubjectIdentifier(psibase.resolveAbsolute("occurrence-type")); otype.addType(occType); // datatype addAssociation2(psibase.resolveAbsolute("has-datatype"), otype, psibase.resolveAbsolute("field-definition"), datatype, psibase.resolveAbsolute("datatype"), tm); return otype; }