String messageObjectName = getProperties().getProperty(MESSAGE_OBJECT_NAME_PROP);
String producerName = getProperties().getProperty(PRODUCER_NAME_PROP);
String xml = INITIAL_XML;
try {
// get the baseline (current value of 'xml' variable)
BasicPerson baselineBp = (BasicPerson)getAppConfig().getObject(messageObjectName);
baselineBp.getXmlEnterpriseObject().getEnterpriseFields().setIgnoreValidation(true);
baselineBp.getXmlEnterpriseObject().buildObjectFromXmlString(getBaselineXml());
// where to get the newdata (the form data)?
BasicPerson bp = (BasicPerson)getAppConfig().getObject(messageObjectName);
bp.setInstitutionalId(getChannelRuntimeData().getParameter("InstitutionalId"));
Name name = bp.newName();
name.setFirstName(getChannelRuntimeData().getParameter("FirstName"));
name.setLastName(getChannelRuntimeData().getParameter("LastName"));
bp.setName(name);
// address info
String[] addrTypes = getChannelRuntimeData().getParameterValues("Address@type");
for (int i=0; i<addrTypes.length; i++) {
String type = addrTypes[i];
if (type == null || type.length() == 0) { continue; }
Address addr = bp.newAddress();
addr.setType(addrTypes[i]);
addr.setStreet1(getChannelRuntimeData().getParameterValues("Street1")[i]);
addr.setCityOrLocality(getChannelRuntimeData().getParameterValues("CityOrLocality")[i]);
addr.setStateOrProvince(getChannelRuntimeData().getParameterValues("StateOrProvince")[i]);
/*
String stateFormValue = getChannelRuntimeData().getParameterValues("StateOrPovince")[i];
if (stateFormValue != null) {
addr.setStateOrProvince(stateFormValue);
}
*/
com.any_erp_vendor.moa.objects.resources.v1_0.Date effDate = addr.newEffectiveDate();
effDate.setMonth(getChannelRuntimeData().getParameterValues("EffectiveDate/Month")[i]);
effDate.setDay(getChannelRuntimeData().getParameterValues("EffectiveDate/Day")[i]);
effDate.setYear(getChannelRuntimeData().getParameterValues("EffectiveDate/Year")[i]);
addr.setEffectiveDate(effDate);
bp.addAddress(addr);
}
bp.getXmlEnterpriseObject().setBaseline(baselineBp.getXmlEnterpriseObject());
LogService.log(LogService.INFO, "[BasicPersonUpdateHandler] built " + messageObjectName + " from form data, performing Update...");
// todo - use producer pool
// todo - map producer name based on message object since different message
// objects may be going against different sources.
bp.update((PointToPointProducer)getAppConfig().getObject(producerName));
LogService.log(LogService.INFO, "[BasicPersonUpdateHandler] " + messageObjectName + " update is done.");
xml = INITIAL_XML;
xml += bp.getXmlEnterpriseObject().toXmlString();
}
catch (Exception openeaiExc) {
LogService.log(LogService.ERROR, openeaiExc);
openeaiExc.printStackTrace();
throw new UportalFormHandlerException("[BasicPersonUpdateHandler] Error performing update action", openeaiExc);