// --------------------------
return (counter > 1);
}
-
-// ==============================================================================================================================
-// Public services
-// ==============================================================================================================================
-
- public static SimulationContextType createType (String name, ProjectSettingsService.Step step) throws InvalidPropertyException, RuntimeException {
-// ---------------------------------------------------------------------------------------
-//TODO: Check for duplicate definition
- SimulationContextType type = new SimulationContextType(name, step);
- Session session = Database.getSession();
- session.save(type);
-
- return type;
- }
-
- @SuppressWarnings("unchecked")
- public static List<SimulationContextType> selectAllTypes () {
-// -----------------------------------------------------------
- StringBuffer query = new StringBuffer("from SimulationContextType"); // Useless to order by names as the result mixes localized and non localized types
- query = query.append(" order by step asc");
- return Database.getSession().createQuery(query.toString()).list();
- }
-
- @SuppressWarnings("unchecked")
- public static List<SimulationContextType> selectTypesOf (ProjectSettingsService.Step... step) {
-// --------------------------------------------------------------------------------------
- StringBuffer query = new StringBuffer("from SimulationContextType where step='").append(step[0].getNumber()).append("'");
- for (int i=1; i<step.length; i++) { // Useless to order as the result mixes localized and non localized types
- query = query.append(" or step='").append(step[i].getNumber()).append("'");
- }
- query = query.append(" order by step asc");
- return Database.getSession().createQuery(query.toString()).list();
- }
-
- @SuppressWarnings("unchecked")
- public static List<SimulationContextType> selectTypesWhere (SimulationContextType.Properties sprop) {
-// ---------------------------------------------------------------------------------------------------
- StringBuffer query = new StringBuffer("from SimulationContextType");
- String separator = " where";
- ProjectSettingsService.Step step = sprop.getStep();
- ProgressState state = sprop.getProgressState();
- String order = " order by step asc";
-
- if (step != null) {
- query = query.append(separator).append(" step='").append(step.getNumber()).append("'");
- separator = " and";
- order = " order by state desc"; // APPROVED (upper case A) is grater than inCHECK (lower case i)
- }
- if (state != null) {
- query = query.append(separator).append(" state='").append(state.toString()).append("'");
-// separator = " and";
- if (step != null) {
- if (state != ProgressState.APPROVED) order = " order by name asc";
- else order = ""; // Approved types are localized
- }
- }
- query = query.append(order);
- return Database.getSession().createQuery(query.toString()).list();
- }
-
- public static SimulationContextType selectType (String name) {
-// ------------------------------------------------------------
- StringBuffer query = new StringBuffer("from SimulationContextType where name='").append(name).append("'");
- return (SimulationContextType)Database.getSession().createQuery(query.toString()).uniqueResult();
- }
-
- public static SimulationContextType selectType (int index) {
-// ----------------------------------------------------------
- StringBuffer query = new StringBuffer("from SimulationContextType where rid='").append(index).append("'");
- return (SimulationContextType)Database.getSession().createQuery(query.toString()).uniqueResult();
- }
-
-// ==============================================================================================================================
-// Protected services
-// ==============================================================================================================================
-
- public void hold () {
-// ----------------------
- counter += 1;
- if (this.isSaved()) Database.getSession().update(this);
- }
-
- public void release () {
-// -------------------------
- counter -= 1;
- if (this.isSaved()) Database.getSession().update(this);
- }
+ /**
+ * Get counter.
+ * @return counter
+ */
+ public int getCounter() {
+ return counter;
+ }
+ /**
+ * Set counter.
+ * @param aValue a counter value to set
+ */
+ public void setCounter(int aValue) {
+ counter = aValue;
+ }
}
\ No newline at end of file