@Override public Collection getItemIdentifiers() { return occ.getItemIdentifiers(); }
SnapshotOccurrence(OccurrenceIF original, int snapshotType, Map<TMObjectIF, SnapshotTMObject> processed) { this.snapshotType = snapshotType; switch (snapshotType) { case SNAPSHOT_REFERENCE: this.objectId = original.getObjectId(); break; case SNAPSHOT_COMPLETE: this.objectId = original.getObjectId(); this.srclocs = new ArrayList<LocatorIF>(original.getItemIdentifiers()); this.topic = SnapshotTopic.makeSnapshot(original.getTopic(), SnapshotTopic.SNAPSHOT_REFERENCE, processed); this.datatype = original.getDataType(); this.value = original.getValue(); this.scope = new ArrayList<TopicIF>(); Iterator<TopicIF> siter = original.getScope().iterator(); while (siter.hasNext()) { this.scope.add(SnapshotTopic.makeSnapshot(siter.next(), snapshotType, processed)); } this.type = SnapshotTopic.makeSnapshot(original.getType(), SnapshotTopic.SNAPSHOT_REFERENCE, processed); this.reifier = SnapshotTopic.makeSnapshot(original.getReifier(), SnapshotTopic.SNAPSHOT_REFERENCE, processed); break; default: throw new OntopiaRuntimeException("Unknown snapshot type: " + snapshotType); } }
@Override public void run(MasterTest mt) { OccurrenceIF o = (OccurrenceIF)topicmap.getObjectById(mt.objectId); assertTrue("Occurrence source locator is not set", o.getItemIdentifiers().contains(URILocator.create("x:source-locator"))); assertTrue("Occurrence not found by source locator", topicmap.getObjectByItemIdentifier(URILocator.create("x:source-locator")).equals(o)); } });
private void write(OccurrenceIF occurrence, int number) { AttributesImpl attributes = reifier(occurrence); attributes.addAttribute("", "", AT_NUMBER, null, "" + number); startElement(EL_OCCURRENCE, attributes); attributes.clear(); write(occurrence.getValue()); // normalized in FakeOccurrence below write(occurrence.getDataType(), "datatype"); writeType(occurrence); write(occurrence.getScope()); writeLocators(occurrence.getItemIdentifiers(), EL_ITEMIDENTIFIERS); endElement(EL_OCCURRENCE); }
@Override public void run(MasterTest mt) { OccurrenceIF o = (OccurrenceIF)topicmap.getObjectById(mt.objectId); assertTrue("Occurrence source locator is set", !o.getItemIdentifiers().contains(URILocator.create("x:source-locator"))); assertTrue("Occurrence found by source locator", topicmap.getObjectByItemIdentifier(URILocator.create("x:source-locator")) == null); } });
@Test public void testOmittingIDs() throws IOException { prepareTopicMap(); TopicIF topic = builder.makeTopic(); TopicIF otype = builder.makeTopic(); OccurrenceIF occ = builder.makeOccurrence(topic, otype, "huhei"); XTMTopicMapWriter writer = new XTMTopicMapWriter(tmfile); writer.setAddIds(false); writer.write(topicmap); XTMTopicMapReader reader = new XTMTopicMapReader(tmfile); topicmap = reader.read(); Iterator it = topicmap.getTopics().iterator(); while (it.hasNext()) { topic = (TopicIF) it.next(); if (!topic.getOccurrences().isEmpty()) break; } occ = (OccurrenceIF) topic.getOccurrences().iterator().next(); Assert.assertTrue("occurrence had ID!", occ.getItemIdentifiers().isEmpty()); }
public void testOccurrenceItemIds() throws MalformedURLException { TopicIF type = builder.makeTopic(); TopicIF topic = builder.makeTopic(); OccurrenceIF occ = builder.makeOccurrence(topic, type, "duplicate"); occ.addItemIdentifier(new URILocator("http://psi.example.org")); occ = builder.makeOccurrence(topic, type, "duplicate"); occ.addItemIdentifier(new URILocator("http://psi.example.com")); DuplicateSuppressionUtils.removeDuplicates(topic); assertTrue("duplicate occurrence were not removed", topic.getOccurrences().size() == 1); occ = (OccurrenceIF) topic.getOccurrences().iterator().next(); assertTrue("item IDs were not merged", occ.getItemIdentifiers().size() == 2); }
@Override public void run(MasterTest mt) { OccurrenceIF o = (OccurrenceIF)topicmap.getObjectById(mt.objectId); assertTrue("Added occurrence not found", o != null); if (testInitialProperties) { assertTrue("Source locators is set", o.getItemIdentifiers().isEmpty()); assertTrue("Scope is set", o.getScope().isEmpty()); assertTrue("Type is set", o.getType() == null); assertTrue("Value is set", o.getValue() == null); assertTrue("Locator is set", o.getLocator() == null); } } });