public void run( Constraint object, Resource resource, IProgressMonitor monitor, Map<String, VCObject> seenObjects, List<Option> globalOptions) throws JCoException { // determine name of containing dependencyNet // TODO implement finding containing dependency net with ECoreUtils DependencyNet dependencyNet = null; VcmlModel model = (VcmlModel) object.eContainer(); for (Object o : EcoreUtil.getObjectsByType(model.getObjects(), VcmlPackage.Literals.DEPENDENCY_NET)) { DependencyNet depNet = (DependencyNet) o; if (depNet.getConstraints().contains(object)) { dependencyNet = depNet; break; } } beginTransaction(); JCoFunction function = getJCoFunction("CAMA_CNET_CONSTRAINT_MAINTAIN", monitor); JCoParameterList ipl = function.getImportParameterList(); handleOptions(object.getOptions(), globalOptions, ipl, "CHANGE_NO", null); ipl.setValue("CONSTRAINT", object.getName()); if (dependencyNet != null) { ipl.setValue("CONSTRAINT_NET", dependencyNet.getName()); } ipl.setValue("DELETE_FLAG", "X"); try { execute(function, monitor, "DELETE " + object.getName()); endTransaction(); } catch (AbapException e) { handleAbapException(e); } }
public static <T extends VCObject> Iterable<T> getObjectsByNameAndType( final String name, VcmlModel vcmlModel, final java.lang.Class<T> type) { if (vcmlModel == null || type == null) { return Lists.newArrayList(); } else { Iterable<T> typeFilter = Iterables.filter(vcmlModel.getObjects(), type); if (name == null || name.isEmpty()) { return typeFilter; } else { return Iterables.filter( typeFilter, new Predicate<VCObject>() { public boolean apply(VCObject object) { return name.equals(object.getName()) && type.isAssignableFrom(object.getClass()); } }); } } }