SnapshotVariantName(VariantNameIF 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.basename = SnapshotTopicName.makeSnapshot(original.getTopicName(), SnapshotTopic.SNAPSHOT_REFERENCE, processed); 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.reifier = SnapshotTopic.makeSnapshot(original.getReifier(), SnapshotTopic.SNAPSHOT_REFERENCE, processed); break; default: throw new OntopiaRuntimeException("Unknown snapshot type: " + snapshotType); } }
@Override public void run(MasterTest mt) { VariantNameIF vn = (VariantNameIF)topicmap.getObjectById(mt.objectId); assertTrue("Variant name source locator is not set", vn.getItemIdentifiers().contains(URILocator.create("x:source-locator"))); assertTrue("Variant name not found by source locator", topicmap.getObjectByItemIdentifier(URILocator.create("x:source-locator")).equals(vn)); } });
@Override public void run(MasterTest mt) { VariantNameIF vn = (VariantNameIF)topicmap.getObjectById(mt.objectId); assertTrue("Variant name source locator is set", !vn.getItemIdentifiers().contains(URILocator.create("x:source-locator"))); assertTrue("Variant name found by source locator", topicmap.getObjectByItemIdentifier(URILocator.create("x:source-locator")) == null); } });
@Override public void run(MasterTest mt) { VariantNameIF vn = (VariantNameIF)topicmap.getObjectById(mt.objectId); assertTrue("Added variant name not found", vn != null); if (testInitialProperties) { assertTrue("Source locators is set", vn.getItemIdentifiers().isEmpty()); assertTrue("Scope is set", vn.getScope().isEmpty()); assertTrue("Value is set", vn.getValue() == null); assertTrue("Locator is set", vn.getLocator() == null); } } });
private void write(VariantNameIF variant, int number) { AttributesImpl attributes = reifier(variant); attributes.addAttribute("", "", AT_NUMBER, null, "" + number); startElement(EL_VARIANT, attributes); attributes.clear(); if (Objects.equals(variant.getDataType(), DataTypes.TYPE_URI)) { LocatorIF locator = variant.getLocator(); if (locator != null) write(normaliseLocatorReference(locator.getAddress())); } else { String value = variant.getValue(); if (value != null) write(value); } write(variant.getDataType(), "datatype"); write(variant.getScope()); writeLocators(variant.getItemIdentifiers(), EL_ITEMIDENTIFIERS); endElement(EL_VARIANT); }