Date begD, Date endDate, String datasetLabel,
Integer modInstId, KpiValue kpiVal) throws EMFUserError, SourceBeanException{
int length = fields.size();
String xmlData = null;
String tempXMLroot = "<XML_DATA></XML_DATA>";
SourceBean dsValuesXml = SourceBean.fromXMLString(tempXMLroot);
boolean valueFound = false;
for(int fieldIndex =0; fieldIndex<length; fieldIndex++){
IField f = (IField)fields.get(fieldIndex);
if (f != null) {
if (f.getValue() != null) {
String fieldName = d.getFieldName(fieldIndex);
if (fieldName.equalsIgnoreCase("DESCR")){
String descr = f.getValue().toString();
kpiValueToReturn.setValueDescr(descr);
logger.debug("Setted the kpiValue description:"+descr);
}else if(fieldName.equalsIgnoreCase("END_DATE")){
String endD = f.getValue().toString();
String format = "dd/MM/yyyy hh:mm:ss";
SimpleDateFormat form = new SimpleDateFormat();
form.applyPattern(format);
try {
endDate = form.parse(endD);
} catch (ParseException e) {
e.printStackTrace();
}
if(endDate!=null && endDate.after(begD)) {
kpiValueToReturn.setEndDate(endDate);
logger.debug("Setted the new EndDate description:"+endD.toString());
}
}else if(fieldName.equalsIgnoreCase("VALUE")){
String fieldValue = f.getValue().toString();
kpiValueToReturn.setValue(fieldValue);
logger.debug("Setted the kpiValue value:"+fieldValue);
valueFound = true;
}
else if(fieldName.equalsIgnoreCase("XML_DATA")){
xmlData = f.getValue().toString();
kpiValueToReturn.setValueXml(xmlData);
logger.debug("Setted the kpiValue xmlData:"+xmlData);
}
else if(fieldName.equalsIgnoreCase(RESOURCE)){
String fieldValue = f.getValue().toString();
if (fieldValue!=null){
Resource rTemp = DAOFactory.getResourceDAO().loadResourcesByNameAndModelInst(fieldValue);
kpiValueToReturn.setR(rTemp);
logger.info("Setted the kpiValue Resource with resource name:"+fieldValue);
}
}/*else if(fieldName.equalsIgnoreCase("ORG_UNIT_ID")){
String fieldValue = f.getValue().toString();
if (fieldValue!=null){
Resource rTemp = DAOFactory.getResourceDAO().loadResourcesByNameAndModelInst(fieldValue);
kpiValueToReturn.setR(rTemp);
logger.info("Setted the kpiValue Resource with resource name:"+fieldValue);
}
}*/ else{
String fieldValue = f.getValue().toString();
if (fieldValue!=null){
dsValuesXml.setAttribute(fieldName, fieldValue);
}
}
}
}
}
if(xmlData==null && dsValuesXml!=null){
xmlData = dsValuesXml.toXML(false);
kpiValueToReturn.setValueXml(xmlData);
logger.debug("Setted the kpiValue xmlData:"+xmlData);
}
if (kpiValueToReturn == null && valueFound == true){