/** * INTERNAL: Set the name that the variant name belongs to. [parent] */ protected void setTopicName(TopicNameIF name) { // Set parent topic map setTopicMap((name == null ? null : (TopicMap)name.getTopicMap())); // Notify transaction valueChanged(LF_name, name, true); }
private static void copyVariants(TopicNameIF target, TopicNameIF source, Map<TopicIF, TopicIF> mergemap) { TopicMapBuilderIF builder = target.getTopicMap().getBuilder(); Iterator<VariantNameIF> it = source.getVariants().iterator(); while (it.hasNext()) { VariantNameIF sv = it.next(); VariantNameIF tv = builder.makeVariantName(target, sv.getValue(), sv.getDataType()); copyScope(tv, sv, mergemap); copyReifier(tv, sv, mergemap); copySourceLocators(tv, sv); } }
/** * INTERNAL: Copies the variant from the source topic to the * target topic. * * @since 4.0 */ public static VariantNameIF copyVariant(TopicNameIF target, VariantNameIF source) { TopicMapBuilderIF builder = target.getTopicMap().getBuilder(); VariantNameIF n = builder.makeVariantName(target, ""); // HACK: needs improvement copyScope(n, source); copyVariantData(n, source); return n; }
public static String toString(String impl, TopicNameIF basename) { String id = UNASSIGNED; try { if (basename.getTopicMap() != null) id = basename.getObjectId(); if (basename.getValue() != null) return "[" + impl + ", " + id + ", '" + basename.getValue() + "']"; else return "[" + impl + ", " + id + "]"; } catch (Throwable t) { return "[" + impl + ", " + basename.getObjectId() + "!]"; } }
private static void update(TopicNameIF tbn, TopicNameIF sbn, DeciderIF<TMObjectIF> tfilter) { TopicMapIF target = tbn.getTopicMap(); TopicMapBuilderIF builder = target.getBuilder();
public void perform(ActionParametersIF params, ActionResponseIF response) { //test params ActionSignature paramsType = ActionSignature.getSignature("b t?"); paramsType.validateArguments(params, this); TopicNameIF basename = (TopicNameIF) params.get(0); Collection themes = params.getCollection(1); String value = params.getStringValue().trim(); TopicMapBuilderIF builder = basename.getTopicMap().getBuilder(); // do not create variant with empty string value if (value == null || value.equals("")) return; // create new (internal) variant for base name VariantNameIF variant = builder.makeVariantName(basename, value); // set scope, if provided if (themes != null) { Iterator it = themes.iterator(); while (it.hasNext()) variant.addTheme((TopicIF) it.next()); } } }
@Override public int compare(TopicNameIF o1, TopicNameIF o2) { TopicMapIF tm = o1.getTopicMap(); TopicIF t1 = o1.getType(); TopicIF t2 = o2.getType(); // check for default type TopicIF untypedname = tm.getTopicBySubjectIdentifier(PSI.getSAMNameType()); if (untypedname == null) { t1 = null; t2 = null; } else { if (untypedname.equals(t1)) t1 = null; if (untypedname.equals(t2)) t2 = null; } // untyped should sort before typed if (t1 == null) { if (t2 != null) return -1; } else { if (t2 == null) return 1; } return super.compare(o1, o2); }
basename.getTopicMap().getBuilder();
public void perform(ActionParametersIF params, ActionResponseIF response) { //test params ActionSignature paramsType = ActionSignature.getSignature("v b?"); paramsType.validateArguments(params, this); VariantNameIF variant = (VariantNameIF) params.get(0); TopicNameIF basename = (TopicNameIF) params.get(1); String value = params.getStringValue(); if (variant == null) { // check if new variant should be created, otherwise do nothing if (value.trim().length() == 0) return; // create new occurrence TopicMapBuilderIF builder = basename.getTopicMap().getBuilder(); variant = builder.makeVariantName(basename, ""); } variant.setValue(value); }
public void perform(ActionParametersIF params, ActionResponseIF response) { //test params ActionSignature paramsType = ActionSignature.getSignature("v b?"); paramsType.validateArguments(params, this); VariantNameIF variant = (VariantNameIF) params.get(0); TopicNameIF basename = (TopicNameIF) params.get(1); String value = params.getStringValue(); if (variant == null) { // check if new variant should be created, otherwise do nothing if (value.trim().length() == 0) return; // create new occurrence TopicMapBuilderIF builder = basename.getTopicMap().getBuilder(); variant = builder.makeVariantName(basename, ""); } try { URILocator loc = new URILocator(value); variant.setLocator(loc); } catch (MalformedURLException e) { throw new ActionRuntimeException("Malformed URL for variant: '" + value + "'", false); } }
assertNull("Association bound to topicmap after removal", assoc.getTopicMap()); assertNull("Occurrence bound to topicmap after removal", occurrence.getTopicMap()); assertNull("Topic name bound to topicmap after removal", name.getTopicMap()); assertNull("Variant name bound to topicmap after removal", variant.getTopicMap());