state = INVALID_STATE;
} else if ( state == DEFAULT_STATE && ( controlState == Control.OPTIONAL_VALID_CONTROL || controlState == Control.REQUIRED_VALID_CONTROL ) ) {
state = VALID_STATE;
}
}
Result composerResult = new Result(state, GENERATED_CONTROLS, new ArrayValue((Value [])generatedControls.toArray(new Value[generatedControls.size()])));
List generatedTriggers = new ArrayList();
for (int i = 0; i < triggerDescriptions.length; i++ ) {
Map triggerParameters = ((MapValue)triggerDescriptions[i]).getMap();
String triggerName = triggerParameters.get(TRIGGER_NAME).toString();
Value involvedTriggerParameters = (Value)triggerParameters.get(Trigger.INVOLVED_PARAMETERS);
if ( involvedTriggerParameters == NullValue.NULL ) {
involvedTriggerParameters = new ArrayValue((StringValue[])involvedParameters.toArray(new StringValue[involvedParameters.size()]));
}
triggerParameters.put(Trigger.INVOLVED_PARAMETERS, involvedTriggerParameters);
URI triggerUri = (URI)triggerParameters.get(TRIGGER);
Trigger trigger = (Trigger)ProcessorManager.getInstance().getProcessor(triggerUri);
Value triggerActionUri = (Value)triggerParameters.get(Trigger.ACTION);
if ( triggerActionUri == NullValue.NULL ) triggerActionUri = actionUri;
triggerParameters.put(Trigger.ACTION, triggerActionUri);
try {
ProcessorManager.prepareValues(trigger.getParameterDescriptors(), triggerParameters, context);
} catch ( ValidationException exception ) {
throw new ValidationException(new ErrorMessage("controlComposer/triggerParameterInvalid", new Object[] { triggerUri }), exception);
}
Value triggerContainerUri = (Value)triggerParameters.get(TRIGGER_CONTAINER);
Result triggerResult = trigger.process(triggerParameters, context);
if ( triggerContainerUri != NullValue.NULL ) {
Processor triggerContainer = ProcessorManager.getInstance().getProcessor((URI)triggerContainerUri);
Map triggerContainerParameters = new HashMap();
triggerContainerParameters.putAll(parameter);
triggerContainerParameters.put(TRIGGER, triggerResult.getResultEntries().get(OUTPUT));
try {
ProcessorManager.prepareValues(triggerContainer.getParameterDescriptors(), triggerContainerParameters, context);
} catch ( ValidationException exception ) {
throw new ValidationException(new ErrorMessage("controlComposer/triggerContainerParameterInvalid", new Object[] { triggerContainerUri }), exception);
}
Result triggerContainerResult = triggerContainer.process(triggerContainerParameters, context);
generatedTriggers.add(new MapValue(triggerName, (Value)triggerContainerResult.getResultEntries().get(OUTPUT)));
} else {
generatedTriggers.add(new MapValue(triggerName, (Value)triggerResult.getResultEntries().get(OUTPUT)));
}
}
composerResult.addResultEntry(GENERATED_TRIGGERS, new ArrayValue((Value [])generatedTriggers.toArray(new Value[generatedTriggers.size()])));
if ( errorsProcessorUri instanceof URI ) {
Processor errorsTable = ProcessorManager.getInstance().getProcessor((URI)errorsProcessorUri);
List errorList = new ArrayList();
for ( Iterator i = context.getInformations().iterator(); i.hasNext(); ) {
Information info = (Information)i.next();
Map errors = new HashMap();
explodeInformation(errors, info, locale );
errorList.add(new MapValue(errors));
}
Map errorsParameter = new HashMap();
MapValue[] errorsArray = new MapValue[errorList.size()];
errorsParameter.put(SimpleProcessor.INPUT, new ArrayValue((MapValue[])errorList.toArray(errorsArray)));
Result renderedErrors = ProcessorManager.process(errorsTable, errorsParameter, context);
composerResult.addResultEntry(RENDERED_ERRORS, (Value)renderedErrors.getResultEntries().get(OUTPUT));
}
return composerResult;
}