@Override public void setValue(String value) { Check.valueNotNull(this, value); wrapped.setValue(value); }
protected static void renameTopics(TopicMapIF topicmap, String oldName, String newName) { NameIndexIF nix = (NameIndexIF)topicmap.getIndex(NameIndexIF.class.getName()); Iterator<TopicNameIF> names = nix.getTopicNames(oldName).iterator(); while (names.hasNext()) { TopicNameIF tn = names.next(); tn.setValue(newName); } }
protected static void renameTopics(TopicMapIF topicmap, String oldName, String newName) { NameIndexIF nix = (NameIndexIF)topicmap.getIndex(NameIndexIF.class.getName()); Iterator<TopicNameIF> names = nix.getTopicNames(oldName).iterator(); while (names.hasNext()) { TopicNameIF tn = names.next(); tn.setValue(newName); } }
protected static void normalizeTopicNames(TopicMapIF tm) { Iterator it = tm.getTopics().iterator(); while (it.hasNext()) { TopicIF topic = (TopicIF) it.next(); Iterator it2 = topic.getTopicNames().iterator(); while (it2.hasNext()) { TopicNameIF bn = (TopicNameIF) it2.next(); bn.setValue(StringUtils.normalizeSpace(bn.getValue())); } } }
public static void setName(TopicIF nType, TopicIF topic, String value, Collection<TopicIF> scope) { if (value != null && topic != null) { // update existing new name or create a new one Collection<TopicNameIF> names = OntopolyModelUtils.findTopicNames(null, topic, scope); Iterator<TopicNameIF> iter = names.iterator(); if (iter.hasNext()) { TopicNameIF bn = iter.next(); bn.setValue(value); } else { topic.getTopicMap().getBuilder().makeTopicName(topic, value); } // remove superfluous names while (iter.hasNext()) ((TopicNameIF) iter.next()).remove(); } }
public static void setName(TopicIF nType, TopicIF topic, String value, Collection<TopicIF> scope) { if (value != null && topic != null) { // update existing new name or create a new one Collection<TopicNameIF> names = OntopolyModelUtils.findTopicNames(null, topic, scope); Iterator<TopicNameIF> iter = names.iterator(); if (iter.hasNext()) { TopicNameIF bn = iter.next(); bn.setValue(value); } else { topic.getTopicMap().getBuilder().makeTopicName(topic, value); } // remove superfluous names while (iter.hasNext()) ((TopicNameIF) iter.next()).remove(); } }
@Override public TopicNameIF makeTopicName(TopicIF topic, String value) { if (topic == null) throw new NullPointerException(MSG_TOPIC_NOT_NULL); if (value == null) throw new NullPointerException(MSG_TOPIC_NAME_VALUE_NOT_NULL); CrossTopicMapException.check(topic, this.tm); TopicNameIF name = new TopicName(tm); ((Topic)topic).addTopicName(name); name.setValue(value); name.setType(getDefaultNameType()); return name; }
@Override public TopicNameIF makeTopicName(TopicIF topic, String value) { if (topic == null) throw new NullPointerException(MSG_TOPIC_NOT_NULL); if (value == null) throw new NullPointerException(MSG_TOPIC_NAME_VALUE_NOT_NULL); CrossTopicMapException.check(topic, this.tm); TopicIF bntype = getDefaultNameType(); TopicNameIF name = new TopicName(txn); ((Topic)topic).addTopicName(name); name.setValue(value); name.setType(bntype); return name; }
@Override public void modify(TMObjectIF object, Object v) { String value = (String) v; if (object instanceof OccurrenceIF) ((OccurrenceIF) object).setValue(value); else if (object instanceof TopicNameIF) ((TopicNameIF) object).setValue(value); else if (object instanceof VariantNameIF) ((VariantNameIF) object).setValue(value); else throw new OntopiaRuntimeException("OUCH!"); } }
@Override public TopicNameIF makeTopicName(TopicIF topic, TopicIF bntype, String value) { if (topic == null) throw new NullPointerException(MSG_TOPIC_NOT_NULL); if (value == null) throw new NullPointerException(MSG_TOPIC_NAME_VALUE_NOT_NULL); CrossTopicMapException.check(topic, this.tm); // if not type has been specified, use the default name type if (bntype == null) bntype = getDefaultNameType(); else CrossTopicMapException.check(bntype, this.tm); TopicNameIF name = new TopicName(tm); ((Topic)topic).addTopicName(name); name.setType(bntype); name.setValue(value); return name; }
public void testTopicName() { basename.setValue("basename"); assertTrue("base name stringified wrongly", stringifier.toString(basename).equals("basename")); }
@Override public void run() { TopicNameIF bn = getTopicName(); bn.setValue(""); this.objectId = bn.getObjectId(); } });
@Override public void run() { TopicNameIF bn = getTopicName(); bn.setValue("New name"); this.objectId = bn.getObjectId(); } });
public void testValue() { assertTrue("initial name value not \"\"", "".equals(basename.getValue())); basename.setValue("testfaen"); assertTrue("name not set correctly", basename.getValue().equals("testfaen")); try { basename.setValue(null); fail("value could be set to null"); } catch (NullPointerException e) { } basename.setValue("foo"); assertTrue("name value not set to foo", "foo".equals(basename.getValue())); }
@Override public TopicNameIF makeTopicName(TopicIF topic, TopicIF bntype, String value) { if (topic == null) throw new NullPointerException(MSG_TOPIC_NOT_NULL); if (value == null) throw new NullPointerException(MSG_TOPIC_NAME_VALUE_NOT_NULL); CrossTopicMapException.check(topic, this.tm); if (bntype != null) CrossTopicMapException.check(bntype, this.tm); // if type has not been specified, use the default name type if (bntype == null) bntype = getDefaultNameType(); else CrossTopicMapException.check(bntype, this.tm); TopicNameIF name = new TopicName(txn); ((Topic)topic).addTopicName(name); name.setType(bntype); name.setValue(value); return name; }
protected static void addTopicName(TopicIF topic, Relation relation, Entity entity, Field field, int fieldIndex, String[] tuple, Context ctx) { String value = Utils.getValue(relation, entity, field, tuple, ctx); if (!Utils.isValueEmpty(value)) { TopicIF type = Utils.getTopic(field.getType(), ctx); if (type == null && field.getType() != null) throw new DB2TMInputException("Name type not found", entity, tuple, field.getType()); TopicNameIF bn = (TopicNameIF)ctx.reuseOldFieldValue(topic, fieldIndex); if (bn == null) { bn = ctx.getBuilder().makeTopicName(topic, type, value); addScope(bn, field.getScope(), entity, tuple, ctx); log.trace(" +N " + topic + " " + bn); } else { if (!bn.getValue().equals(value)) { bn.setValue(value); log.trace(" =N " + topic + " " + bn); } } // notify context ctx.characteristicsChanged(topic); } }
protected static void addTopicName(TopicIF topic, Relation relation, Entity entity, Field field, int fieldIndex, String[] tuple, Context ctx) { String value = Utils.getValue(relation, entity, field, tuple, ctx); if (!Utils.isValueEmpty(value)) { TopicIF type = Utils.getTopic(field.getType(), ctx); if (type == null && field.getType() != null) throw new DB2TMInputException("Name type not found", entity, tuple, field.getType()); TopicNameIF bn = (TopicNameIF)ctx.reuseOldFieldValue(topic, fieldIndex); if (bn == null) { bn = ctx.getBuilder().makeTopicName(topic, type, value); addScope(bn, field.getScope(), entity, tuple, ctx); log.trace(" +N {} {}", topic, bn); } else { if (!bn.getValue().equals(value)) { bn.setValue(value); log.trace(" =N {} {}", topic, bn); } } // notify context ctx.characteristicsChanged(topic); } }
public TopicNameIF change(TopicMapIF topicMap, TopicNameIF result, TopicName name) { // NameIF if ((name.getValue() != null) && (!name.getValue().equals(result.getValue()))) { result.setValue(name.getValue()); } // TypedIF typed.setType(result, name.getType()); // ScopedIF scoped.setScope(result, name.getScope()); // ReifiableIF reifiable.setReifier(result, name.getReifier()); // TMObjectIF tmobject.setItemIdentifiers(result, name); return result; }
public void testLTMImport() throws IOException, MalformedURLException { String ltm = " [random-id : user = \"Karl Popper\" = \"popper\" / username] " + "ansatt-ved(ontopia-uni : arbeidsgiver, random-id : ansatt)"; LocatorIF base = new URILocator("http://www.example.com"); LTMTopicMapReader reader = new LTMTopicMapReader(new StringReader(ltm), base); reader.importInto(topicmap); topicmap.getStore().commit(); assertTrue("couldn't find base name via string value", index.getTopicNames("popper").size() == 1); TopicNameIF bn = (TopicNameIF) index.getTopicNames("popper").iterator().next(); bn.setValue("popper"); topicmap.getStore().commit(); assertTrue("couldn't find base name via string value after modification", index.getTopicNames("popper").size() == 1); }