Search in sources :

Example 1 with RecordMap

use of com.dexels.navajo.adapter.sqlmap.RecordMap in project navajo by Dexels.

the class QueryMap method store.

@Override
public void store() throws MappableException, UserException {
    // Construct Navajo message.
    try {
        Message recordSet = NavajoFactory.getInstance().createMessage(outputDoc, "RecordSet", Message.MSG_TYPE_ARRAY);
        try {
            outputDoc.addMessage(recordSet);
        } catch (NavajoException ex) {
            throw new UserException(-1, ex.getMessage(), ex);
        }
        ResultSetMap[] resultSet = getResultSet();
        for (int i = 0; i < resultSet.length; i++) {
            Message record = NavajoFactory.getInstance().createMessage(outputDoc, "RecordSet", Message.MSG_TYPE_ARRAY_ELEMENT);
            recordSet.addElement(record);
            RecordMap[] columns = resultSet[i].getRecords();
            for (int j = 0; j < columns.length; j++) {
                try {
                    Object value = columns[j].getRecordValue();
                    String type = (value != null ? MappingUtils.determineNavajoType(value) : "unknown");
                    Property prop = NavajoFactory.getInstance().createProperty(outputDoc, columns[j].recordName, type, null, 0, "", Property.DIR_IN);
                    prop.setAnyValue(value);
                    record.addProperty(prop);
                } catch (Exception ex1) {
                    throw new UserException(-1, ex1.getMessage(), ex1);
                }
            }
        }
    } finally {
        super.store();
    }
}
Also used : RecordMap(com.dexels.navajo.adapter.sqlmap.RecordMap) Message(com.dexels.navajo.document.Message) NavajoException(com.dexels.navajo.document.NavajoException) ResultSetMap(com.dexels.navajo.adapter.sqlmap.ResultSetMap) UserException(com.dexels.navajo.script.api.UserException) Property(com.dexels.navajo.document.Property) UserException(com.dexels.navajo.script.api.UserException) MappableException(com.dexels.navajo.script.api.MappableException) NavajoException(com.dexels.navajo.document.NavajoException)

Aggregations

RecordMap (com.dexels.navajo.adapter.sqlmap.RecordMap)1 ResultSetMap (com.dexels.navajo.adapter.sqlmap.ResultSetMap)1 Message (com.dexels.navajo.document.Message)1 NavajoException (com.dexels.navajo.document.NavajoException)1 Property (com.dexels.navajo.document.Property)1 MappableException (com.dexels.navajo.script.api.MappableException)1 UserException (com.dexels.navajo.script.api.UserException)1