@Override public void execute() { super.execute(); // Now we'll do recursive MatchMapping. // (We need to iterate over a copy, since we modify the underlying list in the loop.) for (Command command : new ArrayList<Command>(commandList)) { appendAndExecute(NameMatchMappingCommand.create(domain, (Mapping)command.getResult().iterator().next())); } }
protected void matchChildren(Collection<?> inputChildren, Collection<?> outputChildren) { ArrayList<Object> newMappedInputs = new ArrayList<Object>(); mappedInputs = newMappedInputs; MappingRoot mappingRoot = domain.getMappingRoot(); boolean multipleMatchesAllowed = (domain.getMappingEnablementFlags() & MappingDomain.ENABLE_MULTIPLE_INPUT_MAPPINGS) != 0; for (Object childOutput : outputChildren) { if (mappingRoot.getMappings(childOutput).isEmpty()) { Collection<Object> mappedObjects = new ArrayList<Object>(); for (Object childInput : inputChildren) { boolean canCreateMapping = multipleMatchesAllowed || (!mappedInputs.contains(childInput) && mappingRoot.getMappings(childInput).isEmpty()); if (canCreateMapping && match(childInput, childOutput, mappedObjects)) { break; } } if (!mappedObjects.isEmpty()) { newMappedInputs.addAll(mappedObjects); mappedObjects.add(childOutput); Command mapCommand = CreateMappingCommand.create(domain, mappedObjects); appendIfCanExecute(mapCommand); } } } }
@Override protected boolean prepare() { if (domain != null && mapping != null) { Collection<Object> inputChildren = new ArrayList<Object>(); for (Object input : mapping.getSenders()) { inputChildren.addAll(domain.getChildren(input)); } Collection<Object> outputChildren = new ArrayList<Object>(); for (Object output : mapping.getReceivers()) { outputChildren.addAll(domain.getChildren(output)); } matchChildren(inputChildren, outputChildren); } // We have done our preparation. Now ask the super to validate. // boolean result = super.prepare(); return result; }
protected void matchChildren(Collection<?> inputChildren, Collection<?> outputChildren) { ArrayList<Object> newMappedInputs = new ArrayList<Object>(); mappedInputs = newMappedInputs; MappingRoot mappingRoot = domain.getMappingRoot(); boolean multipleMatchesAllowed = (domain.getMappingEnablementFlags() & MappingDomain.ENABLE_MULTIPLE_INPUT_MAPPINGS) != 0; for (Object childOutput : outputChildren) { if (mappingRoot.getMappings(childOutput).isEmpty()) { Collection<Object> mappedObjects = new ArrayList<Object>(); for (Object childInput : inputChildren) { boolean canCreateMapping = multipleMatchesAllowed || (!mappedInputs.contains(childInput) && mappingRoot.getMappings(childInput).isEmpty()); if (canCreateMapping && match(childInput, childOutput, mappedObjects)) { break; } } if (!mappedObjects.isEmpty()) { newMappedInputs.addAll(mappedObjects); mappedObjects.add(childOutput); Command mapCommand = CreateMappingCommand.create(domain, mappedObjects); appendIfCanExecute(mapCommand); } } } }
@Override protected boolean prepare() { if (domain != null && mapping != null) { Collection<Object> inputChildren = new ArrayList<Object>(); for (Object input : mapping.getSenders()) { inputChildren.addAll(domain.getChildren(input)); } Collection<Object> outputChildren = new ArrayList<Object>(); for (Object output : mapping.getReceivers()) { outputChildren.addAll(domain.getChildren(output)); } matchChildren(inputChildren, outputChildren); } // We have done our preparation. Now ask the super to validate. // boolean result = super.prepare(); return result; }
@Override public void execute() { super.execute(); // Now we'll do recursive MatchMapping. // (We need to iterate over a copy, since we modify the underlying list in the loop.) for (Command command : new ArrayList<Command>(commandList)) { appendAndExecute(NameMatchMappingCommand.create(domain, (Mapping)command.getResult().iterator().next())); } }