@Override public void modify(TMObjectIF object, Object v) { if (!(object instanceof TopicIF)) return; TopicIF topic = (TopicIF) object; TopicIF type = (TopicIF) v; topic.removeType(type); } }
protected static void removeTypes(TopicIF topic, String[] types, Context ctx) { for (int i = 0; i < types.length; i++) { TopicIF type = Utils.getTopic(types[i], ctx); if (type != null) topic.removeType(type); } }
protected static void removeTypes(TopicIF topic, String[] types, Context ctx) { for (int i = 0; i < types.length; i++) { TopicIF type = Utils.getTopic(types[i], ctx); if (type != null) topic.removeType(type); } }
/** * INTERNAL: Replace source by target as the type of objects. */ private static void replaceTopicTypes(Collection<TopicIF> objects, TopicIF target, TopicIF source) { Iterator<TopicIF> it = objects.iterator(); while (it.hasNext()) { TopicIF object = it.next(); object.removeType(source); object.addType(target); } }
@Override public void removeType(Topic type) { Check.typeNotNull(this, type); wrapped.removeType(topicMap.unwrapTopic(type)); }
public void removeType(TopicIF topic, Topic type) { topic.removeType(resolve(topic.getTopicMap(), type)); } }
/** * Removes the topic type from the list of topic types that topic is * a direct instance of. */ public void removeTopicType(TopicType type) { if (type == null) throw new OntopiaRuntimeException("The input parameter is null"); getTopicIF().removeType(type.getTopicIF()); }
/** * Removes the topic type from the list of topic types that topic is * a direct instance of. */ public void removeTopicType(TopicType type) { if (type == null) throw new OntopiaRuntimeException("The input parameter is null"); getTopicIF().removeType(type.getTopicIF()); }
public void perform(ActionParametersIF params, ActionResponseIF response) { //test params ActionSignature paramsType = ActionSignature.getSignature("t t"); paramsType.validateArguments(params, this); TopicIF topic = (TopicIF) params.get(0); TopicIF type = (TopicIF) params.get(1); topic.removeType(type); }
protected static void makePublicSystemTopic(TopicMapIF topicmap, LocatorIF base_on, LocatorIF base_t, String topic) { TopicIF systemTopic = getTopic(topicmap, base_on, "system-topic"); TopicIF publicSystemTopic = getTopic(topicmap, base_on, "public-system-topic"); TopicIF t = getTopic(topicmap, base_t, topic); t.removeType(systemTopic); t.addType(publicSystemTopic); }
protected static void updateTypes(TopicIF topic, String[] types, Entity entity, String[] tuple, Context ctx) { // this is a bit convoluted because we don't want to change anything // unless the set of types has actually changed // tracking old types with this Set<TopicIF> oldtypes = new CompactHashSet(topic.getTypes()); // loop over new list of types for (int i = 0; i < types.length; i++) { TopicIF type = Utils.getTopic(types[i], ctx); if (type == null) throw new DB2TMInputException("Topic type not found", entity, tuple, types[i]); if (oldtypes.contains(type)) oldtypes.remove(type); else topic.addType(type); } // any old types that still remain need to be removed for (TopicIF oldtype : oldtypes) topic.removeType(oldtype); }
protected static void makePublicSystemTopic(TopicMapIF topicmap, LocatorIF base_on, LocatorIF base_t, String topic) { TopicIF systemTopic = getTopic(topicmap, base_on, "system-topic"); TopicIF publicSystemTopic = getTopic(topicmap, base_on, "public-system-topic"); TopicIF t = getTopic(topicmap, base_t, topic); t.removeType(systemTopic); t.addType(publicSystemTopic); }
protected static void updateTypes(TopicIF topic, String[] types, Entity entity, String[] tuple, Context ctx) { // this is a bit convoluted because we don't want to change anything // unless the set of types has actually changed // tracking old types with this Set<TopicIF> oldtypes = new CompactHashSet<TopicIF>(topic.getTypes()); // loop over new list of types for (int i = 0; i < types.length; i++) { TopicIF type = Utils.getTopic(types[i], ctx); if (type == null) throw new DB2TMInputException("Topic type not found", entity, tuple, types[i]); if (oldtypes.contains(type)) oldtypes.remove(type); else topic.addType(type); } // any old types that still remain need to be removed for (TopicIF oldtype : oldtypes) topic.removeType(oldtype); }
public void perform(ActionParametersIF params, ActionResponseIF response) { //test params ActionSignature paramsType = ActionSignature.getSignature("t"); paramsType.validateArguments(params, this); TopicIF topic = (TopicIF) params.get(0); TopicIF type = (TopicIF) params.getTMObjectValue(); // first remove all existing typing topics Collection typing_topics = topic.getTypes(); if (!typing_topics.isEmpty()) { Object[] types = typing_topics.toArray(); for (int i=0; i < types.length; i++) { topic.removeType((TopicIF)types[i]); } } // now set the type of this topic (if the user chose one) if (type != null) topic.addType(type); }
public void setTypes(TopicIF object, Topic pojo) { if (pojo.getTypes() != null) { Collection<TopicIF> newTypes = new HashSet<>(pojo.getTypes().size()); for (Topic t : pojo.getTypes()) { TopicIF resolved = resolve(object.getTopicMap(), t); newTypes.add(resolved); } for (TopicIF remove : CollectionUtils.subtract(object.getTypes(), newTypes)) { object.removeType(remove); } for (TopicIF add : newTypes) { object.addType(add); } } }
@Override public void run() { TopicIF t = getTopic(); TopicIF type = (TopicIF)this.data.remove("type"); t.removeType(type); this.objectId = t.getObjectId(); this.value = type.getObjectId(); } });
public void testTypes() { // STATE 1 assertTrue("type set not empty initially", topic.getTypes().size() == 0); // STATE 2 TopicIF type = builder.makeTopic(); topic.addType(type); assertTrue("type not added", topic.getTypes().size() == 1); assertTrue("type identity not retained", topic.getTypes().iterator().next().equals(type)); topic.addType(type); assertTrue("duplicate not rejected", topic.getTypes().size() == 1); // STATE 2 topic.removeType(type); assertTrue("type not removed", topic.getTypes().size() == 0); // verify that it's safe topic.removeType(type); }
public void testTopicsDynamic() { // create some topics for the topic map TopicIF tt1 = builder.makeTopic(); TopicIF t1 = builder.makeTopic(); t1.addType(tt1); assertTrue("TopicMapIF.addTopic does not update index", index.getTopics(tt1).size() == 1); t1.removeType(tt1); assertTrue("TopicIF.removeType does not update index", index.getTopics(tt1).size() == 0); t1.addType(tt1); assertTrue("TopicIF.addType does not update index", index.getTopics(tt1).size() == 1); t1.remove(); assertTrue("TopicMapIF.removeTopic does not update index", index.getTopics(tt1).size() == 0); }
topic.addType((TopicIF)tm.getObjectByItemIdentifier(loc2)); assertTrue("getTypes (size check after add)", topic.getTypes().size() == types_size + 2); topic.removeType((TopicIF)tm.getObjectByItemIdentifier(loc1)); topic.removeType((TopicIF)tm.getObjectByItemIdentifier(loc2)); assertTrue("getTypes (size check after remove)", topic.getTypes().size() == types_size);
inst.removeType(type);