/** * Compares two AssociationIFs. */ @Override public int compare(AssociationIF a1, AssociationIF a2) { return ac.compare(a1.getObjectId(), a2.getObjectId()); }
public static String toString(String impl, AssociationIF assoc) { String id = UNASSIGNED; try { if (assoc.getTopicMap() != null) id = assoc.getObjectId(); return "[" + impl + ", " + id + ", type: " + assoc.getType() + "]"; } catch (Throwable t) { return "[" + impl + ", " + id + "]"; } }
public TMAssociationEdge(TMTopicNode tn1, TMTopicNode tn2, AssociationIF association, TopicIF aScopingTopic) { super(tn1, tn2); this.association = association; setScopingTopic(aScopingTopic); setID(association.getObjectId()); }
public static void debug(TopicIF topic) { System.out.println("Object ID: " + topic.getObjectId()); Iterator it = topic.getSubjectLocators().iterator(); while (it.hasNext()) System.out.println("Subject: " + it.next()); it = topic.getSubjectIdentifiers().iterator(); while (it.hasNext()) System.out.println("Indicator: " + it.next()); it = topic.getItemIdentifiers().iterator(); while (it.hasNext()) System.out.println("Source: " + it.next()); it = topic.getRoles().iterator(); while (it.hasNext()) { AssociationIF assoc = ((AssociationRoleIF) it.next()).getAssociation(); System.out.print("Association " + assoc.getObjectId() + ": "); Iterator it2 = assoc.getRoles().iterator(); while (it2.hasNext()) { AssociationRoleIF role = (AssociationRoleIF) it2.next(); if (role.getPlayer() != topic) System.out.print(" " + role.getPlayer().getObjectId()); } System.out.println(); } }
public TMAssociationNode(AssociationIF assoc, TopicIF aScopingTopic, TopicMapView topicMapView) { super(assoc.getObjectId()); this.association = assoc; setScopingTopic(aScopingTopic); this.setLabel(""); this.setType(Node.TYPE_CIRCLE); this.topicMapView = topicMapView; }
@Override protected void writeAssociation(AssociationIF assoc, ContentHandler dh) throws SAXException { String objid = assoc.getObjectId(); if (alreadyExported.contains(objid)) return; alreadyExported.add(objid); dh.startElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "association", EMPTY_ATTR_LIST); if (assoc.getType() != null) writeInstanceOf(assoc, dh); if (assoc.getScope().size() > 0) writeScope(assoc.getScope(), dh); if (assoc.getRoles().size() > 0 ) writeMembers(assoc, dh); dh.endElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "association"); }
@Override public void run() { AssociationIF a = (AssociationIF)this.data.remove("AssociationIF"); this.objectId = a.getObjectId(); a.remove(); } });
@Override public void run() { AssociationIF a = builder.makeAssociation(builder.makeTopic()); this.data.put("AssociationIF", a); this.objectId = a.getObjectId(); } });
public void testSpecificAssoc() throws InvalidQueryException, IOException { load("bb-test.ltm"); List matches = new ArrayList(); Iterator it = topicmap.getAssociations().iterator(); AssociationIF assoc = (AssociationIF) it.next(); Iterator it2 = assoc.getRoles().iterator(); while (it2.hasNext()) { AssociationRoleIF role = (AssociationRoleIF) it2.next(); addMatch(matches, "ROLE", role); } verifyQuery(matches, "association-role(@" + assoc.getObjectId() + ", $ROLE)?"); closeStore(); }
@Override public void run() { AssociationIF a = getAssociation(); TopicIF theme = (TopicIF)this.data.remove("scope"); a.removeTheme(theme); this.objectId = a.getObjectId(); this.value = theme.getObjectId(); } });
public void perform(ActionParametersIF params, ActionResponseIF response) { // create new association //test params ActionSignature paramsType = ActionSignature.getSignature("m t? t?"); paramsType.validateArguments(params, this); TopicMapIF topicmap = (TopicMapIF) params.get(0); TopicMapBuilderIF builder = topicmap.getBuilder(); TopicIF assocType = (TopicIF) params.get(1); if (assocType == null) assocType = builder.makeTopic(); AssociationIF assoc = builder.makeAssociation(assocType); Collection scope = params.getCollection(2); if (scope != null) { Iterator it = scope.iterator(); while (it.hasNext()) { TopicIF theme = (TopicIF) it.next(); assoc.addTheme(theme); } } response.addParameter(Constants.RP_ASSOC_ID, assoc.getObjectId()); }
@Override public void run() { AssociationIF a = getAssociation(); TopicIF type = builder.makeTopic(); // create type this.data.put("type", type); a.setType(type); this.objectId = a.getObjectId(); this.value = type.getObjectId(); } });
public void testBothBoundTrue() throws InvalidQueryException, IOException { load("bb-test.ltm"); List matches = new ArrayList(); TopicIF teacher = getTopicById("larer"); AssociationRoleIF role = (AssociationRoleIF) teacher.getRoles().iterator().next(); AssociationIF assoc = role.getAssociation(); matches.add(new HashMap()); verifyQuery(matches, "association-role(@" + assoc.getObjectId() + ", @" + role.getObjectId() + ")?"); closeStore(); }
public void testBothBoundFalse() throws InvalidQueryException, IOException { load("bb-test.ltm"); List matches = new ArrayList(); TopicIF teacher = getTopicById("gdm"); Iterator it = teacher.getRoles().iterator(); AssociationRoleIF role = (AssociationRoleIF) it.next(); AssociationRoleIF role2 = (AssociationRoleIF) it.next(); AssociationIF assoc = role2.getAssociation(); verifyQuery(matches, "association-role(@" + assoc.getObjectId() + ", @" + role.getObjectId() + ")?"); closeStore(); }
@Override public void run() { AssociationIF a = getAssociation(); a.addItemIdentifier(URILocator.create("x:source-locator")); this.objectId = a.getObjectId(); } });
@Override public void run() { AssociationIF a = getAssociation(); TopicIF theme = builder.makeTopic(); this.data.put("scope", theme); a.addTheme(theme); this.objectId = a.getObjectId(); this.value = theme.getObjectId(); } });
@Override public void run() { AssociationIF a = getAssociation(); a.removeItemIdentifier(URILocator.create("x:source-locator")); this.objectId = a.getObjectId(); } });
@Override public void run() { AssociationIF a = getAssociation(); TopicIF type = builder.makeTopic(); // create type type.addSubjectIdentifier(URILocator.create("type:cleared")); a.setType(type); TopicIF xtype = (TopicIF)this.data.remove("type"); // remove type xtype.remove(); this.objectId = a.getObjectId(); } });
srcloc= new URILocator("http://net.ontopia.identity/assoc#" + assoc.getObjectId()); } catch (MalformedURLException e) { throw new ActionRuntimeException("Malformed URL for occurrence source locator: " + e); response.addParameter("associd", assoc.getObjectId());
@Put public void addAssociation(Association association) { if (optionalRequestParameter(Parameters.ID) != null) { setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); return; } if (association == null) { throw OntopiaRestErrors.MANDATORY_OBJECT_IS_NULL.build("Association"); } TopicMapIF tm = getTopicMap(); TopicIF type = Parameters.TYPE.optional(this); AssociationIF result; if (type != null) { result = getController(AssociationController.class).add(tm, type, association); } else { result = getController(AssociationController.class).add(tm, association); } store.commit(); // todo: maybe this should be '302 Found' instead redirectSeeOther("associations/" + result.getObjectId()); // todo: how to make this stable? } }