@Override protected OperationResult dbStorageFunction(ArrayList<Object> lo) { try { Administrator data = (Administrator) lo.get(0); String userId = (String) lo.get(1); // DEBUG - TRACE StorageComponentMain.scLog("DEBUG", "METHOD : " + this.getClass().getName()); OperationResult res = new OperationResult(); NullChecker nc = new NullChecker(); userId = nc.check(userId, String.class); data = nc.check(data, Administrator.class); if (!checkUserPermissions("", userId, U_ADMIN)) { // set OperationResult values return Globals.getOpResult(Globals.ResponseCode.PERMISSION_ERROR.getCode(), ""); } try { _session.beginTransaction(); eu.ehealth.db.db.Administrator administrator = new eu.ehealth.db.db.Administrator(); Integer pdid = importPersondata(data.getPersonData(), null); administrator.setPersonData(pdid); _session.save(administrator); _session.getTransaction().commit(); // set OperationResult values res = Globals.getOpResult("" + administrator.getPersonData().toString(), ""); } catch (HibernateException e) { rollbackSession(); StorageComponentMain.logException(e); // set OperationResult values res = Globals.getOpResult( Globals.ResponseCode.DATABASE_ERROR_1.getCode(), " : " + e.toString()); } return res; } catch (Exception ex) { StorageComponentMain.logException(ex); // set OperationResult values return Globals.getOpResult( Globals.ResponseCode.UNKNOWN_ERROR.getCode(), " : " + ex.toString()); } }
/** * @param obj * @param defaultVal * @return */ public static int getIntValue(Object obj, int defaultVal) { try { if (obj == null) { return defaultVal; } return (Integer) obj; } catch (Exception ex) { StorageComponentMain.scLog("ERROR", ex.getMessage()); return defaultVal; } }
/** * @param value * @param vRef * @return 1 if greater, 0 if equal, -2 if lesser, -2 if error */ public static int int_isGreaterThan(String value, int vRef) { try { int iValue = Integer.parseInt(value); if (iValue > vRef) { return 1; } else if (iValue == vRef) { return 0; } return -1; } catch (Exception ex) { StorageComponentMain.scLog("ERROR", ex.getMessage()); return -2; } }