private static void moveItemIdentifiers(TMObjectIF target, TMObjectIF source) { Iterator<LocatorIF> it = new ArrayList<LocatorIF>(source.getItemIdentifiers()).iterator(); while (it.hasNext()) { LocatorIF itemid = it.next(); source.removeItemIdentifier(itemid); target.addItemIdentifier(itemid); } }
private static void copySourceLocators(TMObjectIF target, TMObjectIF source) { Collection<LocatorIF> srclocs = source.getItemIdentifiers(); if (srclocs.isEmpty()) return; LocatorIF[] list = srclocs.toArray(new LocatorIF[srclocs.size()]); for (int i = 0; i < list.length; i++) { LocatorIF loc = list[i]; source.removeItemIdentifier(loc); target.addItemIdentifier(loc); } }
@Override public void modify(TMObjectIF object, Object v) { String value = (String) v; try { object.removeItemIdentifier(new URILocator(value)); } catch (MalformedURLException e) { throw new OntopiaRuntimeException("Invalid URI: " + value); } } }
@Override public void removeItemIdentifier(Locator iid) { getWrapped().removeItemIdentifier(topicMap.unwrapLocator(iid)); }
public void perform(ActionParametersIF params, ActionResponseIF response) { //test params ActionSignature paramsType = ActionSignature.getSignature("x ls"); paramsType.validateArguments(params, this); TMObjectIF object = (TMObjectIF) params.get(0); Object param1 = params.get(1); LocatorIF locator = null; if (param1 instanceof LocatorIF) locator = (LocatorIF) param1; else if (param1 instanceof String) { try { locator = new URILocator((String) param1); } catch (MalformedURLException e) { throw new ActionRuntimeException("Unable to create URI locator from '" + param1 + "'", false); } } else throw new ActionRuntimeException("Unable to create URI locator." + " Second parameter to RemoveSourceLocator must be either a" + " LocatorIF or a String, but was a " + param1.getClass().getName() + ".", true); object.removeItemIdentifier(locator); }
public void setItemIdentifiers(TMObjectIF object, TMObject pojo) { if (pojo.getItemIdentifiers() != null) { Collection<LocatorIF> toRemove = CollectionUtils.subtract(object.getItemIdentifiers(), pojo.getItemIdentifiers()); for (LocatorIF ii : pojo.getItemIdentifiers()) { object.addItemIdentifier(ii); } for (LocatorIF ii : toRemove) { object.removeItemIdentifier(ii); } } }
object.removeItemIdentifier(locator); } catch (MalformedURLException e) { throw new ActionRuntimeException("Malformed URL for source locator: '" + newAddress + "'", false);
object.removeItemIdentifier(loc); assertTrue("source locator not removed", object.getItemIdentifiers().size() == 0); object.removeItemIdentifier(loc);
public void testMoveSourceLocators() { // bug #273 try { URILocator loc = new URILocator("http://www.ontopia.net"); TopicIF topic = builder.makeTopic(); object.addItemIdentifier(loc); // we do this here to make the RDBMS backend write the // changes in the transaction to the DB URILocator loc2 = new URILocator("http://www.ontopia.com"); TMObjectIF lookedup = topicmap.getObjectByItemIdentifier(loc2); // </end> // ready to blow us up object.removeItemIdentifier(loc); topic.addItemIdentifier(loc); lookedup = topicmap.getObjectByItemIdentifier(loc); assertTrue("wrong object returned on lookup: " + lookedup, lookedup == topic); } catch (MalformedURLException e) { fail("(INTERNAL) bad URL given" + e); } }