/** * Saves a new/modified list entry If sortOrder is not set it will be set to be the next available * sortOrder according to listID and parentID * * @param systemStateBean * @param locale * @return */ static synchronized Integer save(TSystemStateBean systemStateBean, Locale locale) { boolean isNew = systemStateBean.getObjectID() == null; if (systemStateBean.getSortorder() == null) { Integer sortOrder = systemStateDAO.getNextSortOrder(systemStateBean.getEntityflag()); systemStateBean.setSortorder(sortOrder); } Integer objectID = systemStateDAO.save(systemStateBean); if (isNew) { systemStateBean.setObjectID(objectID); } else { // The localization is loaded from localized resources table, and if not found, // from the localized property files, and if not found from the "native" table. // The value should be saved also with the default locale only if it is edited // (new entities have no correspondence in the localized property files) LocalizeBL.saveSystemStateLocalizedResource( systemStateBean.getEntityflag(), systemStateBean.getObjectID(), systemStateBean.getLabel(), locale); } // cache and possible lucene update in other cluster nodes LookupContainer.resetSystemStateMap(systemStateBean.getEntityflag()); ClusterMarkChangesBL.markDirtySystemStatesListEntryInCluster( systemStateBean.getEntityflag(), objectID); return objectID; }
/** Saves the label bean into the database */ static Integer saveSimple(ILabelBean labelBean) { TSystemStateBean systemStateBean = (TSystemStateBean) labelBean; Integer systemStatusID = systemStateDAO.save(systemStateBean); LookupContainer.resetSystemStateMap(systemStateBean.getEntityflag()); ClusterMarkChangesBL.markDirtySystemStatesListEntryInCluster( systemStateBean.getEntityflag(), systemStatusID); return systemStatusID; }
/** * Gets the localized options for an entity * * @param locale * @return */ public static List<TSystemStateBean> getStatusOptions(Integer entityFlag, Locale locale) { List<TSystemStateBean> statusOptions = LookupContainer.getSystemStateList(entityFlag); if (statusOptions != null) { for (TSystemStateBean systemStateBean : statusOptions) { systemStateBean.setLabel( LocalizeUtil.localizeSystemStateEntry(systemStateBean, entityFlag, locale)); } } return statusOptions; }
/** * Get the stateIDs by entityType an state flags * * @param entityType * @param stateFlag * @return */ public static List<TSystemStateBean> getSystemStatesByByEntityAndStateFlags( Integer entityType, int[] stateFlagArr) { List<TSystemStateBean> systemList = LookupContainer.getSystemStateList(entityType); List<TSystemStateBean> systemListByStateFlag = new LinkedList<TSystemStateBean>(); Set<Integer> stateFlagsSet = GeneralUtils.createSetFromIntArr(stateFlagArr); if (systemList != null) { for (TSystemStateBean systemStateBean : systemList) { Integer stateFlag = systemStateBean.getStateflag(); if (stateFlagsSet.contains(stateFlag)) { systemListByStateFlag.add(systemStateBean); } } } return systemListByStateFlag; // systemStateDAO.loadWithStateFlagForEntity(entityType, // stateFlag); }
/** * Gets the status flag for an objectID * * @param statusID * @return */ public static Integer getStatusFlagForStatusID(Integer entityType, Integer statusID) { List<TSystemStateBean> systemStateList = LookupContainer.getSystemStateList(entityType); if (systemStateList != null) { for (TSystemStateBean systemStateBean : systemStateList) { Integer objectID = systemStateBean.getObjectID(); if (objectID.equals(statusID)) { return systemStateBean.getStateflag(); } } } TSystemStateBean systemStateBean = systemStateDAO.loadByPrimaryKey(statusID); if (systemStateBean != null) { return systemStateBean.getStateflag(); } return null; }
/** * Deletes the severity * * @param objectID */ static void delete(Integer objectID) { if (objectID != null) { TSystemStateBean systemStateBean = systemStateDAO.loadByPrimaryKey(objectID); Integer iconKey = null; if (systemStateBean != null) { iconKey = systemStateBean.getIconKey(); } systemStateDAO.delete(objectID); if (iconKey != null) { BlobBL.delete(iconKey); } // remove localized resource LocalizeBL.removeLocalizedResources( new TSystemStateBean().getKeyPrefix() + systemStateBean.getEntityflag() + ".", objectID); LookupContainer.resetSystemStateMap(systemStateBean.getEntityflag()); ClusterMarkChangesBL.markDirtySystemStatesListEntryInCluster( systemStateBean.getEntityflag(), objectID); } }
/** * sets an associated TSystemStateBean object * * @param v TSystemStateBean */ public void setTSystemStateBean(TSystemStateBean v) { if (v == null) { setStatus((Integer) null); } else { setStatus(v.getObjectID()); } aTSystemStateBean = v; }