public Object getEntityFromHashMap(HashMap hm) { ItemBean eb = new ItemBean(); // below inserted to find out a class cast exception, tbh Date dateCreated = (Date) hm.get("date_created"); Date dateUpdated = (Date) hm.get("date_updated"); Integer statusId = (Integer) hm.get("status_id"); Integer ownerId = (Integer) hm.get("owner_id"); Integer updateId = (Integer) hm.get("update_id"); eb.setCreatedDate(dateCreated); eb.setUpdatedDate(dateUpdated); eb.setStatus(Status.get(statusId.intValue())); eb.setOwnerId(ownerId.intValue()); eb.setUpdaterId(updateId.intValue()); // something to trip over // something else to trip over // eb = (ItemBean)this.getEntityAuditInformation(hm); eb.setName((String) hm.get("name")); eb.setId(((Integer) hm.get("item_id")).intValue()); eb.setDescription((String) hm.get("description")); eb.setUnits((String) hm.get("units")); eb.setPhiStatus(((Boolean) hm.get("phi_status")).booleanValue()); eb.setItemDataTypeId(((Integer) hm.get("item_data_type_id")).intValue()); eb.setItemReferenceTypeId(((Integer) hm.get("item_reference_type_id")).intValue()); // logger.info("item name|date type id" + eb.getName() + "|" + // eb.getItemDataTypeId()); eb.setDataType(ItemDataType.get(eb.getItemDataTypeId())); eb.setOid((String) hm.get("oc_oid")); // the rest should be all set return eb; }
public EntityBean update(EntityBean eb) { ItemBean ib = (ItemBean) eb; HashMap variables = new HashMap(); variables.put(new Integer(1), ib.getName()); variables.put(new Integer(2), ib.getDescription()); variables.put(new Integer(3), ib.getUnits()); variables.put(new Integer(4), new Boolean(ib.isPhiStatus())); variables.put(new Integer(5), new Integer(ib.getItemDataTypeId())); variables.put(new Integer(6), new Integer(ib.getItemReferenceTypeId())); variables.put(new Integer(7), new Integer(ib.getStatus().getId())); variables.put(new Integer(8), new Integer(ib.getUpdaterId())); variables.put(new Integer(9), new Integer(ib.getId())); this.execute(digester.getQuery("update"), variables); return eb; }
public EntityBean create(EntityBean eb) { ItemBean ib = (ItemBean) eb; // per the create sql statement HashMap variables = new HashMap(); variables.put(new Integer(1), ib.getName()); variables.put(new Integer(2), ib.getDescription()); variables.put(new Integer(3), ib.getUnits()); variables.put(new Integer(4), new Boolean(ib.isPhiStatus())); variables.put(new Integer(5), new Integer(ib.getItemDataTypeId())); variables.put(new Integer(6), new Integer(ib.getItemReferenceTypeId())); variables.put(new Integer(7), new Integer(ib.getStatus().getId())); variables.put(new Integer(8), new Integer(ib.getOwnerId())); // date_created=now() in Postgres this.execute(digester.getQuery("create"), variables); // set the id here???? return eb; }