@Override public void remove() { getWrapped().remove(); }
public TMO remove(TMO object) throws OntopiaRestException { if (object == null) { // todo: OntopiaRestErrors throw new OntopiaClientException(Status.CLIENT_ERROR_NOT_FOUND, "Cannot find " + objectClass.getSimpleName() + " to remove"); } // todo: move to controller object.remove(); store.commit(); return object; }
@Override protected int doLitListDeletes(boolean strict, Map arguments) throws InvalidQueryException { int deletes = 0; for (int ix = 0; ix < litlist.size(); ix++) { Object lit = litlist.get(ix); if (lit instanceof Parameter) lit = arguments.get(((Parameter) lit).getName()); if (lit instanceof TMObjectIF) { ((TMObjectIF) lit).remove(); deletes++; } else if (strict) throw new InvalidQueryException("Invalid reference in litlist: " + lit); } return deletes; }
private void runQuery(ParsedQueryIF query, Map args) throws InvalidQueryException { log.debug("Running query for: " + args.get("topic")); QueryResultIF result = query.execute(args); while (result.next()) { for (int ix = 0; ix < result.getWidth(); ix++) { log.debug("Removing: " + result.getValue(ix)); ((TMObjectIF) result.getValue(ix)).remove(); } } result.close(); }
public void perform(ActionParametersIF params, ActionResponseIF response) { //test params ActionSignature paramsType = ActionSignature.getSignature("x& x?"); paramsType.validateArguments(params, this); Collection objects = params.getCollection(0); if (objects == null) { TMObjectIF object = params.getTMObjectValue(); if (object != null) objects = Collections.singleton(object); else objects = Collections.EMPTY_SET; } Iterator it = objects.iterator(); while (it.hasNext()) ((TMObjectIF) it.next()).remove(); TMObjectIF next = (TMObjectIF) params.get(1); if (next != null) response.addParameter(Constants.RP_TOPIC_ID, next.getObjectId()); }
@SuppressWarnings("unchecked") private static <O extends TMObjectIF> O resolveIdentities(O target, O source) { TopicMapIF targettm = target.getTopicMap(); Iterator<LocatorIF> it = source.getItemIdentifiers().iterator(); while (it.hasNext()) { LocatorIF loc = it.next(); TMObjectIF object = targettm.getObjectByItemIdentifier(loc); if (object != null) { if (!equals(target, object)) { throw new ConstraintViolationException("Different topic map objects have " + "the same source locator (" + loc + "): " + target + " and " + object); } else { target.remove(); return (O) object; // this is a duplicate } } else target.addItemIdentifier(loc); } return target; }
private int doNormalDeletes(QueryMatches matches) throws InvalidQueryException{ int deletes = doLitListDeletes(false, matches.getQueryContext().getParameters()); // INV: the final QueryMatches object contains only variables actually // used in the litlist, so we can go through and just delete everything for (int row = 0; row <= matches.last; row++) { for (int col = 0; col < matches.colcount; col++) { Object o = matches.data[row][col]; if (o instanceof TMObjectIF) { ((TMObjectIF) o).remove(); deletes++; } else throw new InvalidQueryException("Deleting non-topic map object: " + o); } } return deletes; }
protected static void removeObjects(TopicMapIF topicMap, DeclarationContextIF dc, String removalQuery) throws InvalidQueryException { QueryProcessorIF qp = QueryUtils.getQueryProcessor(topicMap); QueryResultIF qr = null; try { qr = qp.execute(removalQuery, dc); while (qr.next()) { TMObjectIF tmobject = (TMObjectIF)qr.getValue(0); if (tmobject.getTopicMap() != null) { tmobject.remove(); } } } finally { if (qr != null) qr.close(); } }
protected static void removeObjects(TopicMapIF topicMap, DeclarationContextIF dc, String removalQuery) throws InvalidQueryException { QueryProcessorIF qp = QueryUtils.getQueryProcessor(topicMap); QueryResultIF qr = null; try { qr = qp.execute(removalQuery, dc); while (qr.next()) { TMObjectIF tmobject = (TMObjectIF)qr.getValue(0); if (tmobject.getTopicMap() != null) { tmobject.remove(); } } } finally { if (qr != null) qr.close(); } }
public void perform(ActionParametersIF params, ActionResponseIF response) { QueryProcessorIF processor = QueryUtils.getQueryProcessor((TopicMapIF) params.get(1)); Collection queries = params.getCollection(0); try { // iterate over the queries and run them one by one Iterator it = queries.iterator(); while (it.hasNext()) { QueryResultIF result = processor.execute((String) it.next()); while (result.next()) { for (int ix = 0; ix < result.getWidth(); ix++) { ((TMObjectIF) result.getValue(ix)).remove(); } } result.close(); } TMObjectIF next = (TMObjectIF) params.get(2); if (next != null) response.addParameter(Constants.RP_TOPIC_ID, next.getObjectId()); } catch (InvalidQueryException e) { throw new ActionRuntimeException(e); } }
log.debug("Removing: " + o); if (!simulate) o.remove();