}
}
- // Database fetch constructor
protected Document() {
+ // Database fetch constructor
}
// Internal constructor
public Document getPreviousVersion() {
// -------------------------------------
Relation previous = getFirstRelation(VersionsRelation.class);
- if (previous != null) {
- return (Document) previous.getTo();
- } else {
+ if (previous == null) {
return null;
+ } else {
+ return (Document) previous.getTo();
}
}
return res;// TODO: Get schema version from the specific object/table
}
- protected void setSchemaVersion(final String version) {
- // TODO: Set schema version into specific object/table: myIDpool = new IDPool(version);
+ protected void setSchemaVersion(final String version) { // RKV: NOPMD: TODO: Set schema version into specific object/table
+ // RKV: NOPMD: TODO: Set schema version into specific object/table: myIDpool = new IDPool(version);
// getSession().save(myIDpool);
}
}
\ No newline at end of file
--- /dev/null
+/*****************************************************************************
+ * Company OPEN CASCADE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 08.10.2012
+ * @author $Author$
+ * @version $Revision$
+ *****************************************************************************/
+
+package org.splat.dal.dao.kernel;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Properties;
+
+import org.hibernate.Criteria;
+import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Restrictions;
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
+
+/**
+ * Generic DAO implementation.
+ *
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ *
+ * @param <T>
+ * Persistent object class
+ * @param <PK>
+ * Primary key class
+ */
+public abstract class AbstractGenericDAOImpl<T, PK extends Serializable> extends
+ HibernateDaoSupport implements GenericDAO<T, PK> {
+ /**
+ * Unchecked warning specification.
+ */
+ private static final String UNCHECKED = "unchecked";
+ /**
+ * Persist the newInstance object into database.
+ *
+ * @param newInstance
+ * new object as a transient instance
+ * @return new primary key for the created persistent object
+ */
+ @SuppressWarnings(UNCHECKED)
+ public PK create(final T newInstance) {
+ return (PK) getSession().save(newInstance);
+ }
+
+ /**
+ * Retrieve an object that was previously persisted to the database using the indicated id as primary key.
+ *
+ * @param id
+ * primary key of an object to read
+ * @return an object found by the given key
+ */
+ @SuppressWarnings(UNCHECKED)
+ public T get(final PK id) {
+ return (T) getSession().get(getType(), id);
+ }
+
+ /**
+ * Retrieve an object that was previously persisted to the database using the given criteria.
+ *
+ * @param aCondition
+ * a search condition
+ * @return an object found according to the given criteria
+ */
+ @SuppressWarnings(UNCHECKED)
+ public T findByCriteria(final Criterion aCondition) {
+ return (T) getSession().createCriteria(getType()).add(aCondition)
+ .uniqueResult();
+ }
+
+ /**
+ * Retrieve an object that was previously persisted to the database using the given criteria.
+ *
+ * @param andParams
+ * a properties values to filter with AND condition
+ * @return an object found according to the given criteria
+ */
+ public T findByCriteria(final Properties andParams) {
+ Criterion aCondition = null;
+ for (String aName: andParams.stringPropertyNames()) {
+ aCondition = Restrictions.and(aCondition, Restrictions.eq(aName, andParams.get(aName)));
+ }
+ return findByCriteria(aCondition);
+ }
+
+ /**
+ * Retrieve a list of all objects of the considered type T which were previously persisted to the database.
+ *
+ * @return a list of all objects of the considered type T
+ */
+ @SuppressWarnings(UNCHECKED)
+ public List<T> getAll() {
+ return getSession().createCriteria(getType()).list();
+ }
+
+ /**
+ * Retrieve an ordered list of all objects of the considered type T which were previously persisted to the database.
+ *
+ * @param anOrder
+ * a result list order. Null is ignored and in such case the result list is unordered.
+ * @return an ordered list of all objects of the considered type T
+ */
+ @SuppressWarnings(UNCHECKED)
+ public List<T> getAll(final Order ... anOrder) {
+ Criteria aCriteria = getSession().createCriteria(getType());
+ for (Order order : anOrder) {
+ if (anOrder != null) {
+ aCriteria.addOrder(order);
+ }
+ }
+ return aCriteria.list();
+ }
+
+ /**
+ * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+ *
+ * @param aCondition
+ * a search condition
+ * @return a list of objects filtered according to the given criteria
+ */
+ @SuppressWarnings(UNCHECKED)
+ public List<T> getFilteredList(final Criterion aCondition) {
+ return getSession().createCriteria(getType()).add(aCondition).list();
+ }
+
+ /**
+ * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+ *
+ * @param aCondition
+ * a search condition
+ * @param anOrder
+ * a result list order. Null is ignored and in such case the result list is unordered.
+ * @return a list of objects filtered according to the given criteria
+ */
+ @SuppressWarnings(UNCHECKED)
+ public List<T> getFilteredList(final Criterion aCondition, final Order ... anOrder) {
+ Criteria aCriteria = getSession().createCriteria(getType()).add(
+ aCondition);
+ for (Order order : anOrder) {
+ if (anOrder != null) {
+ aCriteria.addOrder(order);
+ }
+ }
+ return aCriteria.list();
+ }
+
+ /**
+ * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+ *
+ * @param andParams
+ * a properties values to filter with AND condition
+ * @return a list of objects filtered according to the given criteria
+ */
+ public List<T> getFilteredList(final Properties andParams) {
+ return getFilteredList(andParams);
+ }
+
+ /**
+ * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+ *
+ * @param andParams
+ * a properties values to filter with AND condition
+ * @param anOrder
+ * a result list order. Null is ignored and in such case the result list is unordered.
+ * @return a list of objects filtered according to the given criteria
+ */
+ public List<T> getFilteredList(final Properties andParams, final Order ... anOrder) {
+ Criterion aCondition = null;
+ for (String aName: andParams.stringPropertyNames()) {
+ aCondition = Restrictions.and(aCondition, Restrictions.eq(aName, andParams.get(aName)));
+ }
+ return getFilteredList(aCondition, anOrder);
+ }
+
+ /**
+ * Save changes made to a persistent object.
+ *
+ * @param transientObject
+ * transient instance of the object to update
+ */
+ public void update(final T transientObject) {
+ getSession().update(transientObject);
+ }
+
+ /**
+ * Remove an object from persistent storage in the database.
+ *
+ * @param persistentObject
+ * a persistent object to delete from the database
+ */
+ public void delete(final T persistentObject) {
+ getSession().delete(persistentObject);
+ }
+
+ /**
+ * Makes detached object persistent.
+ *
+ * @param transientObject
+ * transient instance of the object to be made persistent
+ */
+ public void persist(final T transientObject) {
+ getSession().persist(transientObject);
+ }
+
+ /**
+ * Merge detached object with persistent data.
+ *
+ * @param transientObject
+ * transient instance of the object to be merged with persistent data
+ * @return merged persistent object
+ */
+ @SuppressWarnings(UNCHECKED)
+ public T merge(final T transientObject) {
+ return (T) getSession().merge(transientObject);
+ }
+
+ /**
+ * Synchronize the session data with the database.
+ */
+ public void flush() {
+ getSession().flush();
+ }
+
+ /**
+ * Get persistent object type.
+ *
+ * @return Persistent object class to be processed by this DAO
+ */
+ abstract protected Class<T> getType();
+}
\ No newline at end of file
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
import org.splat.dal.bo.kernel.Any;
-import org.splat.dal.dao.kernel.GenericDAO;
/**
* Any DAO class implementation.
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
import org.splat.dal.bo.kernel.Any;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
/**
* Any DAO.
*
*/
public class AnyDAOImpl extends
- GenericDAOImpl<Any, Long> implements AnyDAO {
+ AbstractGenericDAOImpl<Any, Long> implements AnyDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<Any> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
import org.splat.dal.bo.kernel.Attribute;
-import org.splat.dal.dao.kernel.GenericDAO;
/**
* Attribute DAO class implementation.
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
import org.splat.dal.bo.kernel.Attribute;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
/**
* Attribute DAO.
*
*/
public class AttributeDAOImpl extends
- GenericDAOImpl<Attribute, Long> implements AttributeDAO {
+ AbstractGenericDAOImpl<Attribute, Long> implements AttributeDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<Attribute> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
import org.splat.dal.bo.kernel.Entity;
-import org.splat.dal.dao.kernel.GenericDAO;
/**
* Entity DAO class implementation.
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
import org.splat.dal.bo.kernel.Entity;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
/**
* Entity DAO.
*
*/
public class EntityDAOImpl extends
- GenericDAOImpl<Entity, Long> implements EntityDAO {
+ AbstractGenericDAOImpl<Entity, Long> implements EntityDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<Entity> getType() {
+++ /dev/null
-/*****************************************************************************
- * Company OPEN CASCADE
- * Application SIMAN
- * File $Id$
- * Creation date 08.10.2012
- * @author $Author$
- * @version $Revision$
- *****************************************************************************/
-
-package org.splat.dal.dao.kernel;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Properties;
-
-import org.hibernate.Criteria;
-import org.hibernate.criterion.Criterion;
-import org.hibernate.criterion.Order;
-import org.hibernate.criterion.Restrictions;
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
-
-/**
- * Generic DAO implementation.
- *
- * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
- *
- * @param <T>
- * Persistent object class
- * @param <PK>
- * Primary key class
- */
-public abstract class GenericDAOImpl<T, PK extends Serializable> extends
- HibernateDaoSupport implements GenericDAO<T, PK> {
- /**
- * Persist the newInstance object into database.
- *
- * @param newInstance
- * new object as a transient instance
- * @return new primary key for the created persistent object
- */
- @SuppressWarnings("unchecked")
- public PK create(T newInstance) {
- return (PK) getSession().save(newInstance);
- }
-
- /**
- * Retrieve an object that was previously persisted to the database using the indicated id as primary key.
- *
- * @param id
- * primary key of an object to read
- * @return an object found by the given key
- */
- @SuppressWarnings("unchecked")
- public T get(PK id) {
- return (T) getSession().get(getType(), id);
- }
-
- /**
- * Retrieve an object that was previously persisted to the database using the given criteria.
- *
- * @param aCondition
- * a search condition
- * @return an object found according to the given criteria
- */
- @SuppressWarnings("unchecked")
- public T findByCriteria(Criterion aCondition) {
- return (T) getSession().createCriteria(getType()).add(aCondition)
- .uniqueResult();
- }
-
- /**
- * Retrieve an object that was previously persisted to the database using the given criteria.
- *
- * @param andParams
- * a properties values to filter with AND condition
- * @return an object found according to the given criteria
- */
- public T findByCriteria(Properties andParams) {
- Criterion aCondition = null;
- for (String aName: andParams.stringPropertyNames()) {
- aCondition = Restrictions.and(aCondition, Restrictions.eq(aName, andParams.get(aName)));
- }
- return findByCriteria(aCondition);
- }
-
- /**
- * Retrieve a list of all objects of the considered type T which were previously persisted to the database.
- *
- * @return a list of all objects of the considered type T
- */
- @SuppressWarnings("unchecked")
- public List<T> getAll() {
- return getSession().createCriteria(getType()).list();
- }
-
- /**
- * Retrieve an ordered list of all objects of the considered type T which were previously persisted to the database.
- *
- * @param anOrder
- * a result list order. Null is ignored and in such case the result list is unordered.
- * @return an ordered list of all objects of the considered type T
- */
- @SuppressWarnings("unchecked")
- public List<T> getAll(Order ... anOrder) {
- Criteria aCriteria = getSession().createCriteria(getType());
- for (Order order : anOrder) {
- if (anOrder != null) {
- aCriteria.addOrder(order);
- }
- }
- return aCriteria.list();
- }
-
- /**
- * Retrieve a list of objects which were previously persisted to the database using the given criteria.
- *
- * @param aCondition
- * a search condition
- * @return a list of objects filtered according to the given criteria
- */
- @SuppressWarnings("unchecked")
- public List<T> getFilteredList(Criterion aCondition) {
- return getSession().createCriteria(getType()).add(aCondition).list();
- }
-
- /**
- * Retrieve a list of objects which were previously persisted to the database using the given criteria.
- *
- * @param aCondition
- * a search condition
- * @param anOrder
- * a result list order. Null is ignored and in such case the result list is unordered.
- * @return a list of objects filtered according to the given criteria
- */
- @SuppressWarnings("unchecked")
- public List<T> getFilteredList(Criterion aCondition, Order ... anOrder) {
- Criteria aCriteria = getSession().createCriteria(getType()).add(
- aCondition);
- for (Order order : anOrder) {
- if (anOrder != null) {
- aCriteria.addOrder(order);
- }
- }
- return aCriteria.list();
- }
-
- /**
- * Retrieve a list of objects which were previously persisted to the database using the given criteria.
- *
- * @param andParams
- * a properties values to filter with AND condition
- * @return a list of objects filtered according to the given criteria
- */
- public List<T> getFilteredList(Properties andParams) {
- return getFilteredList(andParams);
- }
-
- /**
- * Retrieve a list of objects which were previously persisted to the database using the given criteria.
- *
- * @param andParams
- * a properties values to filter with AND condition
- * @param anOrder
- * a result list order. Null is ignored and in such case the result list is unordered.
- * @return a list of objects filtered according to the given criteria
- */
- public List<T> getFilteredList(Properties andParams, Order ... anOrder) {
- Criterion aCondition = null;
- for (String aName: andParams.stringPropertyNames()) {
- aCondition = Restrictions.and(aCondition, Restrictions.eq(aName, andParams.get(aName)));
- }
- return getFilteredList(aCondition, anOrder);
- }
-
- /**
- * Save changes made to a persistent object.
- *
- * @param transientObject
- * transient instance of the object to update
- */
- public void update(T transientObject) {
- getSession().update(transientObject);
- }
-
- /**
- * Remove an object from persistent storage in the database.
- *
- * @param persistentObject
- * a persistent object to delete from the database
- */
- public void delete(T persistentObject) {
- getSession().delete(persistentObject);
- }
-
- /**
- * Makes detached object persistent.
- *
- * @param transientObject
- * transient instance of the object to be made persistent
- */
- public void persist(T transientObject) {
- getSession().persist(transientObject);
- }
-
- /**
- * Merge detached object with persistent data.
- *
- * @param transientObject
- * transient instance of the object to be merged with persistent data
- * @return merged persistent object
- */
- @SuppressWarnings("unchecked")
- public T merge(T transientObject) {
- return (T) getSession().merge(transientObject);
- }
-
- /**
- * Synchronize the session data with the database.
- */
- public void flush() {
- getSession().flush();
- }
-
- /**
- * Get persistent object type.
- *
- * @return Persistent object class to be processed by this DAO
- */
- abstract protected Class<T> getType();
-}
\ No newline at end of file
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
import org.splat.dal.bo.kernel.Persistent;
-import org.splat.dal.dao.kernel.GenericDAO;
/**
* Persistent DAO class implementation.
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
import org.splat.dal.bo.kernel.Persistent;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
/**
* Persistent DAO.
*
*/
public class PersistentDAOImpl extends
- GenericDAOImpl<Persistent, Long> implements PersistentDAO {
+ AbstractGenericDAOImpl<Persistent, Long> implements PersistentDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<Persistent> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
import org.splat.dal.bo.kernel.Relation;
-import org.splat.dal.dao.kernel.GenericDAO;
/**
* Relation DAO class implementation.
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
import org.splat.dal.bo.kernel.Relation;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
/**
* Relation DAO.
*
*/
public class RelationDAOImpl extends
- GenericDAOImpl<Relation, Long> implements RelationDAO {
+ AbstractGenericDAOImpl<Relation, Long> implements RelationDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<Relation> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
import org.splat.dal.bo.kernel.Role;
-import org.splat.dal.dao.kernel.GenericDAO;
/**
* Role DAO class implementation.
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
import org.splat.dal.bo.kernel.Role;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
/**
* Role DAO.
*
*/
public class RoleDAOImpl extends
- GenericDAOImpl<Role, Long> implements RoleDAO {
+ AbstractGenericDAOImpl<Role, Long> implements RoleDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<Role> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
import org.splat.dal.bo.kernel.TextAttribute;
-import org.splat.dal.dao.kernel.GenericDAO;
/**
* TextAttribute DAO class implementation.
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
import org.splat.dal.bo.kernel.TextAttribute;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
/**
* TextAttribute DAO.
*
*/
public class TextAttributeDAOImpl extends
- GenericDAOImpl<TextAttribute, Long> implements TextAttributeDAO {
+ AbstractGenericDAOImpl<TextAttribute, Long> implements TextAttributeDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<TextAttribute> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.kernel.GenericDAO;
/**
* User DAO class implementation.
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
/**
* User DAO.
*
*/
public class UserDAOImpl extends
- GenericDAOImpl<User, Long> implements UserDAO {
+ AbstractGenericDAOImpl<User, Long> implements UserDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<User> getType() {
--- /dev/null
+/*****************************************************************************
+ * Company OPEN CASCADE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 06.10.2012
+ * @author $Author$
+ * @version $Revision$
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
+ *****************************************************************************/
+
+package org.splat.dal.dao.som;
+
+import org.splat.dal.bo.som.CommentAttribute;
+import org.splat.dal.dao.kernel.GenericDAO;
+
+/**
+ * CommentAttribute DAO class implementation.
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ *
+ */
+public interface CommentAttributeDAO extends GenericDAO<CommentAttribute, Long> {
+}
--- /dev/null
+/*****************************************************************************
+ * Company OPEN CASCADE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 06.10.2012
+ * @author $Author$
+ * @version $Revision$
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
+ *****************************************************************************/
+
+package org.splat.dal.dao.som;
+
+import org.splat.dal.bo.som.CommentAttribute;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
+
+/**
+ * CommentAttribute DAO.
+ * @author RKV
+ *
+ */
+public class CommentAttributeDAOImpl extends
+ AbstractGenericDAOImpl<CommentAttribute, Long> implements CommentAttributeDAO {
+
+ /**
+ * {@inheritDoc}
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
+ */
+ @Override
+ protected Class<CommentAttribute> getType() {
+ return CommentAttribute.class;
+ }
+
+}
\ No newline at end of file
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.ContributorRelation;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* ContributorRelation DAO.
*
*/
public class ContributorRelationDAOImpl extends
- GenericDAOImpl<ContributorRelation, Long> implements ContributorRelationDAO {
+ AbstractGenericDAOImpl<ContributorRelation, Long> implements ContributorRelationDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<ContributorRelation> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.ConvertsRelation;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* ConvertsRelation DAO.
*
*/
public class ConvertsRelationDAOImpl extends
- GenericDAOImpl<ConvertsRelation, Long> implements ConvertsRelationDAO {
+ AbstractGenericDAOImpl<ConvertsRelation, Long> implements ConvertsRelationDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<ConvertsRelation> getType() {
public class Database extends org.splat.dal.dao.kernel.AbstractDatabase {
- private int uplevel = 0; // Level of database upgrade
+ public final static Logger LOG = org.splat.dal.dao.som.Database.LOG;
+
+ private transient int _uplevel = 0; // Level of database upgrade
private RepositoryService _repositoryService;
private IndexService _indexService;
private UserService _userService;
protected class CheckVersion implements Work {
/**
* {@inheritDoc}
+ * @throws SQLException
* @see org.hibernate.jdbc.Work#execute(java.sql.Connection)
*/
public void execute(final Connection connex) throws SQLException {
DatabaseMetaData dbmdata = connex.getMetaData();
String dbname = connex.getCatalog();
- ResultSet table;
+ ResultSet table = null;
- table = dbmdata.getTables(dbname, null, "study", null);
- if (table.next()) {
- return;
+ try {
+ table = dbmdata.getTables(dbname, null, "study", null);
+ if (table.next()) {
+ return;
+ }
+ } catch (SQLException e) {
+ LOG.debug("Can't check the database version: ", e);
+ throw e;
+ } finally {
+ if (table != null) {
+ table.close();
+ }
}
- uplevel = -1; // Database not initialized
+ _uplevel = -1; // Database not initialized
}
}
- public final static Logger logger = org.splat.dal.dao.som.Database.logger;
-
// ==============================================================================================================================
// Construction
// ==============================================================================================================================
- private static Database myDB;
+ private static Database myDB = new Database();
public static Database getInstance() {
- if (myDB == null) {
- myDB = new Database();
- }
return myDB;
}
my = this;
my.checkVersion();
} catch (Exception error) {
- logger.fatal("Could not access the database, reason:", error);
+ LOG.fatal("Could not access the database, reason:", error);
}
}
return my;
// ==============================================================================================================================
public boolean isInitialized() {
- return (uplevel >= 0);
+ return (_uplevel >= 0);
}
public void initialize() throws IOException, SQLException {
- logger.info("Creation of the database.");
+ LOG.info("Creation of the database.");
// Creation of the Lucene index
getIndexService().create(); // May throw IOException if the index repository is improperly configured
// Population of the database with customized data
this.populate();
- uplevel = 0; // The database is now up-to-date
+ _uplevel = 0; // The database is now up-to-date
}
// ==============================================================================================================================
getUserService().createUser(uprop);
} catch (Exception e) {
// Let's continue, hoping the best...
+ LOG.debug(e.getMessage(), e);
}
}
--- /dev/null
+/*****************************************************************************
+ * Company OPEN CASCADE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 06.10.2012
+ * @author $Author$
+ * @version $Revision$
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
+ *****************************************************************************/
+
+package org.splat.dal.dao.som;
+
+import org.splat.dal.bo.som.DescriptionAttribute;
+import org.splat.dal.dao.kernel.GenericDAO;
+
+/**
+ * DescriptionAttribute DAO class implementation.
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ *
+ */
+public interface DescriptionAttributeDAO extends GenericDAO<DescriptionAttribute, Long> {
+}
--- /dev/null
+/*****************************************************************************
+ * Company OPEN CASCADE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 06.10.2012
+ * @author $Author$
+ * @version $Revision$
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
+ *****************************************************************************/
+
+package org.splat.dal.dao.som;
+
+import org.splat.dal.bo.som.DescriptionAttribute;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
+
+/**
+ * DescriptionAttribute DAO.
+ * @author RKV
+ *
+ */
+public class DescriptionAttributeDAOImpl extends
+ AbstractGenericDAOImpl<DescriptionAttribute, Long> implements DescriptionAttributeDAO {
+
+ /**
+ * {@inheritDoc}
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
+ */
+ @Override
+ protected Class<DescriptionAttribute> getType() {
+ return DescriptionAttribute.class;
+ }
+
+}
\ No newline at end of file
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.Document;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* Document DAO.
*
*/
public class DocumentDAOImpl extends
- GenericDAOImpl<Document, Long> implements DocumentDAO {
+ AbstractGenericDAOImpl<Document, Long> implements DocumentDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<Document> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.DocumentType;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* DocumentType DAO.
*
*/
public class DocumentTypeDAOImpl extends
- GenericDAOImpl<DocumentType, Long> implements DocumentTypeDAO {
+ AbstractGenericDAOImpl<DocumentType, Long> implements DocumentTypeDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<DocumentType> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.File;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* File DAO.
*
*/
public class FileDAOImpl extends
- GenericDAOImpl<File, Long> implements FileDAO {
+ AbstractGenericDAOImpl<File, Long> implements FileDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<File> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.IDBuilder;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* IDBuilder DAO.
*
*/
public class IDBuilderDAOImpl extends
- GenericDAOImpl<IDBuilder, Long> implements IDBuilderDAO {
+ AbstractGenericDAOImpl<IDBuilder, Long> implements IDBuilderDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<IDBuilder> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.KnowledgeElement;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* KnowledgeElement DAO.
*
*/
public class KnowledgeElementDAOImpl extends
- GenericDAOImpl<KnowledgeElement, Long> implements KnowledgeElementDAO {
+ AbstractGenericDAOImpl<KnowledgeElement, Long> implements KnowledgeElementDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<KnowledgeElement> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.KnowledgeElementType;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* KnowledgeElementType DAO.
*
*/
public class KnowledgeElementTypeDAOImpl extends
- GenericDAOImpl<KnowledgeElementType, Long> implements KnowledgeElementTypeDAO {
+ AbstractGenericDAOImpl<KnowledgeElementType, Long> implements KnowledgeElementTypeDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<KnowledgeElementType> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.ProjectElement;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* ProjectElement DAO.
*
*/
public class ProjectElementDAOImpl extends
- GenericDAOImpl<ProjectElement, Long> implements ProjectElementDAO {
+ AbstractGenericDAOImpl<ProjectElement, Long> implements ProjectElementDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<ProjectElement> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.Publication;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* Publication DAO.
*
*/
public class PublicationDAOImpl extends
- GenericDAOImpl<Publication, Long> implements PublicationDAO {
+ AbstractGenericDAOImpl<Publication, Long> implements PublicationDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<Publication> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.Scenario;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* Scenario DAO.
*
*/
public class ScenarioDAOImpl extends
- GenericDAOImpl<Scenario, Long> implements ScenarioDAO {
+ AbstractGenericDAOImpl<Scenario, Long> implements ScenarioDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<Scenario> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.SimulationContext;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* SimulationContext DAO.
*
*/
public class SimulationContextDAOImpl extends
- GenericDAOImpl<SimulationContext, Long> implements SimulationContextDAO {
+ AbstractGenericDAOImpl<SimulationContext, Long> implements SimulationContextDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<SimulationContext> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.SimulationContextType;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* SimulationContextType DAO.
*
*/
public class SimulationContextTypeDAOImpl extends
- GenericDAOImpl<SimulationContextType, Long> implements SimulationContextTypeDAO {
+ AbstractGenericDAOImpl<SimulationContextType, Long> implements SimulationContextTypeDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<SimulationContextType> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.StampRelation;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* StampRelation DAO.
*
*/
public class StampRelationDAOImpl extends
- GenericDAOImpl<StampRelation, Long> implements StampRelationDAO {
+ AbstractGenericDAOImpl<StampRelation, Long> implements StampRelationDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<StampRelation> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.Study;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* Study DAO.
*
*/
public class StudyDAOImpl extends
- GenericDAOImpl<Study, Long> implements StudyDAO {
+ AbstractGenericDAOImpl<Study, Long> implements StudyDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<Study> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.Timestamp;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* Timestamp DAO.
*
*/
public class TimestampDAOImpl extends
- GenericDAOImpl<Timestamp, Long> implements TimestampDAO {
+ AbstractGenericDAOImpl<Timestamp, Long> implements TimestampDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<Timestamp> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.UsedByRelation;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* UsedByRelation DAO.
*
*/
public class UsedByRelationDAOImpl extends
- GenericDAOImpl<UsedByRelation, Long> implements UsedByRelationDAO {
+ AbstractGenericDAOImpl<UsedByRelation, Long> implements UsedByRelationDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<UsedByRelation> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.UsesRelation;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* UsesRelation DAO.
*
*/
public class UsesRelationDAOImpl extends
- GenericDAOImpl<UsesRelation, Long> implements UsesRelationDAO {
+ AbstractGenericDAOImpl<UsesRelation, Long> implements UsesRelationDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<UsesRelation> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.ValidationCycle;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* ValidationCycle DAO.
*
*/
public class ValidationCycleDAOImpl extends
- GenericDAOImpl<ValidationCycle, Long> implements ValidationCycleDAO {
+ AbstractGenericDAOImpl<ValidationCycle, Long> implements ValidationCycleDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<ValidationCycle> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.ValidationCycleRelation;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* ValidationCycleRelation DAO.
*
*/
public class ValidationCycleRelationDAOImpl extends
- GenericDAOImpl<ValidationCycleRelation, Long> implements ValidationCycleRelationDAO {
+ AbstractGenericDAOImpl<ValidationCycleRelation, Long> implements ValidationCycleRelationDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<ValidationCycleRelation> getType() {
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.splat.dal.bo.som.VersionsRelation;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
/**
* VersionsRelation DAO.
*
*/
public class VersionsRelationDAOImpl extends
- GenericDAOImpl<VersionsRelation, Long> implements VersionsRelationDAO {
+ AbstractGenericDAOImpl<VersionsRelation, Long> implements VersionsRelationDAO {
/**
* {@inheritDoc}
- * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+ * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
*/
@Override
protected Class<VersionsRelation> getType() {
public class Do {
- public static boolean containsIllicitCharacter (String name) {
+ public static boolean containsIllicitCharacter (final String name) {
// ------------------------------------------------------------
char parse[] = name.toCharArray();
for (int i=0; i<parse.length; i++) {
int k = java.lang.Character.getType(parse[i]);
- if (k == java.lang.Character.DECIMAL_DIGIT_NUMBER) continue;
- if (k == java.lang.Character.LOWERCASE_LETTER) continue;
- if (k == java.lang.Character.UPPERCASE_LETTER) continue;
- if (k == java.lang.Character.SPACE_SEPARATOR) continue;
- if (k == java.lang.Character.END_PUNCTUATION) continue;
- if (k == java.lang.Character.DASH_PUNCTUATION) continue;
- if (parse[i] == '\'') continue;
- if (parse[i] == '_') continue;
- if (parse[i] == '&') continue;
- if (parse[i] == '.') continue;
+ if (k == java.lang.Character.DECIMAL_DIGIT_NUMBER) {
+ continue;
+ }
+ if (k == java.lang.Character.LOWERCASE_LETTER) {
+ continue;
+ }
+ if (k == java.lang.Character.UPPERCASE_LETTER) {
+ continue;
+ }
+ if (k == java.lang.Character.SPACE_SEPARATOR) {
+ continue;
+ }
+ if (k == java.lang.Character.END_PUNCTUATION) {
+ continue;
+ }
+ if (k == java.lang.Character.DASH_PUNCTUATION) {
+ continue;
+ }
+ if (parse[i] == '\'') {
+ continue;
+ }
+ if (parse[i] == '_') {
+ continue;
+ }
+ if (parse[i] == '&') {
+ continue;
+ }
+ if (parse[i] == '.') {
+ continue;
+ }
return true;
}
return false;
}
- public static void copy (File fromFile, File toFile) throws IOException {
+ public static void copy (final File fromFile, File toFile) throws IOException {
// ----------------------------------------------------
- if (!fromFile.exists()) throw new IOException("ERROR File copy: no such '" + fromFile.getName() + "' source file.");
- if (!fromFile.isFile()) throw new IOException("Error File copy: can't copy directory '" + fromFile.getName() + "'.");
+ if (!fromFile.exists()) {
+ throw new IOException("ERROR File copy: no such '" + fromFile.getName() + "' source file.");
+ }
+ if (!fromFile.isFile()) {
+ throw new IOException("Error File copy: can't copy directory '" + fromFile.getName() + "'.");
+ }
- if (toFile.isDirectory()) toFile = new File(toFile, fromFile.getName());
- if (toFile.exists()) throw new IOException("ERROR File copy: file " + toFile.getName() + " already exist.");
- else {
+ if (toFile.isDirectory()) {
+ toFile = new File(toFile, fromFile.getName());
+ }
+ if (toFile.exists()) {
+ throw new IOException("ERROR File copy: file " + toFile.getName() + " already exist.");
+ } else {
String parent = toFile.getParent();
- if (parent == null) throw new IOException("ERROR File copy: destination directory not defined.");
+ if (parent == null) {
+ throw new IOException("ERROR File copy: destination directory not defined.");
+ }
File dir = new File(parent);
- if (!dir.exists()) throw new IOException("ERROR File copy: destination directory " + parent + " doesn't exist.");
+ if (!dir.exists()) {
+ throw new IOException("ERROR File copy: destination directory " + parent + " doesn't exist.");
+ }
}
FileInputStream from = null;
FileOutputStream to = null;
from = new FileInputStream(fromFile);
to = new FileOutputStream(toFile);
byte[] buffer = new byte[4096];
- int bytesRead;
+ int bytesRead = from.read(buffer);
- while ((bytesRead = from.read(buffer)) != -1) to.write(buffer, 0, bytesRead); // write
+ while (bytesRead != -1) {
+ to.write(buffer, 0, bytesRead); // write
+ bytesRead = from.read(buffer);
+ }
from.close();
to.close();
}
catch (IOException e) {
- throw new IOException();
+ throw e;
+ }
+ finally {
+ if (from != null) {
+ from.close();
+ }
+ if (to != null) {
+ to.close();
+ }
}
}
- public static boolean sendMail (User to, String subject, String message, File attachement, Properties mprop) {
+ public static boolean sendMail (final User to, final String subject, final String message, final File attachement, final Properties mprop) {
// ------------------------------------------------------------------------------------------------------------
- if (mprop.getProperty("mail.smtp.host") == null) return false;
- if (mprop.getProperty("mail.pop3.host") == null) return false;
- if (mprop.getProperty("mail.from") == null) return false;
+ if (mprop.getProperty("mail.smtp.host") == null) {
+ return false;
+ }
+ if (mprop.getProperty("mail.pop3.host") == null) {
+ return false;
+ }
+ if (mprop.getProperty("mail.from") == null) {
+ return false;
+ }
Session mail = Session.getInstance(mprop, null);
Logger log = Logger.getLogger(Do.class);
package org.splat.kernel;
+
/**
*
- * @author Daniel Brunier-Coulin
+ * @author Daniel Brunier-Coulin
* @copyright OPEN CASCADE 2012
*/
public class MismatchException extends Exception {
- private static final long serialVersionUID = 366699682058153984L;
+ private static final long serialVersionUID = 366699682058153984L;
+
+ public MismatchException() {
+ super();
+ }
- public MismatchException () {
- }
- public MismatchException (String message) {
- super(message);
- }
+ public MismatchException(final String message) {
+ super(message);
+ }
}
\ No newline at end of file
package org.splat.kernel;
+
/**
*
- * @author Daniel Brunier-Coulin
+ * @author Daniel Brunier-Coulin
* @copyright OPEN CASCADE 2012
*/
private static final long serialVersionUID = 3551033092059904168L;
- public MultiplyDefinedException () {
- }
- public MultiplyDefinedException (String message) {
- super(message);
- }
+ public MultiplyDefinedException() {
+ super();
+ }
+
+ public MultiplyDefinedException(final String message) {
+ super(message);
+ }
}
\ No newline at end of file
package org.splat.kernel;
+
/**
*
* @author Daniel Brunier-Coulin
import java.util.Date;
import java.util.Map;
-import javax.security.auth.*;
-import javax.security.auth.callback.*;
-import javax.security.auth.login.*;
-import javax.security.auth.spi.*;
+import javax.security.auth.Subject;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.FailedLoginException;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.spi.LoginModule;
import org.apache.log4j.Logger;
import org.splat.dal.bo.kernel.User;
import org.splat.service.ServiceLocatorImpl;
-
public class RealmLoginModule implements LoginModule {
-
-// Initial state
- private Subject subject;
- private CallbackHandler callbackHandler;
-// private Map sharedState;
-// private Map options;
-
-// Authentication status
- private boolean succeeded = false;
- private boolean commit = false;
-
-// Principal
- private User identity = null;
-
- private Logger logger = null;
-
-// ==============================================================================================================================
-// Constructor
-// ==============================================================================================================================
-
- public void initialize(Subject user, CallbackHandler handler, Map<String, ?> state, Map<String, ?> opts) {
-// --------------------------------------------------------------------------------------------------------
- subject = user;
- callbackHandler = handler;
-// sharedState = state;
-// options = opts;
-// debug = "true".equalsIgnoreCase((String)options.get("debug"));
- logger = Logger.getLogger(RealmLoginModule.class);
- }
-
-// ==============================================================================================================================
-// Public services
-// ==============================================================================================================================
+
+ // Initial state
+ private transient Subject _subject;
+ private transient CallbackHandler _callbackHandler;
+ // private Map sharedState;
+ // private Map options;
+
+ // Authentication status
+ private transient boolean _succeeded = false;
+ private transient boolean _commit = false;
+
+ // Principal
+ private transient User _identity = null;
+
+ private static final Logger LOG = Logger.getLogger(RealmLoginModule.class);
+
+ // ==============================================================================================================================
+ // Constructor
+ // ==============================================================================================================================
+
+ public void initialize(final Subject user, final CallbackHandler handler,
+ final Map<String, ?> state, final Map<String, ?> opts) {
+ // --------------------------------------------------------------------------------------------------------
+ _subject = user;
+ _callbackHandler = handler;
+ // sharedState = state;
+ // options = opts;
+ // debug = "true".equalsIgnoreCase((String)options.get("debug"));
+ //_logger = Logger.getLogger(RealmLoginModule.class);
+ }
+
+ // ==============================================================================================================================
+ // Public services
+ // ==============================================================================================================================
public boolean login() throws LoginException {
-// ----------------------
- try {
-// Ask for username password
- Callback[] callbacks = new Callback[2];
- callbacks[0] = new NameCallback("username");
- callbacks[1] = new PasswordCallback("password", false);
-
- callbackHandler.handle(callbacks);
-
- String username = ((NameCallback)callbacks[0]).getName();
- String password = null;
- char[] entered = ((PasswordCallback)callbacks[1]).getPassword();
- if (entered != null) {
- password = new String(entered);
- ((PasswordCallback)callbacks[1]).clearPassword();
- }
-
-// Authentication
- User found = ServiceLocatorImpl.getInstance().getUserService().selectUser(username, password);
- if (found != null) {
- identity = found;
- succeeded = true;
- Calendar today = java.util.Calendar.getInstance();
- Date datime = today.getTime();
- logger.info("Connection of " + identity.toString() + " " + datime.toString() + ".");
- return true;
- } else {
- identity = null;
- succeeded = false;
- found = ServiceLocatorImpl.getInstance().getUserService().selectUser(username);
- String reason = "password";
- if (found == null) reason = "username";
- logger.info("Connection attempt as " + username + ".");
- throw new FailedLoginException(reason);
- }
- }
- catch (java.io.IOException ioe) {
- throw new LoginException(ioe.toString());
- }
- catch (UnsupportedCallbackException uce) {
- throw new LoginException("Error: " + uce.getCallback().toString() +
- " not available to garner authentication information" +
- " from the user");
- }
+ boolean res = false;
+ try {
+ // Ask for username password
+ Callback[] callbacks = new Callback[2];
+ callbacks[0] = new NameCallback("username");
+ callbacks[1] = new PasswordCallback("password", false);
+
+ _callbackHandler.handle(callbacks);
+
+ String username = ((NameCallback) callbacks[0]).getName();
+ String password = null;
+ char[] entered = ((PasswordCallback) callbacks[1]).getPassword();
+ if (entered != null) {
+ password = new String(entered);
+ ((PasswordCallback) callbacks[1]).clearPassword();
+ }
+
+ // Authentication
+ User found = ServiceLocatorImpl.getInstance().getUserService()
+ .selectUser(username, password);
+ _identity = found;
+ _succeeded = (found != null);
+ if (_succeeded) {
+ Calendar today = java.util.Calendar.getInstance();
+ Date datime = today.getTime();
+ LOG.info("Connection of " + _identity.toString() + " "
+ + datime.toString() + ".");
+ res = true;
+ } else {
+ found = ServiceLocatorImpl.getInstance().getUserService()
+ .selectUser(username);
+ String reason = "password";
+ if (found == null) {
+ reason = "username";
+ }
+ LOG.info("Connection attempt as " + username + ".");
+ throw new FailedLoginException(reason);
+ }
+ } catch (java.io.IOException ioe) {
+ throw new LoginException(ioe.getMessage()); // RKV: NOPMD: The message is sent into the constructor
+ } catch (UnsupportedCallbackException uce) {
+ throw new LoginException("Error: " + uce.getCallback().toString() // RKV: NOPMD: Stacktrace is printed
+ + " not available to garner authentication information"
+ + " from the user");
+ }
+ return res;
}
public boolean commit() throws LoginException {
-// -----------------------
- if (!succeeded) return false;
-
- if (!subject.getPrincipals().contains(identity)) subject.getPrincipals().add(identity);
- identity = null;
- commit = true;
- return true;
+ boolean res = _succeeded;
+ if (res) {
+ if (!_subject.getPrincipals().contains(_identity)) {
+ _subject.getPrincipals().add(_identity);
+ }
+ _identity = null;
+ _commit = true;
+ }
+ return res;
}
public boolean abort() throws LoginException {
-// ----------------------
- if (!succeeded) {
- return false;
- } else
- if (succeeded && !commit) {
- identity = null;
- succeeded = false;
- } else {
- logout();
- }
- return true;
+ boolean res = _succeeded;
+ if (res) {
+ if (_succeeded && !_commit) {
+ _identity = null;
+ _succeeded = false;
+ } else {
+ logout();
+ }
+ }
+ return res;
}
public boolean logout() throws LoginException {
-// -----------------------
- subject.getPrincipals().remove(identity);
- identity = null;
- succeeded = false;
- commit = false; // To be validated
- return true;
+ _subject.getPrincipals().remove(_identity);
+ _identity = null;
+ _succeeded = false;
+ _commit = false; // To be validated
+ return true;
}
}
\ No newline at end of file
package org.splat.service;
-import java.util.List;
-
import org.splat.dal.bo.som.ConvertsRelation;
import org.splat.dal.bo.som.Document;
import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.Document.Properties;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
-import org.splat.kernel.MultiplyDefinedException;
import org.splat.kernel.NotApplicableException;
-import org.splat.service.technical.ProjectSettingsService;
import org.splat.som.Revision;
import org.splat.som.Step;
-import org.springframework.transaction.annotation.Transactional;
/**
* Document service interface.
* the document path
* @return the document if found or null
*/
- public Document getDocumentByPath(String path);
+ Document getDocumentByPath(String path);
/**
* Defines this document.
* @see Step#createDocument(Properties)
* @see #isUndefined()
*/
- public void initialize(Document aDoc, Properties dprop)
+ void initialize(Document aDoc, Properties dprop)
throws MissedPropertyException, InvalidPropertyException,
NotApplicableException;
* document id
* @return found document
*/
- public Document selectDocument(long index);
+ Document selectDocument(long index);
/**
* Find a document by its reference and version.
* document version
* @return found document
*/
- public Document selectDocument(String refid, String version);
+ Document selectDocument(String refid, String version);
/**
* Generate document reference.
* @param dprop
* document properties (owner project element is used)
*/
- public void generateDocumentId(Document aDoc, Properties dprop);
+ void generateDocumentId(Document aDoc, Properties dprop);
/**
* Get a directory where the document file is saved.
* the document
* @return a directory
*/
- public java.io.File getSaveDirectory(Document aDoc);
+ java.io.File getSaveDirectory(Document aDoc);
/**
* Extract title and reference properties from the given file.
* the file to parse
* @return the extracted properties
*/
- public Properties extractProperties(java.io.File file);
+ Properties extractProperties(java.io.File file);
/**
* Create "Converts" relation for the given document and the given format.
* the format
* @return the created "Converts" relation
*/
- public ConvertsRelation attach(Document aDoc, String format);
+ ConvertsRelation attach(Document aDoc, String format);
/**
* Create "Converts" relation for the given document, format and description.
* the description of the relation
* @return the created "Converts" relation
*/
- public ConvertsRelation attach(Document aDoc, String format,
+ ConvertsRelation attach(Document aDoc, String format,
String description);
/**
* the original document
* @return true if the new reference is set
*/
- public boolean buildReferenceFrom(Document aDoc, ProjectElement scope,
+ boolean buildReferenceFrom(Document aDoc, ProjectElement scope,
Document lineage);
/**
* the study
* @return true if the new reference is set
*/
- public boolean buildReferenceFrom(Document aDoc, Study scope);
+ boolean buildReferenceFrom(Document aDoc, Study scope);
/**
* Demote a document.
* the document to demote
* @return true if demoting succeeded
*/
- public boolean demote(Document aDoc);
+ boolean demote(Document aDoc);
/**
* Promote a document.
* the timestamp of the promotion
* @return true if promotion succeeded
*/
- public boolean promote(Document aDoc, Timestamp stamp);
+ boolean promote(Document aDoc, Timestamp stamp);
/**
* Increments the reference count of this document following its publication in a Study step.
* the document to hold
* @see #release()
*/
- public void hold(Document aDoc);
+ void hold(Document aDoc);
/**
* Decrements the reference count of this document following the removal of a Publication from a Study step.
* the document to release
* @see #hold()
*/
- public void release(Document aDoc);
+ void release(Document aDoc);
/**
* Rename a document.
* @throws InvalidPropertyException
* if the new title is empty
*/
- public void rename(Document aDoc, String title)
+ void rename(Document aDoc, String title)
throws InvalidPropertyException;
/**
* @param newvers
* the new version
*/
- public void updateAs(Document aDoc, Revision newvers);
+ void updateAs(Document aDoc, Revision newvers);
/**
* Update a state of the given document.
* @param state
* the new state
*/
- public void updateAs(Document aDoc, ProgressState state);
+ void updateAs(Document aDoc, ProgressState state);
/**
* Checks if documents of this type are result of a study. A document is the result of a study when it is the result of the last step of
* @see #isStepResult()
* @see #isResultOf(org.splat.service.technical.ProjectSettingsServiceImpl.Step)
*/
- public boolean isStudyResult(DocumentType aType);
+ boolean isStudyResult(DocumentType aType);
}
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.NotApplicableException;
+import org.splat.log.AppLogger;
import org.splat.manox.Reader;
import org.splat.manox.Toolbox;
import org.splat.service.technical.ProjectSettingsService;
*/
public class DocumentServiceImpl implements DocumentService {
+ /**
+ * The logger for the service.
+ */
+ public final static AppLogger LOG = AppLogger
+ .getLogger(DocumentServiceImpl.class);
+
/**
* Injected study service.
*/
/**
* Injected project settings service.
*/
- private ProjectSettingsService _projectSettingsService;
+ private ProjectSettingsService _projectSettings;
/**
* Injected repository service.
*/
// Synchronize the object with the current Hibernate session.
owner = getStudyDAO().get(owner.getIndex());
- SimpleDateFormat tostring = new SimpleDateFormat("yyyy");
+ SimpleDateFormat tostring = new SimpleDateFormat("yyyy"); //RKV: NOPMD: TODO: Use locale here?
String year = tostring.format(owner.getDate());
String filename = generateEncodedName(aDoc, owner);
String path = owner.getReference();
fprop.setReference(value);
}
} catch (Exception e) {
+ LOG.debug(e.getMessage(), e);
}
}
return fprop;
* the original document
* @return true if the new reference is set
*/
- public boolean buildReferenceFrom(final Document aDoc, final ProjectElement scope,
- final Document lineage) {
+ public boolean buildReferenceFrom(final Document aDoc,
+ final ProjectElement scope, final Document lineage) {
if (aDoc.getProgressState() != ProgressState.inWORK) {
return false;
}
* @return Project settings service
*/
private ProjectSettingsService getProjectSettings() {
- return _projectSettingsService;
+ return _projectSettings;
}
/**
* @param projectSettingsService
* project settings service
*/
- public void setProjectSettings(final ProjectSettingsService projectSettingsService) {
- _projectSettingsService = projectSettingsService;
+ public void setProjectSettings(
+ final ProjectSettingsService projectSettingsService) {
+ _projectSettings = projectSettingsService;
}
/**
*
* @return the list of all document types
*/
- public List<DocumentType> selectAllTypes();
+ List<DocumentType> selectAllTypes();
/**
* Find all result document types.
*
* @return the list of found types
*/
- public List<DocumentType> selectResultTypes();
+ List<DocumentType> selectResultTypes();
/**
* Get document type by the given type name.
* the type name
* @return the found document type
*/
- public DocumentType selectType(String name);
+ DocumentType selectType(String name);
/**
* Get document type by the given id.
* the id
* @return the found document type
*/
- public DocumentType selectType(long index);
+ DocumentType selectType(long index);
/**
* Create a new document type.
* @throws MultiplyDefinedException
* if some property is defined several times
*/
- public DocumentType createType(DocumentType.Properties tprop)
+ DocumentType createType(DocumentType.Properties tprop)
throws MissedPropertyException, InvalidPropertyException,
MultiplyDefinedException;
* the step (study activity)
* @return the list of found document types
*/
- public List<DocumentType> selectTypesOf(ProjectSettingsService.Step step);
+ List<DocumentType> selectTypesOf(ProjectSettingsService.Step step);
/**
* Approve the document type.
* the document type to approve
* @return true if approval succeeded
*/
- public boolean approve(DocumentType aType);
+ boolean approve(DocumentType aType);
}
import org.hibernate.criterion.Restrictions;
import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.ProgressState;
-import org.splat.dal.dao.som.Database;
import org.splat.dal.dao.som.DocumentTypeDAO;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
* @return the found document type
*/
@Transactional(readOnly = true)
- public DocumentType selectType(String name) {
+ public DocumentType selectType(final String name) {
return getDocumentTypeDAO().findByCriteria(
Restrictions.eq("name", name));
}
* @return the found document type
*/
@Transactional(readOnly = true)
- public DocumentType selectType(long index) {
+ public DocumentType selectType(final long index) {
return getDocumentTypeDAO().get(index);
}
* if some property is defined several times
*/
@Transactional
- public DocumentType createType(DocumentType.Properties tprop)
+ public DocumentType createType(final DocumentType.Properties tprop)
throws MissedPropertyException, InvalidPropertyException,
MultiplyDefinedException {
// TODO: Check for duplicate definition
* @return the list of found document types
*/
@Transactional(readOnly = true)
- public List<DocumentType> selectTypesOf(ProjectSettingsService.Step step) {
+ public List<DocumentType> selectTypesOf(final ProjectSettingsService.Step step) {
Integer number = step.getNumber();
String sampleStr = new StringBuffer("%-").append(number).append("-%")
.toString();
* @return true if approval succeeded
*/
@Transactional
- public boolean approve (DocumentType aType) {
- if (aType.getState() != ProgressState.inCHECK) return false;
- aType.setState(ProgressState.APPROVED); // The type name is supposed being localized
- getDocumentTypeDAO().update(aType);
- return true;
- }
+ public boolean approve(final DocumentType aType) {
+ boolean res = (aType.getState() == ProgressState.inCHECK);
+ if (res) {
+ aType.setState(ProgressState.APPROVED); // The type name is supposed being localized
+ getDocumentTypeDAO().update(aType);
+ }
+ return res;
+ }
/**
* Get the documentTypeDAO.
* @param documentTypeDAO
* the documentTypeDAO to set
*/
- public void setDocumentTypeDAO(DocumentTypeDAO documentTypeDAO) {
+ public void setDocumentTypeDAO(final DocumentTypeDAO documentTypeDAO) {
_documentTypeDAO = documentTypeDAO;
}
}
* the knowledge element to approve
* @return true if approving succeeded
*/
- public boolean approve(KnowledgeElement knowledgeElement);
+ boolean approve(KnowledgeElement knowledgeElement);
/**
* Demote the knowledge element.
* the knowledge element to demote
* @return true if demoting succeeded
*/
- public boolean demote(KnowledgeElement knowledgeElement);
+ boolean demote(KnowledgeElement knowledgeElement);
/**
* Promote the knowledge element.
* the knowledge element to promote
* @return true if promotion succeeded
*/
- public boolean promote(KnowledgeElement knowledgeElement);
+ boolean promote(KnowledgeElement knowledgeElement);
/**
* Rename the knowledge element.
* @throws InvalidPropertyException
* if renaming is failed
*/
- public void rename(KnowledgeElementDTO knowledgeElement, String title)
+ void rename(KnowledgeElementDTO knowledgeElement, String title)
throws InvalidPropertyException;
/**
* the knowledge element id
* @return the found knowledge element
*/
- public KnowledgeElement selectKnowledgeElement(long index);
+ KnowledgeElement selectKnowledgeElement(long index);
/**
* Get a knowledge element DTO by id.
* the knowledge element id
* @return the found knowledge element as DTO
*/
- public KnowledgeElementDTO getKnowledgeElement(long index);
+ KnowledgeElementDTO getKnowledgeElement(long index);
/**
* Update the description of the knowledge element.
* @param description
* the new description
*/
- public void update(KnowledgeElementDTO kelm, String description);
+ void update(KnowledgeElementDTO kelm, String description);
}
/**
* The logger for the service.
*/
- public final static AppLogger LOGGER = AppLogger
+ public final static AppLogger LOG = AppLogger
.getLogger(KnowledgeElementServiceImpl.class);
/**
getIndexService().update(knowledgeElement);
return true;
} catch (Exception error) {
- LOGGER.error("Unable to re-index the knowledge '"
+ LOG.error("Unable to re-index the knowledge '"
+ knowledgeElement.getIndex() + "', reason:", error);
return false;
}
* the knowledge type name
* @return the found knowledge type
*/
- public KnowledgeElementType selectType(String name);
+ KnowledgeElementType selectType(String name);
/**
* Create a knowledge element type with the given name.
* the new type name
* @return the created knowledge type
*/
- public KnowledgeElementType createType(String name);
+ KnowledgeElementType createType(String name);
/**
* Get all knowledge types from the database.
*
* @return the list of all knowledge types
*/
- public List<KnowledgeElementType> selectAllTypes();
+ List<KnowledgeElementType> selectAllTypes();
/**
* Get knowledge types which have the given progress state.
* the progress state
* @return the list of found knowledge types
*/
- public List<KnowledgeElementType> selectTypesWhere(ProgressState state);
+ List<KnowledgeElementType> selectTypesWhere(ProgressState state);
/**
* Get a knowledge type by its id.
* the id of a knowledge type
* @return the found knowledge type
*/
- public KnowledgeElementType selectType(long index);
+ KnowledgeElementType selectType(long index);
/**
* Approve the knowledge type.
* the knowledge type to approve
* @return true if approval succeeded
*/
- public boolean approve(KnowledgeElementType kelt);
+ boolean approve(KnowledgeElementType kelt);
/**
* Reserves this type for the management of simulation contexts. For being able to get the studies in which simulation contexts are
* the knowledge type to approve
* @return true if approval succeeded
*/
- public boolean reserve(KnowledgeElementType kelt);
+ boolean reserve(KnowledgeElementType kelt);
}
* @version $Revision$
*****************************************************************************/
-package org.splat.service;
+package org.splat.service;
import org.splat.exception.LockAlreadyExistsException;
import org.splat.exception.LockNotExistsException;
import org.splat.log.AppLogger;
/**
+ * The service to lock objects in the database.
+ *
* @author Maria KRUCHININA
- *
*/
public class LockServiceImpl implements LockService {
-
+
/**
* logger.
*/
- private final static AppLogger LOG = AppLogger.getLogger(LockService.class);
+ private final static AppLogger LOG = AppLogger.getLogger(LockService.class); // RKV: NOPMD: TODO: Complete the service.
/**
* Lock timeout period in milliseconds. A 24 hours by default.
*/
- private long _timeoutPeriod = 86400000L;
+ private final long _timeoutPeriod = 86400000L; // RKV: NOPMD: TODO: Complete the service.
/**
* Lock a data row or update lock on a data row for one user.
- * @param rowUid Row uid
- * @param tableUid Table uid
- * @param userUid User uid
- * @throws LockAlreadyExistsException when a lock already exists for row uid and another user id
+ *
+ * @param rowUid
+ * Row uid
+ * @param tableUid
+ * Table uid
+ * @param userUid
+ * User uid
+ * @throws LockAlreadyExistsException
+ * when a lock already exists for row uid and another user id
*/
- public void lock(final String rowUid, final String tableUid, final String userUid) throws LockAlreadyExistsException {
- //TODO:
+ public void lock(final String rowUid, final String tableUid,
+ final String userUid) throws LockAlreadyExistsException {
+ // TODO:
}
-
+
/**
* Unlock a data row for one user.
- * @param rowUid Row uid
- * @param tableUid Table uid
- * @param userUid User uid
- * @throws LockNotExistsException when lock does not exist
- * @throws LockProtectedException lock exists for another user
+ *
+ * @param rowUid
+ * Row uid
+ * @param tableUid
+ * Table uid
+ * @param userUid
+ * User uid
+ * @throws LockNotExistsException
+ * when lock does not exist
+ * @throws LockProtectedException
+ * lock exists for another user
*/
- public void unlock(final String rowUid, final String tableUid, final String userUid) throws LockNotExistsException, LockProtectedException {
- //TODO:
+ public void unlock(final String rowUid, final String tableUid,
+ final String userUid) throws LockNotExistsException,
+ LockProtectedException {
+ // TODO:
}
- /**
+ /**
* Unlock all datas rox for one user.
- * @param userUid User uid
+ *
+ * @param userUid
+ * User uid
*/
@Override
- public void unlockAll(String userUid) {
+ public void unlockAll(final String userUid) {
// TODO Auto-generated method stub
}
-
+
/**
* Check lock on a data row in a table for a user.
- * @param rowUid Row uid
- * @param tableUid Table uid
- * @param userUid User uid
- * @throws LockNotExistsException when lock does not exist
- * @throws LockProtectedException lock exists for another user
- * @throws LockOutdatedException when lock on object is in timeout but the
- * owner of lock is another user
+ *
+ * @param rowUid
+ * Row uid
+ * @param tableUid
+ * Table uid
+ * @param userUid
+ * User uid
+ * @throws LockNotExistsException
+ * when lock does not exist
+ * @throws LockProtectedException
+ * lock exists for another user
+ * @throws LockOutdatedException
+ * when lock on object is in timeout but the owner of lock is another user
*/
- public void check(final String rowUid, final String tableUid, final String userUid) throws LockNotExistsException, LockProtectedException, LockOutdatedException {
- //TODO:
+ public void check(final String rowUid, final String tableUid,
+ final String userUid) throws LockNotExistsException,
+ LockProtectedException, LockOutdatedException {
+ // TODO:
}
-
}
import org.splat.dal.bo.som.ProjectElement;
import org.splat.som.Step;
-import org.springframework.transaction.annotation.Transactional;
/**
* Project element service interface.
* a study or a scenario
* @return the first activity (step) of the project element
*/
- public Step getFirstStep(ProjectElement elem);
+ Step getFirstStep(ProjectElement elem);
/**
* Get activities of the project element.
* a study or a scenario
* @return array of activities (steps).
*/
- public Step[] getSteps(ProjectElement elem);
+ Step[] getSteps(ProjectElement elem);
/**
* Refreshes the internal data potentially out-of-date. This function needs to be called when Publication objects are added to this
* @param elem
* the project element to refresh
*/
- public void refresh(ProjectElement elem);
+ void refresh(ProjectElement elem);
}
/**
* Injected project settings service.
*/
- private ProjectSettingsService _projectSettingsService;
+ private ProjectSettingsService _projectSettings;
/**
* Injected project element DAO.
*/
*
* @see org.splat.service.ProjectElementService#getFirstStep(org.splat.dal.bo.som.ProjectElement)
*/
- public Step getFirstStep(ProjectElement elem) {
+ public Step getFirstStep(final ProjectElement elem) {
return getSteps(elem)[0];
}
- public Step getLastStep(ProjectElement elem) {
+ public Step getLastStep(final ProjectElement elem) {
Step[] mystep = getSteps(elem); // For getting the folders length, if null
return mystep[mystep.length - 1];
}
*
* @see org.splat.service.ProjectElementService#getSteps(org.splat.dal.bo.som.ProjectElement)
*/
- public Step[] getSteps(ProjectElement elem) {
+ public Step[] getSteps(final ProjectElement elem) {
if (elem.getFolders() == null) {
List<ProjectSettingsService.Step> steps = getProjectSettings()
.getStepsOf(elem.getClass());
* @param elem the project element to refresh
*/
@Transactional
- public void refresh(ProjectElement elem) {
+ public void refresh(final ProjectElement elem) {
// -------------------------
Publication[] curdoc = elem.getDocums().toArray(
new Publication[elem.getDocums().size()]);
elem.setFolders(null); // Just in case
elem.getDocums().clear();
- for (int i = 0; i < curdoc.length; i++)
+ for (int i = 0; i < curdoc.length; i++) {
elem.getDocums().add(curdoc[i]);
+ }
// No need to rebuild the list of SimulationContext as it does not use hashcodes
getProjectElementDAO().update(elem);
}
* @return Project settings service
*/
private ProjectSettingsService getProjectSettings() {
- return _projectSettingsService;
+ return _projectSettings;
}
/**
* @param projectSettingsService
* project settings service
*/
- public void setProjectSettings(ProjectSettingsService projectSettingsService) {
- _projectSettingsService = projectSettingsService;
+ public void setProjectSettings(final ProjectSettingsService projectSettingsService) {
+ _projectSettings = projectSettingsService;
}
/**
* Set the projectElementDAO.
* @param projectElementDAO the projectElementDAO to set
*/
- public void setProjectElementDAO(ProjectElementDAO projectElementDAO) {
+ public void setProjectElementDAO(final ProjectElementDAO projectElementDAO) {
_projectElementDAO = projectElementDAO;
}
}
* the target project element
* @return the created copy of the publication
*/
- public Publication copy(Publication aPublication, ProjectElement publisher);
+ Publication copy(Publication aPublication, ProjectElement publisher);
/**
* Create a new version of the document.
* @throws NotApplicableException if publication's document is undefined
* @throws InterruptedException by Thread.sleep if interrupted
*/
- public void versionDocument(Step step, User user, String filename,
+ void versionDocument(Step step, User user, String filename,
long docIndex, String docver, String summary, ProgressState state,
Date date, String[] docuses, long[] docusedby)
throws MissedPropertyException, InvalidPropertyException,
* the document publication
* @return study step
*/
- public Step getInvolvedStep(Publication aPublication);
+ Step getInvolvedStep(Publication aPublication);
/**
* Promotes the document referenced by this publication from In-Check to Approved state, if not out-dated, and attaches the
* @see DocumentType#isStudyResult()
* @see Study#getApproverOf(Publication)
*/
- public Timestamp approve(Publication aPublication, Date adate);
+ Timestamp approve(Publication aPublication, Date adate);
/**
* Demotes the document referenced by this publication to In-Work state, and removes the Promoter of the document, if exist.<br/> The
* @see DocumentRights#canDemote()
* @see DocumentType#isStudyResult()
*/
- public boolean demote(Publication aPublication);
+ boolean demote(Publication aPublication);
/**
* Undo the review operation by demoting the document referenced by this publication from In-Check to In-Draft state and removing the
* @see DocumentRights#canInvalidate()
* @see DocumentType#isStudyResult()
*/
- public boolean invalidate(Publication aPublication);
+ boolean invalidate(Publication aPublication);
/**
* Promotes the document referenced by this publication from In-Work to In-Draft or In-Check state, if not out-dated, and attaches the
* @see DocumentRights#canPromote()
* @see DocumentType#isStudyResult()
*/
- public Timestamp promote(Publication aPublication, Date pdate);
+ Timestamp promote(Publication aPublication, Date pdate);
/**
* Promotes the document referenced by this publication from In-Draft to In-Check state, if not out-dated, and attaches the
* @see DocumentType#isStudyResult()
* @see Study#getReviewerOf(Publication)
*/
- public Timestamp review(Publication aPublication, Date rdate);
+ Timestamp review(Publication aPublication, Date rdate);
/**
* Publishes the document referenced by this publication into the owner Project Element under the given state, the revision number of
* @throws NotApplicableException
* If the referenced document is undefined
*/
- public void saveAs(Publication aPublication, ProgressState state)
+ void saveAs(Publication aPublication, ProgressState state)
throws FileNotFoundException, NotApplicableException;
/**
* If the referenced document is undefined
* @deprecated
*/
- public void saveAs(Publication aPublication, Revision newvers)
+ @Deprecated
+ void saveAs(Publication aPublication, Revision newvers)
throws FileNotFoundException, NotApplicableException;
/**
* @throws InvalidPropertyException
* if the new title is empty
*/
- public void rename(Publication aPublication, String title)
+ void rename(Publication aPublication, String title)
throws InvalidPropertyException;
/**
* the format
* @return the created "Converts" relation
*/
- public ConvertsRelation attach(Publication aPublication, String format);
+ ConvertsRelation attach(Publication aPublication, String format);
/**
* Create "Converts" relation for the given document publication, format and description.
* the description of the relation
* @return the created "Converts" relation
*/
- public ConvertsRelation attach(Publication aPublication, String format,
+ ConvertsRelation attach(Publication aPublication, String format,
String description);
/**
* @see #outdate()
* @see DocumentRights#canAccept()
*/
- public boolean actualize(Publication aPublication);
+ boolean actualize(Publication aPublication);
/**
* Out-dates this publication and recursively all publications using this one. Typically, a publication is out-dated when modifying a
* @see #getProgressState()
* @see #actualize()
*/
- public void outdate(Publication aPublication);
+ void outdate(Publication aPublication);
}
/**
* Logger for this class.
*/
- protected final static Logger logger = Logger
+ protected final static Logger LOG = Logger
.getLogger(PublicationServiceImpl.class);
/**
*
* @see org.splat.service.PublicationService#copy(org.splat.dal.bo.som.Publication, org.splat.dal.bo.som.ProjectElement)
*/
- public Publication copy(Publication aPublication, ProjectElement publisher) {
+ public Publication copy(final Publication aPublication, final ProjectElement publisher) {
Publication copy = new Publication();
copy.setValue(aPublication.value());
copy.setStep(aPublication.getStep()); // May not be initialized yet
* @see org.splat.service.PublicationService#versionDocument(org.splat.som.Step, org.splat.dal.bo.kernel.User, java.lang.String, long, java.lang.String, java.lang.String, org.splat.dal.bo.som.ProgressState, java.util.Date, java.lang.String[], long[])
*/
@Transactional
- public void versionDocument(Step step, User user, String filename,
- long docIndex, String docver, String summary, ProgressState state,
- Date date, String[] docuses, long[] docusedby)
+ public void versionDocument(final Step step, final User user,
+ final String filename, final long docIndex, final String docver,
+ final String summary, final ProgressState state, final Date date,
+ final String[] docuses, final long[] docusedby)
throws MissedPropertyException, InvalidPropertyException,
MultiplyDefinedException, IOException, MismatchException,
NotApplicableException, InterruptedException {
Publication current = step.getDocument(docIndex);
Publication next;
- if (docver.length() == 0) { // Importation of a foreign document
- next = getStepService().versionDocument(step, current,
- dprop.setAuthor(user).setDescription(summary));
- updir = next.getSourceFile().asFile();
- if (logger.isInfoEnabled())
- logger.info("Moving \"" + upfile.getName() + "\" to \""
- + updir.getPath() + "\".");
- upfile.renameTo(updir);
- try {
+ if ((docver.length() != 0) && // Importation of a not foreign document
+ (date != null)) {
+ dprop.setDate(date);
+ }
+ next = getStepService().versionDocument(step, current,
+ dprop.setAuthor(user).setDescription(summary));
+ updir = next.getSourceFile().asFile();
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Moving \"" + upfile.getName() + "\" to \""
+ + updir.getPath() + "\".");
+ }
+ upfile.renameTo(updir);
+
+ try {
+ if (docver.length() == 0) { // Importation of a foreign document
saveAs(next, state); // May throw FileNotFound if rename was not done
- } catch (FileNotFoundException saverror) {
- Thread.sleep(1000);
- logger.info("Waiting for the file.");
- upfile.renameTo(updir);
- saveAs(next, state); // Forget it if throw again FileNotFound
- }
- } else {
- if (date != null) {
- dprop.setDate(date);
- }
- next = getStepService().versionDocument(step, current,
- dprop.setAuthor(user).setDescription(summary));
- updir = next.getSourceFile().asFile();
- if (logger.isInfoEnabled())
- logger.info("Moving \"" + upfile.getName() + "\" to \""
- + updir.getPath() + "\".");
- upfile.renameTo(updir);
- try {
+ } else {
saveAs(next, new Revision(docver));
- } catch (FileNotFoundException saverror) {
- Thread.sleep(1000);
- logger.info("Waiting for the file.");
- upfile.renameTo(updir);
- saveAs(next, state);
}
+ } catch (FileNotFoundException saverror) {
+ Thread.sleep(1000);
+ LOG.info("Waiting for the file.");
+ upfile.renameTo(updir);
+ saveAs(next, state);
}
// TODO: Remove current document details from the contents of open study
// Creation of uses relations
+ updateRelations(current, next, docuses, docusedby);
+ }
+
+ /**
+ * Update relations after creation of a new document version.
+ *
+ * @param current
+ * the current version
+ * @param next
+ * the new version
+ * @param docuses
+ * ids of used documents
+ * @param docusedby
+ * ids of documents used by the versioned one.
+ */
+ private void updateRelations(final Publication current,
+ final Publication next, final String[] docuses,
+ final long[] docusedby) {
if (docuses != null) {
for (int i = 0; i < docuses.length; i++) {
Long index = Long.valueOf(docuses[i].trim());
- Publication used = getPublicationDAO().get(index);//RKV: getPublication(index, steps);
+ Publication used = getPublicationDAO().get(index);// RKV: getPublication(index, steps);
next.addDependency(used);
}
}
List<Publication> relist = current.getRelations(UsedByRelation.class);
for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
Publication using = i.next();
- if (!compatible.contains(using.getIndex()))
+ if (!compatible.contains(using.getIndex())) {
outdate(using);
+ }
}
-
}
/* protected Publication getPublication(int index, List<Step> steps) {
* @see org.splat.service.PublicationService#approve(org.splat.dal.bo.som.Publication, java.util.Date)
*/
@Transactional
- public Timestamp approve(Publication aPublication, Date adate) {
- if (aPublication.isOutdated())
- return null;
- else if (aPublication.value().getProgressState() != ProgressState.inCHECK)
- return null; // This statement must conform to the corresponding right
-
- DocumentType type = aPublication.value().getType();
- Study owner = aPublication.getOwnerStudy();
- ValidationCycle cycle = getStudyService().getValidationCycleOf(owner,
- type);
- User approver = cycle.getActor(ValidationStep.APPROVAL);
- Timestamp stamp = new Timestamp(ValidationStep.APPROVAL, aPublication
- .value(), approver, adate);
- getTimestampDAO().create(stamp);
-
- if (!getDocumentService().promote(aPublication.value(), stamp))
- return null;
- if (getDocumentService().isStudyResult(type)
- && owner.getProgressState() == ProgressState.inCHECK)
- getStudyService().promote(owner);
- return stamp; // Hoping that promotion of the study succeeded
+ public Timestamp approve(final Publication aPublication, final Date adate) {
+ Timestamp res = null;
+ if (!(aPublication.isOutdated() || (aPublication.value().getProgressState() != ProgressState.inCHECK))) {
+ DocumentType type = aPublication.value().getType();
+ Study owner = aPublication.getOwnerStudy();
+ ValidationCycle cycle = getStudyService().getValidationCycleOf(owner,
+ type);
+ User approver = cycle.getActor(ValidationStep.APPROVAL);
+ Timestamp stamp = new Timestamp(ValidationStep.APPROVAL, aPublication
+ .value(), approver, adate);
+ getTimestampDAO().create(stamp);
+
+ if (getDocumentService().promote(aPublication.value(), stamp)) {
+ res = stamp;
+ if (getDocumentService().isStudyResult(type)
+ && owner.getProgressState() == ProgressState.inCHECK) {
+ getStudyService().promote(owner);
+ }
+ }
+ }
+ return res; // Hoping that promotion of the study succeeded
}
/**
* @see org.splat.service.PublicationService#demote(org.splat.dal.bo.som.Publication)
*/
@Transactional
- public boolean demote(Publication aPublication) {
+ public boolean demote(final Publication aPublication) {
+ boolean res = false;
DocumentType type = aPublication.value().getType();
Study owner = aPublication.getOwnerStudy();
ValidationCycle cycle = getStudyService().getValidationCycleOf(
owner, type);
if (cycle.enables(ValidationStep.REVIEW)) {
- if (!getDocumentService().demote(aPublication.value()))
- return false;
+ res = getDocumentService().demote(aPublication.value());
} else {
- if (!getDocumentService().demote(aPublication.value()))
- return false;
- getDocumentService().demote(aPublication.value());
+ res = getDocumentService().demote(aPublication.value());
+ if (res) {
+ getDocumentService().demote(aPublication.value());
+ }
}
} else if (aPublication.value().getProgressState() == ProgressState.inDRAFT) {
- if (!getDocumentService().demote(aPublication.value()))
- return false;
- } else {
- return false;
+ res = getDocumentService().demote(aPublication.value());
}
- if (getDocumentService().isStudyResult(type)
- && owner.getProgressState() != ProgressState.inWORK)
+ if (res && getDocumentService().isStudyResult(type)
+ && owner.getProgressState() != ProgressState.inWORK) {
getStudyService().demote(owner);
- return true;
+ }
+ return res;
}
/**
* @see org.splat.service.PublicationService#invalidate(org.splat.dal.bo.som.Publication)
*/
@Transactional
- public boolean invalidate(Publication aPublication) {
- if (aPublication.value().getProgressState() != ProgressState.inCHECK)
- return false;
- if (!getDocumentService().demote(aPublication.value())) // Removes the reviewer if this document is In-Check
- return false;
- DocumentType type = aPublication.value().getType();
- Study owner = aPublication.getOwnerStudy();
- if (getDocumentService().isStudyResult(type)
- && owner.getProgressState() == ProgressState.inCHECK)
- getStudyService().demote(owner);
- return true;
+ public boolean invalidate(final Publication aPublication) {
+ boolean res = false;
+ if ((aPublication.value().getProgressState() == ProgressState.inCHECK)
+ && getDocumentService().demote(aPublication.value())) {
+ DocumentType type = aPublication.value().getType();
+ Study owner = aPublication.getOwnerStudy();
+ if (getDocumentService().isStudyResult(type)
+ && owner.getProgressState() == ProgressState.inCHECK) {
+ getStudyService().demote(owner);
+ }
+ res = true;
+ }
+ return res;
}
/**
* @see org.splat.service.PublicationService#promote(org.splat.dal.bo.som.Publication, java.util.Date)
*/
@Transactional
- public Timestamp promote(Publication aPublication, Date pdate) {
- if (aPublication.isOutdated())
- return null;
- else if (aPublication.value().getProgressState() != ProgressState.inWORK)
- return null; // This statement must conform to the corresponding right
- else {
+ public Timestamp promote(final Publication aPublication, final Date pdate) {
+ Timestamp res = null;
+ if ((!aPublication.isOutdated())
+ && (aPublication.value().getProgressState() == ProgressState.inWORK)) {
DocumentType type = aPublication.value().getType();
Study owner = aPublication.getOwnerStudy();
ValidationCycle cycle = getStudyService().getValidationCycleOf(
owner, type);
User promoter = cycle.getActor(ValidationStep.PROMOTION);
- if (promoter == null)
+ if (promoter == null) {
promoter = getInvolvedStep(aPublication).getActor();
- if (promoter == null)
+ }
+ if (promoter == null) {
promoter = owner.getAuthor();
+ }
Timestamp stamp = new Timestamp(ValidationStep.PROMOTION,
aPublication.value(), promoter, pdate);
getTimestampDAO().create(stamp);
- if (!getDocumentService().promote(aPublication.value(), stamp)) // Promotion to being reviewed
- return null;
- if (!cycle.enables(ValidationStep.REVIEW)) {
- getDocumentService().promote(aPublication.value(), null);
+ if (getDocumentService().promote(aPublication.value(), stamp)) {
+ res = stamp;
+ if (!cycle.enables(ValidationStep.REVIEW)) {
+ getDocumentService().promote(aPublication.value(), null);
+ }
+ if (getDocumentService().isStudyResult(type)
+ && owner.getProgressState() == ProgressState.inWORK) {
+ getStudyService().promote(owner);
+ }
}
- if (getDocumentService().isStudyResult(type)
- && owner.getProgressState() == ProgressState.inWORK)
- getStudyService().promote(owner);
- return stamp; // Hoping that promotion of the study succeeded
}
+ return res; // Hoping that promotion of the study succeeded
}
/**
* @see org.splat.service.PublicationService#review(org.splat.dal.bo.som.Publication, java.util.Date)
*/
@Transactional
- public Timestamp review(Publication aPublication, Date rdate) {
- if (aPublication.isOutdated())
- return null;
- else if (aPublication.value().getProgressState() != ProgressState.inDRAFT)
- return null; // This statement must conform to the corresponding right
+ public Timestamp review(final Publication aPublication, final Date rdate) {
+ Timestamp res = null;
+ if (!aPublication.isOutdated()
+ && !(aPublication.value().getProgressState() != ProgressState.inDRAFT)) {
- DocumentType type = aPublication.value().getType();
- Study owner = aPublication.getOwnerStudy();
- ValidationCycle cycle = getStudyService().getValidationCycleOf(owner,
- type);
- User reviewer = cycle.getActor(ValidationStep.REVIEW);
- Timestamp stamp = new Timestamp(ValidationStep.REVIEW, aPublication
- .value(), reviewer, rdate);
- getTimestampDAO().create(stamp);
-
- if (!getDocumentService().promote(aPublication.value(), stamp))
- return null;
- if (getDocumentService().isStudyResult(type)
- && owner.getProgressState() == ProgressState.inDRAFT)
- getStudyService().promote(owner);
- return stamp; // Hoping that promotion of the study succeeded
+ DocumentType type = aPublication.value().getType();
+ Study owner = aPublication.getOwnerStudy();
+ ValidationCycle cycle = getStudyService().getValidationCycleOf(
+ owner, type);
+ User reviewer = cycle.getActor(ValidationStep.REVIEW);
+ Timestamp stamp = new Timestamp(ValidationStep.REVIEW, aPublication
+ .value(), reviewer, rdate);
+ getTimestampDAO().create(stamp);
+
+ if (getDocumentService().promote(aPublication.value(), stamp)) {
+ res = stamp;
+ if (getDocumentService().isStudyResult(type)
+ && owner.getProgressState() == ProgressState.inDRAFT) {
+ getStudyService().promote(owner);
+ }
+ }
+ }
+ return res; // Hoping that promotion of the study succeeded
}
/**
* @see org.splat.service.PublicationService#saveAs(org.splat.dal.bo.som.Publication, org.splat.som.Revision)
* @deprecated
*/
+ @Deprecated
@Transactional
- public void saveAs(Publication aPublication, Revision newvers)
+ public void saveAs(final Publication aPublication, final Revision newvers)
throws FileNotFoundException, NotApplicableException {
- if (aPublication.value().isUndefined())
+ if (aPublication.value().isUndefined()) {
throw new NotApplicableException(
"Cannot save a Publication object refering an undefined Document");
- if (!aPublication.value().getSourceFile().exists())
+ }
+ if (!aPublication.value().getSourceFile().exists()) {
throw new FileNotFoundException();
+ }
getPublicationDAO().create(aPublication); // Must be done before updating the study in order to fix this final (rid-based) hascode
getDocumentService().updateAs(aPublication.value(), newvers); // May change the branch name of given revision
* @see org.splat.service.PublicationService#saveAs(org.splat.dal.bo.som.Publication, org.splat.dal.bo.som.ProgressState)
*/
@Transactional
- public void saveAs(Publication aPublication, ProgressState state)
+ public void saveAs(final Publication aPublication, final ProgressState state)
throws FileNotFoundException, NotApplicableException {
- if (aPublication.value().isUndefined())
+ if (aPublication.value().isUndefined()) {
throw new NotApplicableException(
"Cannot save a Publication object refering an undefined Document");
- if (!aPublication.value().getSourceFile().exists())
+ }
+ if (!aPublication.value().getSourceFile().exists()) {
throw new FileNotFoundException();
+ }
if (state == ProgressState.inWORK || state == ProgressState.EXTERN) {
getPublicationDAO().create(aPublication); // Must be done before updating the study in order to fix this final (rid-based)
* the document publication
*/
@Transactional
- private void updateOwner(Publication aPublication) {
+ private void updateOwner(final Publication aPublication) {
Step step = getInvolvedStep(aPublication);
// Update of involved step
* @param to
* the study step
*/
- private void forwardProperties(Publication aPublication, java.io.File from,
- Step to) {
+ private void forwardProperties(final Publication aPublication,
+ final java.io.File from, final Step to) {
Reader tool = Toolbox.getReader(from);
- if (tool == null)
- return; // No properties extractor available for this type of document
-
- SimulationContextType.Properties sprop = new SimulationContextType.Properties()
- .setStep(to.getStep()).setProgressState(ProgressState.APPROVED);
- List<SimulationContextType> contype = getSimulationContextService()
- .selectTypesWhere(sprop);
- if (contype.isEmpty())
- return; // No approved property type configured at this step
-
- SimulationContext.Properties cprop = new SimulationContext.Properties();
- List<SimulationContext> context = to.getAllSimulationContexts();
-
- context = new ArrayList<SimulationContext>(context.size());
- context.addAll(to.getAllSimulationContexts());
- cprop.disableCheck();
- for (Iterator<SimulationContextType> i = contype.iterator(); i
- .hasNext();) {
- SimulationContextType property = i.next();
- for (Iterator<SimulationContext> j = context.iterator(); j
- .hasNext();) {
- SimulationContext existing = j.next();
- if (!existing.getType().equals(property))
- continue;
- property = null; // Forget this property as it is already set
- break;
- }
- if (property != null)
- try {
- String value = tool.extractProperty(property.getName());
- if (value == null)
- continue; // Property not defined into the document
-
- cprop.setType(property).setValue(value);
- if (aPublication.getOwner() instanceof Study)
- getStudyService().addProjectContext(
- (Study) aPublication.getOwner(), cprop); // Re-indexes knowledges and the study
- else
- getStepService().addSimulationContext(to, cprop); // Re-indexes knowledges only
- } catch (Exception e) {
- break;
+ if (tool != null) { // Properties extractor available for this type of document
+ SimulationContextType.Properties sprop = new SimulationContextType.Properties()
+ .setStep(to.getStep()).setProgressState(
+ ProgressState.APPROVED);
+ List<SimulationContextType> contype = getSimulationContextService()
+ .selectTypesWhere(sprop);
+ if (!contype.isEmpty()) { // There is an approved property type configured at this step
+
+ SimulationContext.Properties cprop = new SimulationContext.Properties();
+ List<SimulationContext> context = to.getAllSimulationContexts();
+
+ context = new ArrayList<SimulationContext>(context.size());
+ context.addAll(to.getAllSimulationContexts());
+ cprop.disableCheck();
+ for (Iterator<SimulationContextType> i = contype.iterator(); i
+ .hasNext();) {
+ SimulationContextType property = i.next();
+ boolean isFound = false;
+ for (Iterator<SimulationContext> j = context.iterator(); j
+ .hasNext();) {
+ SimulationContext existing = j.next();
+ isFound = existing.getType().equals(property);
+ if (isFound) {
+ // Forget this property as it is already set
+ break;
+ }
+ }
+ if (!isFound) {
+ try {
+ String value = tool.extractProperty(property
+ .getName());
+ if (value == null) {
+ continue; // Property not defined into the document
+ }
+
+ cprop.setType(property).setValue(value);
+ if (aPublication.getOwner() instanceof Study) {
+ getStudyService().addProjectContext(
+ (Study) aPublication.getOwner(), cprop); // Re-indexes knowledges and the study
+ } else {
+ getStepService()
+ .addSimulationContext(to, cprop); // Re-indexes knowledges only
+ }
+ } catch (Exception e) {
+ break;
+ }
+ }
}
+ }
}
}
* the document publication
* @return the study step where the document is published
*/
- public Step getInvolvedStep(Publication aPublication) {
+ public Step getInvolvedStep(final Publication aPublication) {
if (aPublication.getStep() == null) {
Step[] step = getProjectElementService().getSteps(
aPublication.getOwner());
for (int i = 0; i < step.length; i++) {
aPublication.setStep(step[i]); // The involved step necessarily exists
- if (aPublication.value().isInto(aPublication.getStep()))
+ if (aPublication.value().isInto(aPublication.getStep())) {
break;
+ }
}
}
return aPublication.getStep();
* @see DocumentRights#canAccept()
*/
@Transactional
- public boolean actualize(Publication aPublication) {
- if (!aPublication.isOutdated())
- return false;
- aPublication.setIsnew('Y');
- getPublicationDAO().update(aPublication);
- return true;
+ public boolean actualize(final Publication aPublication) {
+ boolean res = aPublication.isOutdated();
+ if (res) {
+ aPublication.setIsnew('Y');
+ getPublicationDAO().update(aPublication);
+ }
+ return res;
}
/**
* @see #getProgressState()
* @see #actualize()
*/
- public void outdate(Publication aPublication) {
- if (aPublication.isOutdated())
+ public void outdate(final Publication aPublication) {
+ if (aPublication.isOutdated()) {
return;
+ }
List<Publication> relist = aPublication
.getRelations(UsedByRelation.class);
* the format
* @return the created "Converts" relation
*/
- public ConvertsRelation attach(Publication aPublication, String format) {
+ public ConvertsRelation attach(final Publication aPublication, final String format) {
return getDocumentService().attach(aPublication.value(), format);
}
* the description of the relation
* @return the created "Converts" relation
*/
- public ConvertsRelation attach(Publication aPublication, String format,
- String description) {
+ public ConvertsRelation attach(final Publication aPublication, final String format,
+ final String description) {
return getDocumentService().attach(aPublication.value(), format,
description);
}
* @throws InvalidPropertyException
* if the new title is empty
*/
- public void rename(Publication aPublication, String title)
+ public void rename(final Publication aPublication, final String title)
throws InvalidPropertyException {
getDocumentService().rename(aPublication.value(), title);
}
* the projectElementService to set
*/
public void setProjectElementService(
- ProjectElementService projectElementService) {
+ final ProjectElementService projectElementService) {
_projectElementService = projectElementService;
}
* the simulationContextService to set
*/
public void setSimulationContextService(
- SimulationContextService simulationContextService) {
+ final SimulationContextService simulationContextService) {
_simulationContextService = simulationContextService;
}
* @param studyService
* the studyService to set
*/
- public void setStudyService(StudyService studyService) {
+ public void setStudyService(final StudyService studyService) {
_studyService = studyService;
}
* @param stepService
* the stepService to set
*/
- public void setStepService(StepService stepService) {
+ public void setStepService(final StepService stepService) {
_stepService = stepService;
}
* @param documentService
* the documentService to set
*/
- public void setDocumentService(DocumentService documentService) {
+ public void setDocumentService(final DocumentService documentService) {
_documentService = documentService;
}
* @param publicationDAO
* the publicationDAO to set
*/
- public void setPublicationDAO(PublicationDAO publicationDAO) {
+ public void setPublicationDAO(final PublicationDAO publicationDAO) {
_publicationDAO = publicationDAO;
}
* @param projectElementDAO
* the projectElementDAO to set
*/
- public void setProjectElementDAO(ProjectElementDAO projectElementDAO) {
+ public void setProjectElementDAO(final ProjectElementDAO projectElementDAO) {
_projectElementDAO = projectElementDAO;
}
* @param repositoryService
* the repositoryService to set
*/
- public void setRepositoryService(RepositoryService repositoryService) {
+ public void setRepositoryService(final RepositoryService repositoryService) {
_repositoryService = repositoryService;
}
* Set the timestampDAO.
* @param timestampDAO the timestampDAO to set
*/
- public void setTimestampDAO(TimestampDAO timestampDAO) {
+ public void setTimestampDAO(final TimestampDAO timestampDAO) {
_timestampDAO = timestampDAO;
}
}
* @throws MultiplyDefinedException
* if some property occurs several times
*/
- public Study createStudy(Study.Properties sprop, Scenario.Properties oprop,
+ Study createStudy(Study.Properties sprop, Scenario.Properties oprop,
SimulationContext.Properties cprop) throws MissedPropertyException,
InvalidPropertyException, MultiplyDefinedException;
* @throws MultiplyDefinedException
* if some property occurs several times
*/
- public Scenario addScenario(Study aStudy, Scenario.Properties sprop)
+ Scenario addScenario(Study aStudy, Scenario.Properties sprop)
throws MissedPropertyException, InvalidPropertyException,
MultiplyDefinedException;
* @throws MultiplyDefinedException
* if some property is defined several times
*/
- public KnowledgeElement addKnowledgeElement(Scenario aScenario,
+ KnowledgeElement addKnowledgeElement(Scenario aScenario,
KnowledgeElement.Properties kprop) throws MissedPropertyException,
InvalidPropertyException, MultiplyDefinedException;
* @param aScenario
* the scenario to check in
*/
- public void checkin(Scenario aScenario);
+ void checkin(Scenario aScenario);
/**
* Check out the scenario.
* the current user
* @return true if check out operation succeeded
*/
- public boolean checkout(Scenario aScenario, User user);
+ boolean checkout(Scenario aScenario, User user);
/**
* Copy contents from other scenario up to its given step into the given scenario.
* @param lastep
* the last processed step of the source scenario
*/
- public void copyContentsUpTo(Scenario scenario, Step lastep);
+ void copyContentsUpTo(Scenario scenario, Step lastep);
/**
* Check if the scenario is empty, i.d. no one of its steps doesn't contain any knowledge elements or documents.
* the scenario to check
* @return true if the scenario is empty
*/
- public boolean isEmpty(Scenario scenario);
+ boolean isEmpty(Scenario scenario);
/**
* Remove a knowledge element from a scenario.
* the knowledge element to remove
* @return true if removal succeeded
*/
- public boolean removeKnowledgeElement(Scenario scenario,
+ boolean removeKnowledgeElement(Scenario scenario,
KnowledgeElement kelm);
}
/**
* Logger for this class.
*/
- protected final static Logger logger = Logger
+ protected final static Logger LOG = Logger
.getLogger(ScenarioServiceImpl.class);
/**
KnowledgeElement kelm = null;
try {
long aScenarioId = aScenarioDTO.getIndex();
- if (logger.isDebugEnabled()) {
- logger.debug("Add a knowledge element to the scenario #"
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Add a knowledge element to the scenario #"
+ aScenarioId);
}
// Get the persistent scenario.
// Update the lucene index of knowledge elements.
getIndexService().add(kelm);
- if (logger.isDebugEnabled()) {
- logger.debug("A knowledge element #" + kelm.getIndex()
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("A knowledge element #" + kelm.getIndex()
+ " is added to the scenario #" + aScenario.getIndex());
}
} catch (IOException error) {
- logger.error("Unable to index the knowedge element '"
+ LOG.error("Unable to index the knowedge element '"
+ kelm.getIndex() + "', reason:", error);
kelm = null;
}
getScenarioDAO().update(aScenario); // Update of relational base
isOk = true;
} catch (Exception error) {
- logger.error("Unable to re-index the knowledge element '"
+ LOG.error("Unable to re-index the knowledge element '"
+ aScenario.getIndex() + "', reason:", error);
}
return isOk;
package org.splat.service;
import java.util.List;
+
import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.bo.som.Study;
import org.splat.service.dto.ImportedStudyDTO;
*
* @return list of ImportedStudy DTO
*/
- public List<ImportedStudyDTO> selectStudies();
+ List<ImportedStudyDTO> selectStudies();
/**
* Refresh lucene index for studies.
* @param ridlist
* list of studies id's
*/
- public void reindexStudies(String[] ridlist);
+ void reindexStudies(String[] ridlist);
/**
* Find knowledge elements with given properties.
* search filter parameters
* @return the list of found knowledge elements as proxiy results of lucene search
*/
- public List<Proxy> selectKnowledgeElementsWhere(
+ List<Proxy> selectKnowledgeElementsWhere(
KnowledgeElement.Properties... kprop);
/**
* search filter parameters
* @return the list of found studies as proxiy results of lucene search
*/
- public List<Proxy> selectStudiesWhere(Study.Properties... sprop);
+ List<Proxy> selectStudiesWhere(Study.Properties... sprop);
/**
* Refresh lucene index for a study.
* @param study
* the study to reindex
*/
- public void indexStudy(Study study);
+ void indexStudy(Study study);
}
import org.splat.dal.bo.som.Study;
import org.splat.dal.bo.som.Visibility;
import org.splat.dal.dao.som.StudyDAO;
+import org.splat.service.dto.ImportedStudyDTO;
import org.splat.service.dto.Proxy;
import org.splat.service.technical.IndexService;
import org.splat.service.technical.IndexServiceImpl;
import org.splat.service.technical.RepositoryService;
-import org.splat.service.dto.ImportedStudyDTO;
import org.splat.util.BeanHelper;
import org.springframework.transaction.annotation.Transactional;
/**
* The service logger.
*/
- public final static Logger logger = Logger
+ public final static Logger LOG = Logger
.getLogger(org.splat.service.SearchServiceImpl.class);
/**
* list of studies id's
*/
@Transactional(readOnly = true)
- public void reindexStudies(String[] ridlist) {
+ public void reindexStudies(final String[] ridlist) {
for (int i = 0; i < ridlist.length; i++) {
long index = Long.valueOf(ridlist[i].trim());
Study study = getStudyService().selectStudy(index);
* @see org.splat.service.SearchService#selectKnowledgeElementsWhere(org.splat.dal.bo.som.KnowledgeElement.Properties[])
*/
public List<Proxy> selectKnowledgeElementsWhere(
- KnowledgeElement.Properties... kprop) {
+ final KnowledgeElement.Properties... kprop) {
List<Proxy> result = new ArrayList<Proxy>();
int hitsize = 20;
try {
BooleanQuery critext = new BooleanQuery();
String operator = "AND"; // Future user input
BooleanClause.Occur clause = BooleanClause.Occur.MUST;
- if (operator.equals("OR"))
+ if (operator.equals("OR")) {
clause = BooleanClause.Occur.SHOULD;
+ }
String[] word = title.split(" ");
for (int j = 0; j < word.length; j++) {
critext.add(new TermQuery(input.createTerm(word[j])),
}
fulquery.add(query, BooleanClause.Occur.SHOULD);
}
- if (logger.isInfoEnabled()) {
- logger.info("Searching knowledges by Lucene query \""
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Searching knowledges by Lucene query \""
+ fulquery.toString() + "\".");
}
// Creation of the knowledge filter
TopFieldDocs found = searcher.search(fulquery, filter, hitsize,
sort);
- if (found.totalHits < 1)
+ if (found.totalHits < 1) {
return result; // No study found
+ }
// Construction of the result list
ScoreDoc[] hits = found.scoreDocs;
}
searcher.close();
} catch (Exception error) {
- logger.error("Error during Lucene search, reason:", error);
+ LOG.error("Error during Lucene search, reason:", error);
}
return result;
}
*
* @see org.splat.service.SearchService#selectStudiesWhere(org.splat.dal.bo.som.Study.Properties[])
*/
- public List<Proxy> selectStudiesWhere(Study.Properties... sprop) {
+ public List<Proxy> selectStudiesWhere(final Study.Properties... sprop) {
List<Proxy> result = new ArrayList<Proxy>();
int hitsize = 20;
try {
BooleanQuery critext = new BooleanQuery();
String operator = "AND"; // Future user input
BooleanClause.Occur clause = BooleanClause.Occur.MUST;
- if (operator.equals("OR"))
+ if (operator.equals("OR")) {
clause = BooleanClause.Occur.SHOULD;
+ }
String[] word = title.split(" ");
for (int j = 0; j < word.length; j++) {
critext.add(new TermQuery(input.createTerm(word[j])),
}
fulquery.add(query, BooleanClause.Occur.SHOULD);
}
- if (logger.isInfoEnabled()) {
- logger.info("Searching studies by Lucene query \""
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Searching studies by Lucene query \""
+ fulquery.toString() + "\".");
}
// Creation of the studies filter
TopFieldDocs found = searcher.search(fulquery, filter, hitsize,
sort);
- if (found.totalHits < 1)
+ if (found.totalHits < 1) {
return result; // No study found
+ }
// Construction of the result list
ScoreDoc[] hits = found.scoreDocs;
}
searcher.close();
} catch (Exception error) {
- logger.error("Error during Lucene search, reason:", error);
+ LOG.error("Error during Lucene search, reason:", error);
}
return result;
}
*
* @see org.splat.service.SearchService#indexStudy(org.splat.dal.bo.som.Study)
*/
- public void indexStudy(Study study) {
- logger.debug("Index study: id=" + study.getRid() + "; reference="
+ public void indexStudy(final Study study) {
+ LOG.debug("Index study: id=" + study.getRid() + "; reference="
+ study.getReference());
try {
Study.Properties sprop = new Study.Properties();
.getReference()));
if (index.size() != 0) {
- logger.debug("The given study is already indexed.");
+ LOG.debug("The given study is already indexed.");
return; // The given study is already indexed
}
IndexService lucin = getIndex();
Scenario[] scenes = study.getScenarii();
- logger.debug("Number of study " + study.getReference()
+ LOG.debug("Number of study " + study.getReference()
+ " actors: " + study.getActor().size());
lucin.add(study);
- if (study.getProgressState() != ProgressState.inWORK)
+ if (study.getProgressState() != ProgressState.inWORK) {
for (int i = 0; i < scenes.length; i++) {
List<KnowledgeElement> list = scenes[i]
.getAllKnowledgeElements();
for (Iterator<KnowledgeElement> j = list.iterator(); j
.hasNext();) {
lucin.add(j.next());
- logger.debug("Knowlegge added: id="
+ LOG.debug("Knowlegge added: id="
+ j.next().getIndex());
}
}
+ }
} catch (Exception error) {
- logger.error("Unable to index the study '" + study.getIndex()
+ LOG.error("Unable to index the study '" + study.getIndex()
+ "', reason:", error);
}
}
*/
private IndexService getIndex() throws IOException {
IndexService lucin = getIndexService();
- if (!lucin.exists())
+ if (!lucin.exists()) {
lucin.create(); // Happens when re-indexing all studies
+ }
return lucin;
}
* @param repositoryService
* the repositoryService to set
*/
- public void setRepositoryService(RepositoryService repositoryService) {
+ public void setRepositoryService(final RepositoryService repositoryService) {
_repositoryService = repositoryService;
}
* @param indexService
* the indexService to set
*/
- public void setIndexService(IndexService indexService) {
+ public void setIndexService(final IndexService indexService) {
_indexService = indexService;
}
* @param studyService
* the studyService to set
*/
- public void setStudyService(StudyService studyService) {
+ public void setStudyService(final StudyService studyService) {
_studyService = studyService;
}
* @param studyDAO
* the studyDAO to set
*/
- public void setStudyDAO(StudyDAO studyDAO) {
+ public void setStudyDAO(final StudyDAO studyDAO) {
_studyDAO = studyDAO;
}
}
* @param studyService
* the studyService to set
*/
- public void setStudyService(StudyService studyService);
+ void setStudyService(StudyService studyService);
/**
* Get the userService.
*
* @return the userService
*/
- public UserService getUserService();
+ UserService getUserService();
/**
* Set the userService.
* @param userService
* the userService to set
*/
- public void setUserService(UserService userService);
+ void setUserService(UserService userService);
}
* @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
*/
@Deprecated
-public class ServiceLocatorImpl implements ServiceLocator {
+public final class ServiceLocatorImpl implements ServiceLocator {
/**
* The Locator instance.
*/
- static ServiceLocator theInstance;
+ static private ServiceLocator theInstance = new ServiceLocatorImpl();
/**
* Get the locator instance.
* @return the locator instance
*/
public static ServiceLocator getInstance() {
- if (theInstance == null) {
- theInstance = new ServiceLocatorImpl();
- }
return theInstance;
}
* Set the studyService.
* @param studyService the studyService to set
*/
- public void setStudyService(StudyService studyService) {
+ public void setStudyService(final StudyService studyService) {
_studyService = studyService;
}
* Set the userService.
* @param userService the userService to set
*/
- public void setUserService(UserService userService) {
+ public void setUserService(final UserService userService) {
_userService = userService;
}
}
* @throws InvalidPropertyException
* if the given state is invalid
*/
- public Vector<SimulationContextFacade> getSimulationContextsInState(
+ Vector<SimulationContextFacade> getSimulationContextsInState(
ProgressState aState) throws InvalidPropertyException;
/**
* simulation context id.
* @return found context
*/
- public SimulationContext selectSimulationContext(long index);
+ SimulationContext selectSimulationContext(long index);
/**
* Find simulation context by its type and value.
* context value
* @return found context
*/
- public SimulationContext selectSimulationContext(
+ SimulationContext selectSimulationContext(
SimulationContextType celt, String value);
/**
* example properties
* @return list of contexts
*/
- public List<SimulationContext> selectSimulationContextsWhere(
+ List<SimulationContext> selectSimulationContextsWhere(
SimulationContext.Properties cprop);
/**
*
* @return list of context types
*/
- public List<SimulationContextType> selectAllTypes();
+ List<SimulationContextType> selectAllTypes();
/**
* Get simulation context types related to given activities.
* the activity
* @return list of found context types
*/
- public List<SimulationContextType> selectTypesOf(
+ List<SimulationContextType> selectTypesOf(
ProjectSettingsService.Step... step);
/**
* the example
* @return list of found context types
*/
- public List<SimulationContextType> selectTypesWhere(
+ List<SimulationContextType> selectTypesWhere(
SimulationContextType.Properties sprop);
/**
* name of the context type
* @return found context type
*/
- public SimulationContextType selectType(String name);
+ SimulationContextType selectType(String name);
/**
* Get simulation context type by its id.
* simulation context type id.
* @return found context type
*/
- public SimulationContextType selectType(long index);
+ SimulationContextType selectType(long index);
/**
* Hold the simulation context.
* @param simCtx
* the context to hold.
*/
- public void hold(SimulationContext simCtx);
+ void hold(SimulationContext simCtx);
/**
* Release the simulation context.
* @param simCtx
* the context to release
*/
- public void release(SimulationContext simCtx);
+ void release(SimulationContext simCtx);
/**
* Get the simulation context list for displaying drop-down list values populating on the "Create new study" screen.
* @param simCtxType
* @return
*/
- public ProjectSettingsService.Step getAttachedStep(
+ ProjectSettingsService.Step getAttachedStep(
SimulationContextType simCtxType);
}
/**
* logger for the service.
*/
- public final static AppLogger logger = AppLogger
+ public final static AppLogger LOG = AppLogger
.getLogger(SimulationContextServiceImpl.class);
+
+ /**
+ * Step property name.
+ */
+ public final static String STEP_PROP = "step";
+
/**
* Injected simulation context DAO.
*/
/**
* Injected project settings service.
*/
- private ProjectSettingsService _projectSettingsService;
+ private ProjectSettingsService _projectSettings;
/**
* Get simulation contexts which are currently in the given state.
result = clist.get(0); // Supposed being the most used one if many exist
}
} catch (InvalidPropertyException error) {
- logger.info("Attempt to select a simulation context \""
+ LOG.info("Attempt to select a simulation context \""
+ celt.getName() + "\" with an invalid value.");
}
return result;
public List<SimulationContextType> selectAllTypes() {
// Useless to order by names as the result mixes localized
// and non localized types
- return getSimulationContextTypeDAO().getAll(Order.asc("step"));
+ return getSimulationContextTypeDAO().getAll(Order.asc(STEP_PROP));
}
/**
// .append("'");
// }
// query = query.append(" order by step asc");
- Criterion aCondition = Restrictions.eq("step", step[0].getNumber());
+ Criterion aCondition = Restrictions.eq(STEP_PROP, step[0].getNumber());
for (int i = 1; i < step.length; i++) { // Useless to order as the result mixes localized and non localized types
- aCondition = Restrictions.or(aCondition, Restrictions.eq("step",
+ aCondition = Restrictions.or(aCondition, Restrictions.eq(STEP_PROP,
step[i].getNumber()));
}
return getSimulationContextTypeDAO().getFilteredList(aCondition,
- Order.asc("step"));
+ Order.asc(STEP_PROP));
}
/**
// }
// query = query.append(order);
Criterion aCondition = null;
- Order anOrder = Order.asc("step");
+ Order anOrder = Order.asc(STEP_PROP);
if (step != null) {
- aCondition = Restrictions.eq("step", step.getNumber());
+ aCondition = Restrictions.eq(STEP_PROP, step.getNumber());
anOrder = Order.desc("state"); // APPROVED (upper case A) is grater than inCHECK (lower case i)
}
if (state != null) {
aCondition = Restrictions.and(aCondition, Restrictions.eq("state",
state));
if (step != null) {
- if (state != ProgressState.APPROVED) {
- anOrder = Order.asc("name");
- } else {
+ if (state == ProgressState.APPROVED) {
anOrder = null; // Approved types are localized
+ } else {
+ anOrder = Order.asc("name");
}
}
}
* @return true if approval succeeded
*/
public boolean approve(final SimulationContext simCtx) {
- if (simCtx.getProgressState() != ProgressState.inCHECK) {
- return false;
- }
- simCtx.setProgressState(ProgressState.APPROVED); // The type name is supposed being localized
- if (simCtx.isSaved()) {
- getSimulationContextDAO().update(simCtx);
+ boolean res = (simCtx.getProgressState() == ProgressState.inCHECK);
+ if (res) {
+ simCtx.setProgressState(ProgressState.APPROVED); // The type name is supposed being localized
+ if (simCtx.isSaved()) {
+ getSimulationContextDAO().update(simCtx);
+ }
}
- return true;
+ return res;
}
/**
* @return Project settings service
*/
private ProjectSettingsService getProjectSettings() {
- return _projectSettingsService;
+ return _projectSettings;
}
/**
* project settings service
*/
public void setProjectSettings(final ProjectSettingsService projectSettingsService) {
- _projectSettingsService = projectSettingsService;
+ _projectSettings = projectSettingsService;
}
}
* @throws InvalidPropertyException
* if some property of the type to be created is invalid
*/
- public SimulationContextType createType(String name,
+ SimulationContextType createType(String name,
ProjectSettingsService.Step step) throws InvalidPropertyException;
/**
* the type to approve
* @return true if approval succeeded
*/
- public boolean approve(SimulationContextType simCtxType);
+ boolean approve(SimulationContextType simCtxType);
}
* @throws IOException
* if a file system error occurs
*/
- public Publication createDocument(Step aStep, Document.Properties dprop)
+ Publication createDocument(Step aStep, Document.Properties dprop)
throws MissedPropertyException, InvalidPropertyException,
MultiplyDefinedException, IOException;
* @throws NotApplicableException
* if the document is undefined
*/
- public Publication assignDocument(Step aStep, Document.Properties dprop)
+ Publication assignDocument(Step aStep, Document.Properties dprop)
throws MissedPropertyException, InvalidPropertyException,
NotApplicableException;
* @throws MismatchException
* if the document is not applicable to the given study step
*/
- public Publication versionDocument(Step aStep, Publication base,
+ Publication versionDocument(Step aStep, Publication base,
Document.Properties dprop) throws MissedPropertyException,
InvalidPropertyException, MultiplyDefinedException, IOException,
MismatchException;
* @throws MultiplyDefinedException
* if some property is defined several times
*/
- public SimulationContext addSimulationContext(Step aStep,
+ SimulationContext addSimulationContext(Step aStep,
SimulationContext.Properties dprop) throws MissedPropertyException,
InvalidPropertyException, MultiplyDefinedException;
* the simulation context to add
* @return the added simulation context
*/
- public SimulationContext addSimulationContext(Step firstStep,
+ SimulationContext addSimulationContext(Step firstStep,
SimulationContext context);
/**
* the simulation context to remove
* @return true if removal succeeded
*/
- public boolean removeSimulationContext(Step aStep, SimulationContext context);
+ boolean removeSimulationContext(Step aStep, SimulationContext context);
/**
* Add a document publication to the given step.
* the document publication to add
* @return true if publication succeeded
*/
- public boolean add(Step aStep, Publication newdoc);
+ boolean add(Step aStep, Publication newdoc);
/**
* Remove a document publication from the given step.
* the document publication to remove
* @return true if removing of the publication succeeded
*/
- public boolean remove(Step aStep, Publication oldoc);
+ boolean remove(Step aStep, Publication oldoc);
/**
* Remove a document from the given step.
* the document publication
* @return true if removing of the document succeeded
*/
- public boolean removeDocument(Step aStep, Publication doctag);
+ boolean removeDocument(Step aStep, Publication doctag);
/**
* Get document types which are applicable for the given study step (activity).
* the study step
* @return the list of document types
*/
- public List<DocumentType> getValidDocumentTypes(Step aStep);
+ List<DocumentType> getValidDocumentTypes(Step aStep);
}
package org.splat.service;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import java.util.Vector;
import org.splat.dal.bo.kernel.Relation;
import org.splat.dal.bo.som.ConvertsRelation;
/**
* logger for the service.
*/
- public final static AppLogger logger = AppLogger
+ public final static AppLogger LOG = AppLogger
.getLogger(StepServiceImpl.class);
/**
* Injected index service.
/**
* Injected project service.
*/
- private ProjectSettingsService _projectSettingsService;
+ private ProjectSettingsService _projectSettings;
/**
* {@inheritDoc}
@Transactional
public SimulationContext addSimulationContext(final Step aStep,
final SimulationContext context) {
+ SimulationContext res = null;
getSimulationContextService().hold(context); // Increments the reference count of simulation context
if (aStep.getOwner().isSaved()) {
try {
aStep.getContex().add(context); // The context is also referenced from this (transient) Step
getProjectElementDAO().update(aStep.getOwner());
updateKnowledgeElementsIndex(aStep);
+ res = context;
} catch (Exception error) {
- return null;
+ LOG.debug(error.getMessage(), error);
}
} else { // Happens when copying a scenario
aStep.getOwner().add(context);
aStep.getContex().add(context); // The context is also referenced from this (transient) Step
// In case of owner scenario, the Knowledge Element index will be updated later, when saving the scenario
+ res = context;
}
- return context;
+ return res;
}
/**
updateScenarioIndex(scene);
}
} catch (Exception error) {
- logger.error("Unable to re-index Knowledge Elements, reason:",
+ LOG.error("Unable to re-index Knowledge Elements, reason:",
error);
}
}
*/
@Transactional
public boolean removeSimulationContext(final Step aStep, final SimulationContext context) {
- boolean isOk = false;
SimulationContext torem = aStep
.getSimulationContext(context.getIndex());
- if ((torem != null) && (aStep.getOwner().remove(torem))) {
+ boolean isOk = (torem != null) && (aStep.getOwner().remove(torem));
+ if (isOk) {
aStep.getContex().remove(torem);
getProjectElementDAO().update(aStep.getOwner());
} else {
getSimulationContextDAO().delete(torem);
}
- isOk = true;
}
return isOk;
}
// Creation of the save directory
java.io.File wdir = getDocumentService().getSaveDirectory(newdoc);
- if (!wdir.exists()) {
- if (!wdir.mkdirs()) {
- throw new IOException(
- "Cannot create the repository vault directory");
- }
+ if ((!wdir.exists()) && (!wdir.mkdirs())) {
+ throw new IOException(
+ "Cannot create the repository vault directory");
}
// Identification and save
*
* @see org.splat.service.StepService#assignDocument(org.splat.som.Step, org.splat.dal.bo.som.Document.Properties)
*/
- public Publication assignDocument(final Step aStep, final Document.Properties dprop)
- throws MissedPropertyException, InvalidPropertyException,
- NotApplicableException {
+ public Publication assignDocument(final Step aStep,
+ final Document.Properties dprop) throws MissedPropertyException,
+ InvalidPropertyException, NotApplicableException {
String refid = dprop.getReference();
- if (refid == null) {
- return null;
- }
-
- Document slot = getDocumentService().selectDocument(refid,
- new Revision().toString());
- if (slot == null) {
- return null;
- }
- if (!slot.isUndefined()) {
- return null; // Should not happen
+ Publication res = null;
+ if (refid != null) {
+ Document slot = getDocumentService().selectDocument(refid,
+ new Revision().toString());
+ if ((slot != null) && (slot.isUndefined())) {
+ getDocumentService().initialize(slot,
+ dprop.setOwner(aStep.getOwnerStudy()));
+ res = new Publication(slot, aStep.getOwner());
+ }
}
-
- getDocumentService().initialize(slot,
- dprop.setOwner(aStep.getOwnerStudy()));
- return new Publication(slot, aStep.getOwner());
+ return res;
}
/**
* @return true if publication succeeded
*/
public boolean add(final Step aStep, final Publication newdoc) {
- if (!aStep.getOwner().add(newdoc)) {
- return false; // Updates the study in memory
+ boolean res = aStep.getOwner().add(newdoc); // Updates the study in memory
+ if (res) {
+ aStep.getDocuments().add(0, newdoc); // Updates this step
+ getDocumentService().hold(newdoc.value()); // Increments the configuration tag count of document
+ // If not yet saved, the Publication MUST NOT be saved here, although this creates a temporary inconsistent state into the
+ // database (it will be saved later by cascading the update of owner scenario).
}
- aStep.getDocuments().add(0, newdoc); // Updates this step
- getDocumentService().hold(newdoc.value()); // Increments the configuration tag count of document
- // If not yet saved, the Publication MUST NOT be saved here, although this creates a temporary inconsistent state into the
- // database (it will be saved later by cascading the update of owner scenario).
- return true;
+ return res;
}
/**
* @return true if removing of the publication succeeded
*/
public boolean remove(final Step aStep, final Publication oldoc) {
- if (!aStep.getOwner().remove(oldoc)) {
- return false; // Updates the study in memory
+ boolean res = aStep.getOwner().remove(oldoc); // Updates the study in memory
+ if (res) {
+ aStep.getDocuments().remove(oldoc); // Updates this step
+ getDocumentService().release(oldoc.value()); // Decrements the configuration tag count of document
+ // The publication becoming orphan, it should automatically be removed from the database when updating of owner scenario.
}
- aStep.getDocuments().remove(oldoc); // Updates this step
- getDocumentService().release(oldoc.value()); // Decrements the configuration tag count of document
- // The publication becoming orphan, it should automatically be removed from the database when updating of owner scenario.
- return true;
+ return res;
}
/**
getDocumentDAO().update(value);
Publication torem = aStep.getDocument(value.getIndex());
- if (torem == null) {
- return false;
- }
-
- remove(aStep, torem);
- getProjectElementDAO().update(aStep.getOwner());
- if (!value.isPublished() && !value.isVersioned()) { // The referenced document is no more used
- Set<Relation> links = value.getAllRelations(); // Get all relation of the document to remove them
- List<Document> using = new Vector<Document>();
- for (Iterator<Relation> i = links.iterator(); i.hasNext();) {
- Relation link = i.next();
- if (link.getClass().equals(ConvertsRelation.class)) { // File conversion
- getFileDAO().delete((File) link.getTo()); // The corresponding physical file is not removed from the vault
- } else if (link.getClass().equals(UsesRelation.class)) { // Document dependency
- using.add((Document) link.getTo());
+ boolean res = (torem != null);
+ if (res) {
+ remove(aStep, torem);
+ getProjectElementDAO().update(aStep.getOwner());
+ if (!value.isPublished() && !value.isVersioned()) { // The referenced document is no more used
+ Set<Relation> links = value.getAllRelations(); // Get all relation of the document to remove them
+ List<Document> using = new ArrayList<Document>();
+ for (Iterator<Relation> i = links.iterator(); i.hasNext();) {
+ Relation link = i.next();
+ if (link.getClass().equals(ConvertsRelation.class)) { // File conversion
+ getFileDAO().delete((File) link.getTo()); // The corresponding physical file is not removed from the vault
+ } else if (link.getClass().equals(UsesRelation.class)) { // Document dependency
+ using.add((Document) link.getTo());
+ }
}
+ for (Iterator<Document> i = using.iterator(); i.hasNext();) {
+ i.next().removeRelation(UsedByRelation.class, value); // TODO: RKV: don't use Database.getSession in removeRelation
+ }
+ getDocumentDAO().delete(value); // The corresponding physical file is not removed from the vault
}
- for (Iterator<Document> i = using.iterator(); i.hasNext();) {
- i.next().removeRelation(UsedByRelation.class, value); // TODO: RKV: don't use Database.getSession in removeRelation
- }
- getDocumentDAO().delete(value); // The corresponding physical file is not removed from the vault
}
- return true;
+ return res;
}
/**
* @return Project settings service
*/
private ProjectSettingsService getProjectSettings() {
- return _projectSettingsService;
+ return _projectSettings;
}
/**
*/
public void setProjectSettings(
final ProjectSettingsService projectSettingsService) {
- _projectSettingsService = projectSettingsService;
+ _projectSettings = projectSettingsService;
}
}
import org.splat.dal.bo.kernel.User;
import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.Publication;
-import org.splat.dal.bo.som.Scenario;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.Study;
import org.splat.dal.bo.som.ValidationCycle;
* the study
* @return incremented docount value
*/
- public int generateLocalIndex(Study aStudy);
+ int generateLocalIndex(Study aStudy);
/**
* Get study by its id.
* the study id
* @return found study or null
*/
- public Study selectStudy(long index);
+ Study selectStudy(long index);
/**
* Create a new study.
* @throws MultiplyDefinedException
* if some property is defined several times
*/
- public Study createStudy(Study.Properties sprop)
+ Study createStudy(Study.Properties sprop)
throws MissedPropertyException, InvalidPropertyException,
MultiplyDefinedException;
* @throws MultiplyDefinedException
* if some property occurs several times
*/
- public SimulationContext addProjectContext(Study aStudy,
+ SimulationContext addProjectContext(Study aStudy,
SimulationContext.Properties cprop) throws MissedPropertyException,
InvalidPropertyException, MultiplyDefinedException;
* the simulation context to add
* @return the added simulation context
*/
- public SimulationContext addProjectContext(Study aStudy,
+ SimulationContext addProjectContext(Study aStudy,
SimulationContext context);
/**
* the simulation context to remove
* @return true if removing succeeded
*/
- public boolean removeProjectContext(Study aStudy, SimulationContext context);
+ boolean removeProjectContext(Study aStudy, SimulationContext context);
/**
* Demotes this study from In-Check to In-Draft then In-Work states. This function is called internally when demoting the final result
* the study to demote
* @return true if the demotion succeeded.
*/
- public boolean demote(Study aStudy);
+ boolean demote(Study aStudy);
/**
* Promotes this study from In-Work to In-Draft then In-Check and APPROVED states. This function is called internally when promoting the
* the study to promote
* @return true if the promotion succeeded.
*/
- public boolean promote(Study aStudy);
+ boolean promote(Study aStudy);
/**
* Add a contributor to the study.
* the contributor
* @return true if addition succeeded
*/
- public boolean addContributor(Study aStudy, User user);
+ boolean addContributor(Study aStudy, User user);
/**
* Remove contributors from the study.
* contributor(s)
* @return true if removing succeeded
*/
- public boolean removeContributor(Study aStudy, User... users);
+ boolean removeContributor(Study aStudy, User... users);
/**
* Set a validation cycle for documents of the given type in the given study.
* @param vprop
* validation cycle properties
*/
- public void setValidationCycle(Study aStudy, DocumentType type,
+ void setValidationCycle(Study aStudy, DocumentType type,
ValidationCycle.Properties vprop);
/**
* @return true if the move succeeded.
* @see #isPublic()
*/
- public boolean moveToPublic(Study aStudy);
+ boolean moveToPublic(Study aStudy);
/**
* Moves this study from the Public to the Reference area of the repository. For being moved to the Reference area, the study must
* @see #isPublic()
* @see Publication#approve(Date)
*/
- public boolean moveToReference(Study aStudy);
+ boolean moveToReference(Study aStudy);
/**
* Update a study.
* @throws InvalidPropertyException
* if some property doesn't exist
*/
- public boolean update(Study aStudy, Properties sprop)
+ boolean update(Study aStudy, Properties sprop)
throws InvalidPropertyException;
/**
* @param aStudy
* the study
*/
- public void loadWorkflow(Study aStudy);
+ void loadWorkflow(Study aStudy);
/**
* Returns the validation cycle of the given document type.
* the document type being subject of validation
* @return the validation cycle of the document, or null if not defined.
*/
- public ValidationCycle getValidationCycleOf(Study aStudy, DocumentType type);
+ ValidationCycle getValidationCycleOf(Study aStudy, DocumentType type);
/**
* Checks if the given user participates to this study. The Study staff includes the author and contributors.
* @return true if the given user is actor of this study.
* @see #getContributors()
*/
- public boolean isStaffedBy(Study aStudy, User user);
+ boolean isStaffedBy(Study aStudy, User user);
/**
* Checks if the given user is actor of this study. Actors include contributors, reviewers and approvers.
* @return true if the given user is actor of this study.
* @see #getActors()
*/
- public boolean hasActor(Study aStudy, User user);
+ boolean hasActor(Study aStudy, User user);
/**
* Returns unmodifiable initialized transient list of contributors of this study.
* the study
* @return the unmodifiable not null transient list of contributors of this study
*/
- public List<User> getContributors(Study aStudy);
+ List<User> getContributors(Study aStudy);
}
import org.splat.dal.bo.som.ActorRelation;
import org.splat.dal.bo.som.ContributorRelation;
import org.splat.dal.bo.som.DescriptionAttribute;
-import org.splat.dal.bo.som.Document;
import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.IDBuilder;
import org.splat.dal.bo.som.KnowledgeElement;
/**
* logger for the service.
*/
- public final static AppLogger logger = AppLogger
+ public final static AppLogger LOG = AppLogger
.getLogger(StudyServiceImpl.class);
/**
IndexService lucin = getIndex();
lucin.add(study);
} catch (IOException error) {
- logger.error("Unable to index the study '" + study.getIndex()
+ LOG.error("Unable to index the study '" + study.getIndex()
+ "', reason:", error);
// Continue and try to index later
}
* the document
* @return true if the document is published in the study
*/
- private boolean publishes(final Study aStudy, final Document doc) {
+/* private boolean publishes(final Study aStudy, final Document doc) {
if (!aStudy.publishes(doc)) {
Scenario[] scene = aStudy.getScenarii();
for (int i = 0; i < scene.length; i++) {
}
return false;
}
-
+*/
/**
* {@inheritDoc}
*
* org.splat.dal.bo.som.ValidationCycle.Properties)
*/
@Transactional
- public void setValidationCycle(final Study aStudy, final DocumentType type,
+ public void setValidationCycle(final Study aStudyDTO, final DocumentType type,
final ValidationCycle.Properties vprop) {
- Map<String, ValidationCycle> validactor = aStudy.getValidationCycles();
+ Map<String, ValidationCycle> validactor = aStudyDTO.getValidationCycles();
if (validactor == null) {
- setShortCuts(aStudy); // Initializes validactor and actor
+ setShortCuts(aStudyDTO); // Initializes validactor and actor
}
+ Study aStudy = selectStudy(aStudyDTO.getIndex());
+
String cname = type.getName();
ValidationCycle cycle = validactor.get(cname);
ValidationCycleRelation link = cycle.getContext();
// RKV: aStudy.addRelation(link);
- aStudy.getAllRelations().add(link); // RKV
+ aStudyDTO.getAllRelations().add(link); // RKV
validactor.put(cname, link.getTo()); // Replaces the cycle if exists as default,
} catch (Exception error) {
- logger.error("Unable to re-index Knowledge Elements, reason:",
+ LOG.error("Unable to re-index Knowledge Elements, reason:",
error);
return;
}
}
- resetActorsShortCut(aStudy);
+ resetActorsShortCut(aStudyDTO);
update(aStudy); // Re-index the study, just in case
}
getIndex().update(aStudy); // Update of Lucene index
isOk = true;
} catch (Exception e) {
- logger.error("STD-000001", e, aStudy.getIndex(), e.getMessage());
+ LOG.error("STD-000001", e, aStudy.getIndex(), e.getMessage());
}
return isOk;
}
break;
}
}
- SimpleDateFormat tostring = new SimpleDateFormat("yyyy");
+ SimpleDateFormat tostring = new SimpleDateFormat("yyyy"); //RKV: NOPMD: TODO: Use locale here?
String year = tostring.format(study.getDate());
year = year.substring(4 - (i - n), 4); // 4-(i-n) must be equal to either 0 or 2
for (int j = 0; j < year.length(); j++) {
}
isOk = true;
} catch (Exception error) {
- logger.error("Unable to re-index Knowledge Elements, reason:",
+ LOG.error("Unable to re-index Knowledge Elements, reason:",
error);
}
return isOk;
*/
public interface UserService {
- public User createUser(User.Properties uprop)
+ User createUser(User.Properties uprop)
throws MissedPropertyException, InvalidPropertyException,
MultiplyDefinedException;
- public Set<User> importUsers(File xfile) throws XMLException,
+ Set<User> importUsers(File xfile) throws XMLException,
MismatchException;
/**
* the user whose manager is get
* @return the manager of the given user, if defined
*/
- public User getManagerOf(User user);
+ User getManagerOf(User user);
- public List<User> selectAllUsers();
+ List<User> selectAllUsers();
- public User selectUser(String username);
+ User selectUser(String username);
- public User selectUser(String username, String password);
+ User selectUser(String username, String password);
- public User selectUser(long index);
+ User selectUser(long index);
- public List<User> selectUsersWhere(User.Properties... uprop);
+ List<User> selectUsersWhere(User.Properties... uprop);
}
/**
* The service logger.
*/
- final static Logger logger = Logger.getLogger(UserServiceImpl.class);
+ protected final static Logger LOG = Logger.getLogger(UserServiceImpl.class);
/**
* Injected user DAO.
* @see org.splat.service.UserService#createUser(org.splat.dal.bo.kernel.User.Properties)
*/
@Transactional
- public User createUser(User.Properties uprop)
+ public User createUser(final User.Properties uprop)
throws MissedPropertyException, InvalidPropertyException,
MultiplyDefinedException, RuntimeException {
User nuser = new User(uprop);
// For the casting List<String>
@Transactional
- public Set<User> importUsers(File xfile) throws XMLException,
+ public Set<User> importUsers(final File xfile) throws XMLException,
MismatchException {
String[] name = xfile.getName().split("\\x2E"); // Split by '.' (period) character
String fext = name[name.length - 1];
- if (!fext.equals("xml"))
+ if (!fext.equals("xml")) {
throw new MismatchException("filetype");
+ }
try {
DocumentBuilderFactory dfactory = javax.xml.parsers.DocumentBuilderFactory
.newInstance();
DocumentBuilder dBuilder = dfactory.newDocumentBuilder();
org.w3c.dom.Document inDoc = dBuilder.parse(xfile);
String xtag = inDoc.getDocumentElement().getNodeName();
- if (!xtag.equals("users"))
+ if (!xtag.equals("users")) {
throw new MismatchException("filetype");
+ }
org.w3c.dom.NodeList ulist = inDoc.getElementsByTagName("user");
// List<String> result = (List<String>) session
List<User> users = getUserDAO().getAll();
HashSet<String> members = new HashSet<String>();
HashSet<User> imported = new HashSet<User>();
- for (Iterator<User> i = users.iterator(); i.hasNext();)
+ for (Iterator<User> i = users.iterator(); i.hasNext();) {
members.add(i.next().getUsername());
+ }
for (int i = 0; i < ulist.getLength(); i++) {
HashMap<String, Node> row = XDOM.getNamedChildNodes(ulist
// Mandatory properties
String uname = row.get("username").getTextContent();
- if (members.contains(uname))
+ if (members.contains(uname)) {
continue; // This user already exists
+ }
uprop.setUsername(uname)
.setFirstName(row.get("first").getTextContent())
.setName(row.get("last").getTextContent())
}
return imported;
} catch (IOException error) {
- throw new XMLException("XML users file not found");
+ LOG.debug(error.getMessage(), error);
+ throw new XMLException("XML users file not found"); //RKV: NOPMD: Original message is printed
} catch (ParserConfigurationException e) {
- throw new XMLException("XML Organization parser not accessible");
+ LOG.debug(e.getMessage(), e);
+ throw new XMLException("XML Organization parser not accessible"); //RKV: NOPMD: Original message is printed
} catch (Exception e) {
- throw new XMLException("XML users file not valid");
+ LOG.debug(e.getMessage(), e);
+ throw new XMLException("XML users file not valid"); //RKV: NOPMD: Original message is printed
}
}
* the user whose manager is get
* @return the manager of the given user, if defined
*/
- public User getManagerOf(User user) {
+ public User getManagerOf(final User user) {
User result = null;
String orgname = user.getOrganizationName();
- if (orgname.equals("Nx2"))
+ if (orgname.equals("Nx2")) {
return result;
- if (orgname.equals("Nx1"))
+ }
+ if (orgname.equals("Nx1")) {
orgname = "Nx2";
- else {
- if (user.getRoleNames().equals("customer"))
+ } else {
+ if (user.getRoleNames().equals("customer")) {
return result;
+ }
orgname = "Nx1";
}
try {
}
@Transactional(readOnly = true)
- public User selectUser(String username) {
+ public User selectUser(final String username) {
return getUserDAO().findByCriteria(
Restrictions.eq("username", username));
}
- public User selectUser(String username, String password) {
+ public User selectUser(final String username, final String password) {
// WARNING: For not encoding the password here, we better call a selectUsersWhere(User.Properties),
// but this requires a getPassword in User.Properties nested class.
Criterion aCondition = Restrictions.eq("username", username);
}
@Transactional(readOnly = true)
- public User selectUser(long index) {
+ public User selectUser(final long index) {
return getUserDAO().get(index);
}
@SuppressWarnings("unchecked")
- public List<User> selectUsersWhere(User.Properties... uprop) {
+ public List<User> selectUsersWhere(final User.Properties... uprop) {
// StringBuffer query = new StringBuffer("FROM User");
// String separator = " where (";
// String value;
* @param userDAO
* the userDAO to set
*/
- public void setUserDAO(UserDAO userDAO) {
+ public void setUserDAO(final UserDAO userDAO) {
_userDAO = userDAO;
}
}
package org.splat.service;
-import java.util.Map;
-
import org.splat.log.AppLogger;
-import org.splat.som.ApplicationRights;
/**
* @author Maria KRUCHININA
/**
* logger for the service.
*/
- private static final AppLogger LOG = AppLogger.getLogger(UtilServiceImpl.class);
+ private static final AppLogger LOG = AppLogger.getLogger(UtilServiceImpl.class); //RKV: NOPMD: TODO: Complete the service
/**
* Get the connected user.
/**
* Type name.
*/
- private String name;
+ private String _name;
/**
* Persistent id of the type.
*/
- private long rid;
+ private long _index;
// ==============================================================================================================================
// Public member functions
*
* @see java.lang.Object#equals(java.lang.Object)
*/
- public boolean equals(Object entity) {
- if (entity == null)
- return false;
- if (entity instanceof String) {
- return this.name.equals((String) entity); // Names are unique
- } else if (entity instanceof KnowledgeElementTypeDTO) {
- KnowledgeElementTypeDTO object = (KnowledgeElementTypeDTO) entity;
- long he = object.getIndex();
- long me = this.getIndex();
- if (me * he != 0) {
- return (he == me);
- } else {
- return this.getName().equals(object.getName());
+ @Override
+ public boolean equals(final Object entity) {
+ boolean res = (entity != null);
+ if (res) {
+ if (entity instanceof String) {
+ res = this._name.equals(entity); // Names are unique
+ } else if (entity instanceof KnowledgeElementTypeDTO) {
+ KnowledgeElementTypeDTO object = (KnowledgeElementTypeDTO) entity;
+ long he = object.getIndex();
+ long me = this.getIndex();
+ if (me * he == 0) {
+ res = this.getName().equals(object.getName());
+ } else {
+ res = (he == me);
+ }
}
- } else {
- return false;
}
+ return res;
}
+ /**
+ * {@inheritDoc}
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ long oid = getIndex(); // getIndex() is supposed fetching the index if not yet done
+ if (oid == 0) {
+ oid = super.hashCode(); // WARNING: Must not call super.toString() as it goes back here (this.toString())
+ }
+ return new StringBuffer("object ").append(getClass().getName()).append(
+ "@").append(oid).toString().hashCode();
+ }
+
/**
* Get the name of the knowledge type.
*
* @return the type name
*/
public String getName() {
- return name;
+ return _name;
}
/**
* @return the rid
*/
public long getIndex() {
- return rid;
+ return _index;
}
/**
* @param rid
* the rid to set
*/
- public void setIndex(long rid) {
- this.rid = rid;
+ public void setIndex(final long rid) {
+ this._index = rid;
}
/**
* Set the name.
* @param name the name to set
*/
- public void setName(String name) {
- this.name = name;
+ public void setName(final String name) {
+ this._name = name;
}
}
\ No newline at end of file
package org.splat.service.dto;
import org.splat.dal.bo.som.ProgressState;
-import org.splat.dal.dao.som.Database;
-
-
import org.splat.service.technical.IndexServiceImpl;
-import org.splat.dal.bo.som.KnowledgeElement;
-import org.splat.dal.bo.som.ProgressState;
-import org.splat.dal.bo.som.Study;
-import org.splat.dal.bo.som.Study.Properties;
/**
* Stand proxy for entities such as Study and Knowledge Element returned by Lucene-based searches.
* One of these properties is the internal persistent identifier of the object represented by a proxy allowing the
* user of this interface to load the object from the database.
*
- * @see Database#selectStudiesWhere(Study.Properties...)
- * @see Database#selectKnowledgeElementsWhere(KnowledgeElement.Properties)
- * @see Database#selectStudy(int)
- * @see Database#selectKnowledgeElement(int)
* @see IndexServiceImpl
* @see IndexServiceImpl.ObjectProxy
* @author Daniel Brunier-Coulin
public interface Proxy {
- public String getAuthorName ();
+ String getAuthorName ();
/**
* Returns the internal persistent identifier of the object represented by this proxy. The returned identifier can be used
* for selecting the corresponding persistent object from the database.
* @return the internal persistent identifier of the object represented by this proxy.
*/
- public Long getIndex ();
+ Long getIndex ();
- public ProgressState getProgressState ();
+ ProgressState getProgressState ();
/**
* Returns the external reference number of the object represented by this proxy. The returned reference is formated
* according to the format defined in the configuration file of the application.
* @return the external reference number of the object represented by this proxy.
*/
- public String getReference ();
+ String getReference ();
- public String getTitle ();
+ String getTitle ();
/**
* Returns the type of the object represented by this proxy. Depending on the implementation, the returned type may or
* may not be localized in the current locale of final user.
* @return the type of the object represented by this proxy.
*/
- public String getType ();
+ String getType ();
}
\ No newline at end of file
package org.splat.service.dto;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
/**
- * Role DTO.
+ * DTO for keeping roles of a user.
*
* @see UserDTO
*/
public class RoleDTO {
- private String username;
- private String role;
+ /**
+ * User name.
+ */
+ private transient String _username;
+ /**
+ * Roles names.
+ */
+ private String _name;
// ==============================================================================================================================
// Constructors
// ==============================================================================================================================
- // Database fetch constructor
+ /**
+ * Bean replication constructor.
+ */
protected RoleDTO() {
+ // Bean replication constructor
}
- // Initialization constructor
- protected RoleDTO(String username, String role) {
- this.username = username;
- this.role = role;
+ /**
+ * Initialization constructor.
+ * @param username user name
+ * @param role role name
+ */
+ protected RoleDTO(final String username, final String role) {
+ this._username = username;
+ this._name = role;
}
// ==============================================================================================================================
// Protected member functions
// ==============================================================================================================================
- protected void addRole(String role) {
- this.role = this.role + "," + role;
+ /**
+ * Add a role.
+ * @param role the role to add
+ */
+ protected void addRole(final String role) {
+ this._name = this._name + "," + role;
}
+ /**
+ * Get roles as an array of separate DTOs.
+ * @return array of roles
+ */
protected RoleDTO[] toArray() {
- String[] name = role.split(",");
- Vector<RoleDTO> role = new Vector<RoleDTO>();
+ String[] name = _name.split(",");
+ List<RoleDTO> role = new ArrayList<RoleDTO>();
- for (int i = 0; i < name.length; i++)
- role.add(new RoleDTO(username, name[i]));
+ for (int i = 0; i < name.length; i++) {
+ role.add(new RoleDTO(_username, name[i]));
+ }
return role.toArray(new RoleDTO[name.length]);
}
// In functions below, the role is supposed having previously been extracted as an array.
public String getName() {
- return role;
+ return _name;
}
public void setName(final String name) {
- role = name;
+ _name = name;
}
- public boolean is(String name) {
- return this.role.equals(name);
+ public boolean is(final String name) {
+ return this._name.equals(name);
}
- public boolean isSame(RoleDTO other) {
- return this.role.equals(other.role);
+ public boolean isSame(final RoleDTO other) {
+ return this._name.equals(other._name);
}
}
\ No newline at end of file
import java.util.Iterator;
import java.util.List;
-import org.splat.service.technical.ProjectSettingsService;
import org.splat.dal.bo.som.ProgressState;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.SimulationContextType;
+import org.splat.service.technical.ProjectSettingsService;
public class SimulationContextFacade {
- private SimulationContext my;
- private String name;
- private int at;
- private ProgressState state;
+ private transient final SimulationContext _my;
+ private transient final String _name;
+ private transient int _at;
+ private transient ProgressState _state;
// ==============================================================================================================================
// Constructor
// ==============================================================================================================================
- public SimulationContextFacade(SimulationContext represented,
- List<ProjectSettingsService.Step> steps) {
+ public SimulationContextFacade(final SimulationContext represented,
+ final List<ProjectSettingsService.Step> steps) {
// --------------------------------------------------------------
SimulationContextType mytype;
- my = represented;
- mytype = my.getType();
+ _my = represented;
+ mytype = _my.getType();
for (Iterator<ProjectSettingsService.Step> i = steps.iterator(); i
.hasNext();) {
ProjectSettingsService.Step step = i.next();
- if (!mytype.isAttachedTo(step))
+ if (!mytype.isAttachedTo(step)) {
continue;
- at = step.getNumber(); // There is no direct service for getting the step number
+ }
+ _at = step.getNumber(); // There is no direct service for getting the step number
break;
}
- name = my.getType().getName();
+ _name = _my.getType().getName();
if (mytype.isApproved()) {
- state = ProgressState.inCHECK;
+ _state = ProgressState.inCHECK;
// RKV: TODO: Do translation in presentation layer by struts tools: name = ResourceBundle.getBundle("som",
// ApplicationSettings.getCurrentLocale()).getString("type.context." + name);
} else {
- state = ProgressState.inDRAFT;
+ _state = ProgressState.inDRAFT;
}
}
public String getEditIcon() {
// ----------------------------
- StringBuffer result = new StringBuffer("icon.ed").append(state).append(
+ StringBuffer result = new StringBuffer("icon.ed").append(_state).append(
".png");
return result.toString();
}
public String getIndex() {
// -------------------------
- return String.valueOf(my.getIndex());
+ return String.valueOf(_my.getIndex());
}
public int getStepNumber() {
// ---------------------------
- return at;
+ return _at;
}
public String getTypeName() {
// ----------------------------
- return name;
+ return _name;
}
public String getValue() {
// -------------------------
- return my.getValue();
+ return _my.getValue();
}
}
\ No newline at end of file
package org.splat.service.dto;
import java.security.Principal;
+
import org.splat.kernel.Name;
/**
*/
public class UserDTO implements Principal, Name {
- private String password; // Property without getter function
- private String username; // Unique in the user directory
- private String first;
- private String last;
- private String display; // Optional
- private RoleDTO role = new RoleDTO(); // Roles as list (as stored into the database)
- private String email;
- private String organid;
+ private String _password; // Property without getter function
+ private String _username; // Unique in the user directory
+ private String _firstName;
+ private String _name;
+ private String _displayName; // Optional
+ private RoleDTO _role = new RoleDTO(); // Roles as list (as stored into the database)
+ private String _mailAddress;
+ private String _organizationName;
/**
* Persistent id of the type.
*/
- private long rid;
+ private long _index;
// ==============================================================================================================================
// Public member functions
// ==============================================================================================================================
- public boolean equals(Object item) {
- if (item == null)
- return false;
- if (item instanceof String) {
- return this.username.equals((String) item); // Usernames are unique
- } else if (item instanceof UserDTO) {
- UserDTO given = (UserDTO) item;
- return (given.username.equals(this.username)); // Usernames are unique
- } else {
- return false;
+ @Override
+ public boolean equals(final Object item) {
+ boolean res = (item != null);
+ if (res) {
+ if (item instanceof String) {
+ res = this._username.equals(item); // Usernames are unique
+ } else if (item instanceof UserDTO) {
+ UserDTO given = (UserDTO) item;
+ res = given._username.equals(this._username); // Usernames are unique
+ }
}
+ return res;
}
public String getDisplayName() {
- if (display == null)
- return last + " " + first;
- else
- return display;
+ String res = _displayName;
+ if (res == null) {
+ res = _name + " " + _firstName;
+ }
+ return res;
}
public String getFirstName() {
- return first;
+ return _firstName;
}
public void setFirstName(final String name) {
- first = name;
+ _firstName = name;
}
public String getMailAddress() {
- return email;
+ return _mailAddress;
}
public void setMailAddress(final String addr) {
- email = addr;
+ _mailAddress = addr;
}
public String getName() {
- return last;
+ return _name;
}
public void setName(final String name) {
- last = name;
+ _name = name;
}
public String getOrganizationName() {
- return organid;
+ return _organizationName;
}
- public void setOrganizationName(String name) {
- organid = name;
+ public void setOrganizationName(final String name) {
+ _organizationName = name;
}
public String getRoleNames() {
- return role.getName();
+ return _role.getName();
}
public RoleDTO[] getRoles() {
- return role.toArray();
+ return _role.toArray();
}
public String getUsername() {
- return username;
+ return _username;
}
+ @Override
public String toString() {
- return last + " " + first;
+ return _name + " " + _firstName;
}
/**
* @return the rid
*/
public long getIndex() {
- return rid;
+ return _index;
}
/**
* @param rid
* the rid to set
*/
- public void setIndex(long rid) {
- this.rid = rid;
+ public void setIndex(final long rid) {
+ this._index = rid;
}
/**
* @return the password
*/
public String getPassword() {
- return password;
+ return _password;
}
/**
* Set the password.
* @param password the password to set
*/
- public void setPassword(String password) {
- this.password = password;
+ public void setPassword(final String password) {
+ this._password = password;
}
/**
* Set the username.
* @param username the username to set
*/
- public void setUsername(String username) {
- this.username = username;
+ public void setUsername(final String username) {
+ this._username = username;
}
/**
* @return the role
*/
public RoleDTO getRole() {
- return role;
+ return _role;
}
/**
* Set the role.
* @param role the role to set
*/
- public void setRole(RoleDTO role) {
- this.role = role;
+ public void setRole(final RoleDTO role) {
+ this._role = role;
+ }
+
+ /**
+ * Set the displayName.
+ * @param displayName the displayName to set
+ */
+ public void setDisplayName(final String displayName) {
+ _displayName = displayName;
}
}
\ No newline at end of file
import java.util.Set;
import org.apache.log4j.Logger;
-
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.CorruptIndexException;
*/
public class IndexServiceImpl implements IndexService {
- private Directory index;
- private org.apache.lucene.document.Document body;
+ /**
+ * The logger for this service.
+ */
+ private static final Logger LOG = Logger
+ .getLogger(IndexServiceImpl.class);
+
+ private final static String PROP_INDEX = "index";
+ private final static String PROP_REF = "ref";
+ private final static String PROP_STATE = "state";
+ private final static String PROP_AUTHOR = "author";
+ private final static String PROP_TITLE = "title";
+
+ private transient Directory _index;
+ private transient org.apache.lucene.document.Document _body;
private ProjectElementService _projectElementService;
private RepositoryService _repositoryService;
protected static StandardAnalyzer analyzer = new StandardAnalyzer(
Version.LUCENE_29);
- private static final Logger logger = Logger
- .getLogger(IndexServiceImpl.class);
-
private class Entry extends IndexWriter {
- private org.apache.lucene.document.Document entry;
+ private transient final org.apache.lucene.document.Document _entry;
- private Entry(Study study) throws CorruptIndexException,
+ private Entry(final Study study) throws CorruptIndexException,
LockObtainFailedException, IOException {
- super(index, analyzer, false, IndexWriter.MaxFieldLength.UNLIMITED);
+ super(_index, analyzer, false, IndexWriter.MaxFieldLength.UNLIMITED);
// Addition of mandatory fields
- entry = new org.apache.lucene.document.Document();
+ _entry = new org.apache.lucene.document.Document();
Field field;
- field = body.getField("index");
+ field = _body.getField(PROP_INDEX);
field.setValue(String.valueOf(study.getIndex()));
- entry.add(field);
- field = body.getField("class");
+ _entry.add(field);
+ field = _body.getField("class");
field.setValue("Study");
- entry.add(field);
- field = body.getField("type");
+ _entry.add(field);
+ field = _body.getField("type");
field.setValue(""); // Reserved for configurable Study type
- entry.add(field);
- field = body.getField("ref");
+ _entry.add(field);
+ field = _body.getField(PROP_REF);
field.setValue(study.getReference());
- entry.add(field);
- field = body.getField("area");
+ _entry.add(field);
+ field = _body.getField("area");
field.setValue(study.getVisibility().toString());
- entry.add(field);
- field = body.getField("state");
+ _entry.add(field);
+ field = _body.getField(PROP_STATE);
field.setValue(study.getProgressState().toString());
- entry.add(field);
- field = body.getField("author");
+ _entry.add(field);
+ field = _body.getField(PROP_AUTHOR);
field.setValue(study.getAuthor().toString());
- entry.add(field);
- field = body.getField("title");
+ _entry.add(field);
+ field = _body.getField(PROP_TITLE);
field.setValue(study.getTitle());
- entry.add(field);
- field = body.getField("contents");
+ _entry.add(field);
+ field = _body.getField("contents");
field.setValue(study.getTitle());
- entry.add(field);
+ _entry.add(field);
// Addition of optional fields
setActorsOf(study);
setContextAt(getProjectElementService().getSteps(study));
}
- private Entry(KnowledgeElement kelm) throws CorruptIndexException,
+ private Entry(final KnowledgeElement kelm) throws CorruptIndexException,
LockObtainFailedException, IOException {
- super(index, analyzer, false, IndexWriter.MaxFieldLength.UNLIMITED);
+ super(_index, analyzer, false, IndexWriter.MaxFieldLength.UNLIMITED);
// Addition of mandatory fields
- entry = new org.apache.lucene.document.Document();
+ _entry = new org.apache.lucene.document.Document();
Field field;
- field = body.getField("index");
+ field = _body.getField(PROP_INDEX);
field.setValue(String.valueOf(kelm.getIndex()));
- entry.add(field);
- field = body.getField("class");
+ _entry.add(field);
+ field = _body.getField("class");
field.setValue("KnowledgeElement");
- entry.add(field);
- field = body.getField("type");
+ _entry.add(field);
+ field = _body.getField("type");
field.setValue(kelm.getType().getName());
- entry.add(field);
- field = body.getField("ref");
+ _entry.add(field);
+ field = _body.getField(PROP_REF);
field.setValue(kelm.getReference());
- entry.add(field);
- field = body.getField("area");
+ _entry.add(field);
+ field = _body.getField("area");
field.setValue(kelm.getVisibility().toString());
- entry.add(field);
- field = body.getField("state");
+ _entry.add(field);
+ field = _body.getField(PROP_STATE);
field.setValue(kelm.getProgressState().toString());
- entry.add(field);
- field = body.getField("author");
+ _entry.add(field);
+ field = _body.getField(PROP_AUTHOR);
field.setValue(kelm.getAuthor().toString());
- entry.add(field);
- field = body.getField("title");
+ _entry.add(field);
+ field = _body.getField(PROP_TITLE);
field.setValue(kelm.getTitle());
- entry.add(field);
- field = body.getField("contents");
+ _entry.add(field);
+ field = _body.getField("contents");
field.setValue(kelm.getTitle());
- entry.add(field);
+ _entry.add(field);
// TODO: Addition of optional fields
Scenario scene = kelm.getOwnerScenario();
}
private void add() throws CorruptIndexException, IOException {
- addDocument(entry);
+ addDocument(_entry);
// Save the new entry
optimize(); // Should be called before committing the index
close(); // Commits the index
}
private void update() throws CorruptIndexException, IOException {
- String value = entry.getField("ref").stringValue(); // Only field with unique value
- Term term = new Term("ref").createTerm(value);
- updateDocument(term, entry);
+ String value = _entry.getField(PROP_REF).stringValue(); // Only field with unique value
+ Term term = new Term(PROP_REF).createTerm(value);
+ updateDocument(term, _entry);
// Save the updated entry
optimize(); // Should be called before committing the index
close(); // Commits the index
}
- private void setContextAt(Step[] step) {
+ private void setContextAt(final Step[] step) {
for (int i = 0; i < step.length; i++) {
List<SimulationContext> contexts = step[i]
.getAllSimulationContexts();
SimulationContext context = j.next();
String type = String.valueOf(context.getType().getIndex());
String value = context.getValue();
- entry.add(new Field(type, value, Field.Store.NO,
+ _entry.add(new Field(type, value, Field.Store.NO,
Field.Index.NOT_ANALYZED));
}
}
}
- private void setActorsOf(Study study) {
+ private void setActorsOf(final Study study) {
// RKV: This set is always not null. Let's assume that it must be initialized before reindexing: Set<User> actors =
// study.getActors();
Set<User> actors = study.getActor(); // RKV
- if (logger.isDebugEnabled()) {
- logger.debug("Study " + study.getReference()
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Study " + study.getReference()
+ " actors number to be added to the lucen index: "
+ actors.size());
}
for (Iterator<User> i = actors.iterator(); i.hasNext();) {
String value = i.next().toString();
- entry.add(new Field("actor", value, Field.Store.NO,
+ _entry.add(new Field("actor", value, Field.Store.NO,
Field.Index.NOT_ANALYZED));
- if (logger.isDebugEnabled()) {
- logger.debug(" actor added to the lucen index: " + value);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(" actor added to the lucen index: " + value);
}
}
}
}
public static class ObjectProxy implements Proxy, Serializable {
- // --------------------------------------------------------------
- private Long rid;
- private String sid;
- private ProgressState state;
- private String title;
- private String type;
- private String name;
+ private transient final Long _rid;
+ private transient final String _sid;
+ private transient final ProgressState _state;
+ private transient final String _title;
+ private transient String _type;
+ private transient final String _name;
private static final long serialVersionUID = -4386494192709562221L;
- public ObjectProxy(org.apache.lucene.document.Document ludoc) {
- rid = Long.valueOf(ludoc.get("index"));
- sid = ludoc.get("ref");
- state = ProgressState.valueOf(ludoc.get("state"));
- title = ludoc.get("title");
- name = ludoc.get("author");
+ public ObjectProxy(final org.apache.lucene.document.Document ludoc) {
+ _rid = Long.valueOf(ludoc.get(PROP_INDEX));
+ _sid = ludoc.get(PROP_REF);
+ _state = ProgressState.valueOf(ludoc.get(PROP_STATE));
+ _title = ludoc.get(PROP_TITLE);
+ _name = ludoc.get(PROP_AUTHOR);
}
public String getAuthorName() {
- return name;
+ return _name;
}
public Long getIndex() {
- return rid;
+ return _rid;
}
public ProgressState getProgressState() {
- return state;
+ return _state;
}
public String getReference() {
- return sid;
+ return _sid;
}
public String getTitle() {
- return title;
+ return _title;
}
public String getType() {
- return type;
+ return _type;
}
}
public void configure() throws IOException {
File indir = getRepositoryService().getRepositoryIndexDirectory();
- index = FSDirectory.open(indir);
- body = new org.apache.lucene.document.Document();
- body.add(new Field("index", "", Field.Store.YES,
+ _index = FSDirectory.open(indir);
+ _body = new org.apache.lucene.document.Document();
+ _body.add(new Field(PROP_INDEX, "", Field.Store.YES,
Field.Index.NOT_ANALYZED));
- body.add(new Field("class", "", Field.Store.NO,
+ _body.add(new Field("class", "", Field.Store.NO,
Field.Index.NOT_ANALYZED));
- body.add(new Field("type", "", Field.Store.YES,
+ _body.add(new Field("type", "", Field.Store.YES,
Field.Index.NOT_ANALYZED));
- body
- .add(new Field("ref", "", Field.Store.YES,
+ _body
+ .add(new Field(PROP_REF, "", Field.Store.YES,
Field.Index.NOT_ANALYZED));
- body
+ _body
.add(new Field("area", "", Field.Store.NO,
Field.Index.NOT_ANALYZED));
- body.add(new Field("state", "", Field.Store.YES,
+ _body.add(new Field(PROP_STATE, "", Field.Store.YES,
Field.Index.NOT_ANALYZED));
- body.add(new Field("author", "", Field.Store.YES,
+ _body.add(new Field(PROP_AUTHOR, "", Field.Store.YES,
Field.Index.NOT_ANALYZED));
- body.add(new Field("title", "", Field.Store.YES,
+ _body.add(new Field(PROP_TITLE, "", Field.Store.YES,
Field.Index.NOT_ANALYZED));
- body
+ _body
.add(new Field("contents", "", Field.Store.NO,
Field.Index.ANALYZED));
- if (!this.exists())
+ if (!this.exists()) {
this.create(); // Happens when re-indexing all studies
+ }
}
public void create() throws IOException {
- // -------------------------------
Directory index = FSDirectory.open(getRepositoryService()
.getRepositoryIndexDirectory());
IndexWriter writer = new IndexWriter(index, analyzer, true,
// Member functions
// ==============================================================================================================================
- public void add(Study study) throws IOException {
- // --------------------------------
+ public void add(final Study study) throws IOException {
IndexServiceImpl.Entry entry = new Entry(study);
entry.add();
- if (logger.isInfoEnabled()) {
- logger.info("Study \"" + study.getIndex() + "\" indexed.");
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Study \"" + study.getIndex() + "\" indexed.");
}
}
- public void add(KnowledgeElement kelm) throws IOException {
- // ------------------------------------------
+ public void add(final KnowledgeElement kelm) throws IOException {
IndexServiceImpl.Entry entry = new Entry(kelm);
entry.add();
- if (logger.isInfoEnabled()) {
- logger.info("Knowledge \"" + kelm.getIndex() + "\" indexed.");
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Knowledge \"" + kelm.getIndex() + "\" indexed.");
}
}
public boolean exists() {
- // ---------------------------
+ boolean res = false;
try {
- return IndexReader.indexExists(index);
+ res = IndexReader.indexExists(_index);
} catch (IOException error) {
- error.printStackTrace();
- return false;
+ LOG.error(error.getMessage(), error);
}
+ return res;
}
- public void update(Study study) throws IOException {
- // -----------------------------------
+ public void update(final Study study) throws IOException {
IndexServiceImpl.Entry entry = new Entry(study);
entry.update();
- if (logger.isInfoEnabled()) {
- logger.info("Study \"" + study.getIndex() + "\" re-indexed.");
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Study \"" + study.getIndex() + "\" re-indexed.");
}
}
- public void update(KnowledgeElement kelm) throws IOException {
- // ---------------------------------------------
+ public void update(final KnowledgeElement kelm) throws IOException {
IndexServiceImpl.Entry entry = new Entry(kelm);
entry.update();
- if (logger.isInfoEnabled()) {
- logger.info("Knowledge \"" + kelm.getIndex() + "\" re-indexed.");
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Knowledge \"" + kelm.getIndex() + "\" re-indexed.");
}
}
* the projectElementService to set
*/
public void setProjectElementService(
- ProjectElementService projectElementService) {
+ final ProjectElementService projectElementService) {
_projectElementService = projectElementService;
}
* @param repositoryService
* the repositoryService to set
*/
- public void setRepositoryService(RepositoryService repositoryService) {
+ public void setRepositoryService(final RepositoryService repositoryService) {
_repositoryService = repositoryService;
}
}
\ No newline at end of file
/**
* Transient study step data.
*/
- public static class Step {
+ class Step {
/**
* The sequential number of the step.
*/
- int number;
+ private int _number;
/**
* The owner of the step: study or scenario.
*/
- private Class<? extends ProjectElement> level;
+ private Class<? extends ProjectElement> _level;
/**
* Set of Document and/or Knowledge applicable on this step.
*/
- Set<Class<?>> contents;
+ protected Set<Class<?>> _contents;
/**
* Data path for this step.
*/
- private String path;
+ private String _path;
/**
* Create a transient study step definition.
final Class<? extends ProjectElement> level,
final Class<?> contents, final String path) {
this.initialize(number, level, path);
- this.contents.add(contents);
+ this._contents.add(contents);
}
/**
*/
private void initialize(final int number,
final Class<? extends ProjectElement> level, final String path) {
- this.number = number;
- this.level = level;
- this.path = path + "/";
- this.contents = new HashSet<Class<?>>();
+ this._number = number;
+ this._level = level;
+ this._path = path + "/";
+ this._contents = new HashSet<Class<?>>();
}
/**
* @return true if the step is applied to the given level
*/
public boolean appliesTo(final Class<? extends ProjectElement> level) {
- return (level == this.level);
+ return (level == this._level);
}
/**
* @return true if the step can contain data of the given type
*/
public boolean mayContain(final Class<?> type) {
- return contents.contains(type);
+ return _contents.contains(type);
}
/**
* @return the sequential number of the step
*/
public int getNumber() {
- return number;
+ return _number;
}
/**
* @return data path for this step
*/
public String getPath() {
- return path;
+ return _path;
}
}
*
* @return the validation cycles of the workflow
*/
- public List<ProjectSettingsValidationCycle> getAllValidationCycles();
+ List<ProjectSettingsValidationCycle> getAllValidationCycles();
/**
* Get a study step by its sequential number.
* the step number
* @return the step
*/
- public ProjectSettingsService.Step getStep(final int number);
+ ProjectSettingsService.Step getStep(final int number);
/**
* Get ordered list of (transient) study steps.
*
* @return the list of steps from project settings
*/
- public List<ProjectSettingsService.Step> getAllSteps();
+ List<ProjectSettingsService.Step> getAllSteps();
/**
* Get file naming scheme setting.
* @return file naming scheme
* @see org.splat.service.technical.ProjectSettingsServiceImpl.FileNaming
*/
- public FileNaming getFileNamingScheme();
+ FileNaming getFileNamingScheme();
/**
* Get a pattern of study references.
*
* @return the reference pattern
*/
- public String getReferencePattern();
+ String getReferencePattern();
/**
* Get a pattern of the presentation of version numbers.
*
* @return the version numbers presentation pattern
*/
- public String getRevisionPattern();
+ String getRevisionPattern();
/**
* Load workflow configuration from the given file. <br/> Create necessary default staff in the database if it is not initialized yet.
* @throws SQLException
* if there is a database population problem
*/
- public void configure(String filename) throws IOException, SQLException;
+ void configure(String filename) throws IOException, SQLException;
/**
* Get steps of the given project element (study or scenario).
* the project element (study or scenario)
* @return the list of steps
*/
- public List<ProjectSettingsService.Step> getStepsOf(
+ List<ProjectSettingsService.Step> getStepsOf(
Class<? extends ProjectElement> level);
}
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import java.util.Vector;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
/**
* The logger for the service.
*/
- protected final static Logger logger = Logger
+ protected final static Logger LOG = Logger
.getLogger(ProjectSettingsServiceImpl.class);
// Non persistent configuration information
/**
* Repository settings.
*/
- private final Properties reprop = new Properties();
+ private transient final Properties _reprop = new Properties();
/**
* Pattern of study references.
*/
- private String pattern;
+ private transient String _pattern;
/**
* Scheme of file names stored into the repository.
*/
- private FileNaming naming;
+ private transient FileNaming _naming;
/**
* Pattern of the presentation of version numbers.
*/
- private String versioning;
+ private transient String _versioning;
/**
* Ordered list of (transient) study steps.
*/
- private final Vector<ProjectSettingsService.Step> steps = new Vector<ProjectSettingsService.Step>();
+ private transient final List<ProjectSettingsService.Step> _steps = new ArrayList<ProjectSettingsService.Step>();
/**
* Configuration document validation cycles.
*/
- private Vector<ProjectSettingsValidationCycle> concycles;
+ private transient List<ProjectSettingsValidationCycle> _concycles;
// Temporary attributes initialized from the configuration file for populating the database with object types
/**
* Document type names and uses mapping.
*/
- private LinkedHashMap<String, String> mapuse;
+ private transient Map<String, String> _mapuse;
/**
* Simulation Context type names.
*/
- private Vector<String> context;
+ private transient List<String> _context;
/**
* Knowledge Element type names.
*/
- private Vector<String> kname;
+ private transient List<String> _kname;
/**
* Document flows.
*/
- private Vector<NamedNodeMap> flows;
+ private transient List<NamedNodeMap> _flows;
/**
* Study classifications.
*/
- private Vector<NamedNodeMap> sclass;
+ private transient List<NamedNodeMap> _sclass;
// Other resources
/**
/**
* Cycle (document) type name.
*/
- private final String name;
+ private final String _name;
/**
* Array of cycle actors positions in the organization. TODO: Must be replaced by Roles.
*/
- private final Actor[] actor;
+ private final Actor[] _actor;
/**
* Default constructor.
*/
private ProjectSettingsValidationCycle() {
- this.name = "built-in";
- this.actor = new Actor[] { null, null, null };
+ this._name = "built-in";
+ this._actor = new Actor[] { null, null, null };
}
/**
*/
private ProjectSettingsValidationCycle(final String name,
final Actor[] actor) {
- this.name = name;
- this.actor = actor;
+ this._name = name;
+ this._actor = actor;
}
/**
* @return the document type name
*/
public String getName() {
- return name;
+ return _name;
}
/**
* @see org.splat.dal.bo.som.ValidationCycle.Actor
*/
public Actor[] getActorTypes() {
- return actor;
+ return _actor;
}
}
*/
public void configure(final String filename) throws IOException,
SQLException {
- if (!steps.isEmpty()) {
+ if (!_steps.isEmpty()) {
return; // Project already configured
}
if (config.exists()) {
loadCustomization(config);
} else {
- logger.fatal("Could not find the database configuration file \""
+ LOG.fatal("Could not find the database configuration file \""
+ config.getAbsolutePath() + "\"");
throw new FileNotFoundException();
}
- base.configure(reprop);
+ base.configure(_reprop);
if (!base.isInitialized()) {
base.initialize();
initialize(); // Populates the database with all necessary stuff
* @return the list of steps from project settings
*/
public List<ProjectSettingsService.Step> getAllSteps() {
- return steps;
+ return _steps;
}
/**
* @return the validation cycles of the workflow
*/
public List<ProjectSettingsValidationCycle> getAllValidationCycles() {
- return concycles;
+ return _concycles;
}
/**
* @see org.splat.service.technical.ProjectSettingsServiceImpl.FileNaming
*/
public FileNaming getFileNamingScheme() {
- return naming;
+ return _naming;
}
/**
* @return the reference pattern
*/
public String getReferencePattern() {
- return pattern;
+ return _pattern;
}
/**
* @return the version numbers presentation pattern
*/
public String getRevisionPattern() {
- return versioning;
+ return _versioning;
}
/**
* @return the step
*/
public ProjectSettingsService.Step getStep(final int number) {
- for (int i = 0; i < steps.size(); i++) {
- ProjectSettingsService.Step step = steps.get(i);
- if (step.number == number) {
- return step;
+ ProjectSettingsService.Step res = null;
+ for (int i = 0; i < _steps.size(); i++) {
+ ProjectSettingsService.Step step = _steps.get(i);
+ if (step.getNumber() == number) {
+ res = step;
+ break;
}
}
- return null;
+ return res;
}
/**
*/
public List<ProjectSettingsService.Step> getStepsOf(
final Class<? extends ProjectElement> level) {
- Vector<ProjectSettingsService.Step> result = new Vector<ProjectSettingsService.Step>();
+ List<ProjectSettingsService.Step> result = new ArrayList<ProjectSettingsService.Step>();
- for (int i = 0; i < steps.size(); i++) {
- ProjectSettingsService.Step step = steps.get(i);
+ for (int i = 0; i < _steps.size(); i++) {
+ ProjectSettingsService.Step step = _steps.get(i);
if (step.appliesTo(level)) {
result.add(step);
}
if (!disk.endsWith("/")) {
disk = disk + "/";
}
- logger.info("Database root set to " + disk);
- reprop.setProperty("repository", disk);
+ LOG.info("Database root set to " + disk);
+ _reprop.setProperty("repository", disk);
// Formats tag initializing the reference pattern and date attributes
child = children.get("formats");
datag = XDOM.getNamedChildNodes(child);
NamedNodeMap natr = datag.get("references").getAttributes();
- pattern = natr.getNamedItem("study").getNodeValue();
+ _pattern = natr.getNamedItem("study").getNodeValue();
natr = datag.get("files").getAttributes();
- naming = FileNaming.valueOf(natr.getNamedItem("name")
+ _naming = FileNaming.valueOf(natr.getNamedItem("name")
.getNodeValue());
natr = datag.get("versions").getAttributes();
- versioning = natr.getNamedItem("pattern").getNodeValue();
+ _versioning = natr.getNamedItem("pattern").getNodeValue();
// Activities tag initializing the steps and rex attributes
child = children.get("activities");
NodeList nlist = child.getChildNodes();
- Vector<NamedNodeMap> flist = new Vector<NamedNodeMap>();
- Vector<String> resultype = new Vector<String>();
- Vector<NamedNodeMap> clist = new Vector<NamedNodeMap>();
+ List<NamedNodeMap> flist = new ArrayList<NamedNodeMap>();
+ List<String> resultype = new ArrayList<String>();
+ List<NamedNodeMap> clist = new ArrayList<NamedNodeMap>();
int snum = 1; // Base number of steps
for (int i = 0; i < nlist.getLength(); i++) {
}
child = tags.get("classification");
- if (child != null) {
- clist.add(child.getAttributes());
- } else {
+ if (child == null) {
clist.add(null);
+ } else {
+ clist.add(child.getAttributes());
}
if (natr.getNamedItem("contents").getNodeValue()
.equals("knowledge")) {
// TODO In a given scenario, only one step must contain knowledges
- step.contents.add(KnowledgeElement.class);
+ step._contents.add(KnowledgeElement.class);
} else {
- step.contents.add(Document.class);
+ step._contents.add(Document.class);
}
- steps.add(step);
+ _steps.add(step);
snum += 1;
}
} else {
}
child = tags.get("classification"); // Optional information
- if (child != null) {
- clist.add(child.getAttributes());
- } else {
+ if (child == null) {
clist.add(null);
+ } else {
+ clist.add(child.getAttributes());
}
if (natr.getNamedItem("contents").getNodeValue().equals(
"knowledge")) {
// TODO Error: knowledges must be attached to scenarios
+ LOG.error("Error: knowledges must be attached to scenarios.");
} else {
- step.contents.add(Document.class);
+ step._contents.add(Document.class);
}
- steps.add(step);
+ _steps.add(step);
snum += 1;
}
}
// Validations tag
child = children.get("validations");
- concycles = new Vector<ProjectSettingsValidationCycle>();
+ _concycles = new ArrayList<ProjectSettingsValidationCycle>();
datag = XDOM.getNamedChildNodes(child);
String[] step = { "review", "approval", "acceptance" };
}
actor[j] = Actor.valueOf(child.getNodeValue());
}
- concycles.add(new ProjectSettingsValidationCycle(name, actor));
+ _concycles.add(new ProjectSettingsValidationCycle(name, actor));
}
- concycles.add(new ProjectSettingsValidationCycle()); // Adds the built-in validation cycle
+ _concycles.add(new ProjectSettingsValidationCycle()); // Adds the built-in validation cycle
if (getDatabase().getCheckedDB().isInitialized()) {
return; // No need to load object type definitions as they are already stored
child = children.get("documents");
nlist = child.getChildNodes();
- flows = flist; // Kept for later use in document type definition
- sclass = clist; // Kept for later use in simulation context type definition
- mapuse = new LinkedHashMap<String, String>();
+ _flows = flist; // Kept for later use in document type definition
+ _sclass = clist; // Kept for later use in simulation context type definition
+ _mapuse = new LinkedHashMap<String, String>();
for (int i = 0; i < nlist.getLength(); i++) {
child = nlist.item(i);
if (!child.getNodeName().equals("article")) {
if (child != null) {
uses = child.getNodeValue();
}
- mapuse.put(type, uses); // Must be added to the map even if no (null) uses
+ _mapuse.put(type, uses); // Must be added to the map even if no (null) uses
}
// Simulation Contexts tag
child = children.get("contexts");
nlist = child.getChildNodes();
- context = new Vector<String>();
+ _context = new ArrayList<String>();
for (int i = 0; i < nlist.getLength(); i++) {
child = nlist.item(i);
if (!child.getNodeName().equals("article")) {
continue;
}
- context.add(child.getAttributes().getNamedItem("type")
+ _context.add(child.getAttributes().getNamedItem("type")
.getNodeValue());
}
// Knowledge Elements tag
child = children.get("knowledges");
nlist = child.getChildNodes();
- kname = new Vector<String>();
+ _kname = new ArrayList<String>();
for (int i = 0; i < nlist.getLength(); i++) {
child = nlist.item(i);
if (!child.getNodeName().equals("article")) {
continue;
}
- kname.add(child.getAttributes().getNamedItem("type")
+ _kname.add(child.getAttributes().getNamedItem("type")
.getNodeValue());
}
} catch (Exception error) {
- logger.info("Error in customization", error);
+ LOG.info("Error in customization", error);
}
}
*/
private void createDocumentTypes() {
DocumentType.Properties tprop = new DocumentType.Properties();
- HashMap<String, Vector<ProjectSettingsService.Step>> mapsteps = new HashMap<String, Vector<ProjectSettingsService.Step>>();
- HashMap<String, ProjectSettingsService.Step> mapresult = new HashMap<String, ProjectSettingsService.Step>();
- HashMap<String, DocumentType> maptype = new HashMap<String, DocumentType>();
+ Map<String, List<ProjectSettingsService.Step>> mapsteps = new HashMap<String, List<ProjectSettingsService.Step>>();
+ Map<String, ProjectSettingsService.Step> mapresult = new HashMap<String, ProjectSettingsService.Step>();
+ Map<String, DocumentType> maptype = new HashMap<String, DocumentType>();
- Vector<ProjectSettingsService.Step> slist = null; // List of Steps to which each document type is valid
+ List<ProjectSettingsService.Step> slist = null; // List of Steps to which each document type is valid
int snum = 0; // Step number
String type = null;
String uses = null;
- for (Iterator<NamedNodeMap> i = flows.iterator(); i.hasNext(); snum++) {
+ for (Iterator<NamedNodeMap> i = _flows.iterator(); i.hasNext(); snum++) {
NamedNodeMap flow = i.next();
- ProjectSettingsService.Step step = steps.get(snum);
+ ProjectSettingsService.Step step = _steps.get(snum);
String[] contents = flow.getNamedItem("contents").getNodeValue()
.split(",");
for (int j = 0; j < contents.length; j++) {
type = contents[j];
- if (!mapuse.containsKey(type)) {
- logger.warn("Undefined \"" + type + "\" document type.");
+ if (!_mapuse.containsKey(type)) {
+ LOG.warn("Undefined \"" + type + "\" document type.");
continue;
}
slist = mapsteps.get(type);
if (slist == null) {
- slist = new Vector<ProjectSettingsService.Step>();
+ slist = new ArrayList<ProjectSettingsService.Step>();
}
slist.add(step);
mapsteps.put(type, slist);
}
try {
DocumentType tdoc = null;
- Set<String> tset = mapuse.keySet();
+ Set<String> tset = _mapuse.keySet();
ProjectSettingsService.Step step;
for (Iterator<String> i = tset.iterator(); i.hasNext();) {
type = i.next();
slist = mapsteps.get(type);
- uses = mapuse.get(type);
+ uses = _mapuse.get(type);
step = mapresult.get(type);
tprop.clear();
if (uses != null) {
tdoc = maptype.get(uses);
if (tdoc == null) {
- logger
+ LOG
.warn("Undefined \"" + uses
+ "\" document type.");
} else {
maptype.put(type, tdoc);
}
} catch (Exception error) {
- logger.warn("Error creating document types, reason:", error); // Should not happen
+ LOG.warn("Error creating document types, reason:", error); // Should not happen
}
}
KnowledgeElementType ktype = getKnowledgeElementTypeService()
.createType("usecase"); // Internal reserved knowledge element type
getKnowledgeElementTypeService().reserve(ktype);
- for (Iterator<String> i = kname.iterator(); i.hasNext();) {
+ for (Iterator<String> i = _kname.iterator(); i.hasNext();) {
String type = i.next();
ktype = getKnowledgeElementTypeService().createType(type); // Knowledge Elements Types defined in the configuration
getKnowledgeElementTypeService().approve(ktype);
}
} catch (Exception error) {
- logger.warn("Error creating knowledge types, reason:", error); // Should not happen
+ LOG.warn("Error creating knowledge types, reason:", error); // Should not happen
}
}
* Create in the database simulation contexts types defined in the custom configuration.
*/
private void createSimulationContextTypes() {
- HashMap<String, ProjectSettingsService.Step> mapstep = new HashMap<String, ProjectSettingsService.Step>();
+ Map<String, ProjectSettingsService.Step> mapstep = new HashMap<String, ProjectSettingsService.Step>();
int snum = 0;
- for (Iterator<NamedNodeMap> i = sclass.iterator(); i.hasNext(); snum++) {
+ for (Iterator<NamedNodeMap> i = _sclass.iterator(); i.hasNext(); snum++) {
NamedNodeMap clatr = i.next();
if (clatr == null) {
continue;
String[] clist = clatr.getNamedItem("context").getNodeValue()
.split(",");
for (int j = 0; j < clist.length; j++) {
- mapstep.put(clist[j], steps.get(snum));
+ mapstep.put(clist[j], _steps.get(snum));
}
}
try {
SimulationContextType tctex = null;
- for (Iterator<String> i = context.iterator(); i.hasNext();) {
+ for (Iterator<String> i = _context.iterator(); i.hasNext();) {
String type = i.next();
if (!mapstep.containsKey(type)) {
- logger
+ LOG
.warn("Could not find \""
+ type
+ "\" classification. Simulation Context type ignored.");
getSimulationContextTypeService().approve(tctex);
}
} catch (Exception error) {
- logger.warn("Error creating context types, reason:", error); // Should not happen
+ LOG.warn("Error creating context types, reason:", error); // Should not happen
}
}
package org.splat.som;
+
/**
*
* @author Daniel Brunier-Coulin
import org.splat.dal.bo.kernel.Role;
import org.splat.dal.bo.kernel.User;
-
public class ApplicationRights {
- private User user;
- private Set<String> roles;
+ private static final String N_1 = "Nx1";
+ private static final String N_2 = "Nx2";
+ private transient final User _user;
+ private transient final Set<String> _roles;
-// ==============================================================================================================================
-// Construction
-// ==============================================================================================================================
+ // ==============================================================================================================================
+ // Construction
+ // ==============================================================================================================================
- public ApplicationRights (User user) { // Warning: user may be null
-// ------------------------------------
- this.roles = new HashSet<String>();
- this.user = user;
- if (user != null) {
- Role[] role = user.getRoles();
- for (int i=0; i<role.length; i++) {
- String iam = role[i].getName();
- roles.add(iam);
- }
- }
- }
+ public ApplicationRights(final User user) { // Warning: user may be null
+ this._roles = new HashSet<String>();
+ this._user = user;
+ if (user != null) {
+ Role[] role = user.getRoles();
+ for (int i = 0; i < role.length; i++) {
+ String iam = role[i].getName();
+ _roles.add(iam);
+ }
+ }
+ }
-// ==============================================================================================================================
-// Public member functions
-// ==============================================================================================================================
+ // ==============================================================================================================================
+ // Public member functions
+ // ==============================================================================================================================
- public boolean canCreateStudy () {
-// --------------------------------
- if (user != null) {
- String position = user.getOrganizationName();
- if (position != null && position.equals("Nx2")) return false;
- }
- return roles.contains(Profile.manager.toString());
- }
+ public boolean canCreateStudy() {
+ boolean res = (_user == null);
+ if (res) {
+ res = _roles.contains(Profile.manager.toString());
+ } else {
+ String position = _user.getOrganizationName();
+ res = (position == null || !position.equals(N_2));
+ }
+ return res;
+ }
- public boolean canContributeToStudy () {
-// --------------------------------------
- if (user != null) {
- String position = user.getOrganizationName();
- if (position != null && (position.equals("Nx1") || position.equals("Nx2"))) return false;
- }
- return (roles.contains(Profile.manager.toString()) || roles.contains(Profile.studengineer.toString()));
- }
+ public boolean canContributeToStudy() {
+ boolean res = (_user == null);
+ if (res) {
+ res = (_roles.contains(Profile.manager.toString()) || _roles
+ .contains(Profile.studengineer.toString()));
+ } else {
+ String position = _user.getOrganizationName();
+ res = (position == null || ((!position.equals(N_1)) && (!position
+ .equals(N_2))));
+ }
+ return res;
+ }
- public boolean canValidate () {
-// -----------------------------
- return roles.contains(Profile.manager.toString());
- }
+ public boolean canValidate() {
+ return _roles.contains(Profile.manager.toString());
+ }
- public boolean canManageKnowledges () {
-// -------------------------------------
- if (user != null) {
- String position = user.getOrganizationName();
- if (position != null && position.equals("Nx2")) return false;
- }
- return roles.contains(Profile.knowledgineer.toString());
- }
+ public boolean canManageKnowledges() {
+ boolean res = (_user == null);
+ if (res) {
+ res = _roles.contains(Profile.knowledgineer.toString());
+ } else {
+ String position = _user.getOrganizationName();
+ res = (position == null || (!position.equals(N_2)));
+ }
+ return res;
+ }
- public boolean canManageDatabase () {
-// -----------------------------------
- if (user != null) {
- String position = user.getOrganizationName();
- if (position != null && position.equals("Nx2")) return false;
- }
- return roles.contains(Profile.sysadmin.toString());
- }
+ public boolean canManageDatabase() {
+ boolean res = (_user == null);
+ if (res) {
+ res = _roles.contains(Profile.sysadmin.toString());
+ } else {
+ String position = _user.getOrganizationName();
+ res = (position == null || (!position.equals(N_2)));
+ }
+ return res;
+ }
-// ==============================================================================================================================
-// Getters
-// ==============================================================================================================================
+ // ==============================================================================================================================
+ // Getters
+ // ==============================================================================================================================
- public User getUser () {
-// ----------------------
- return user; // May be null
- }
+ public User getUser() {
+ return _user; // May be null
+ }
}
\ No newline at end of file
public class Revision {
- private int major;
- private int minor;
- private int branch;
+ private transient int _major;
+ private transient int _minor;
+ private transient int _branch;
public static class Format {
-// --------------------------
- private String pattern;
+ private transient final String _pattern;
- public Format (String pattern) {
- this.pattern = pattern;
+ public Format (final String pattern) {
+ this._pattern = pattern;
}
- public String format (String verstring) {
- CharBuffer version = CharBuffer.allocate(pattern.length() + 2*2); // Maximum possible size
- char[] format = pattern.toCharArray();
+ public String format (final String verstring) {
+ CharBuffer version = CharBuffer.allocate(_pattern.length() + 2*2); // Maximum possible size
+ char[] format = _pattern.toCharArray();
String[] vernum = verstring.split("\\x2E"); // version is suposed of the internal form (m.n.s)
int branch = Integer.valueOf(vernum[2]);
version.put(vernum[2]);
}
} else if (token == '[') {
- if (branch == 0) while (format[i] != ']') i += 1;
+ if (branch == 0) {
+ while (format[i] != ']') {
+ i += 1;
+ }
+ }
} else if (token == ']') {
continue;
} else {
return new String(version.array(), 0, version.position());
}
- public Revision parse (String verstring) throws ParseException {
- char[] format = pattern.toCharArray();
+ public Revision parse (final String verstring) throws ParseException {
+ char[] format = _pattern.toCharArray();
char[] version = verstring.toCharArray();
CharBuffer major = CharBuffer.allocate(4);
CharBuffer minor = CharBuffer.allocate(4);
token = format[i];
if (token == 'M') {
while (cursor < version.length) {
- if (!Character.isDigit(version[cursor])) break;
+ if (!Character.isDigit(version[cursor])) {
+ break;
+ }
major.put(version[cursor]);
cursor += 1;
}
} else if (token == 'm') {
while (cursor < version.length) {
- if (!Character.isDigit(version[cursor])) break;
+ if (!Character.isDigit(version[cursor])) {
+ break;
+ }
minor.put(version[cursor]);
cursor += 1;
}
} else if (token == 's') {
while (cursor < version.length) {
- if (!Character.isDigit(version[cursor])) break;
+ if (!Character.isDigit(version[cursor])) {
+ break;
+ }
branch.put(version[cursor]);
cursor += 1;
}
} else if (token == '[' || token == ']') {
continue;
} else {
- if (version[cursor] != token) throw new ParseException(verstring, cursor);
+ if (version[cursor] != token) {
+ throw new ParseException(verstring, cursor);
+ }
cursor += 1;
}
- if (cursor >= version.length) break;
+ if (cursor >= version.length) {
+ break;
+ }
}
- if (major.position() == 0) throw new ParseException(verstring, 0);
+ if (major.position() == 0) {
+ throw new ParseException(verstring, 0);
+ }
String majnum = new String(major.array(), 0, major.position());
if (minor.position() == 0) {
}
public String toPattern () {
- return pattern;
+ return _pattern;
}
}
/**
* Constructs a Revision object from the internal representation of a version number (m.n.s).
*/
- public Revision (String value) {
+ public Revision (final String value) {
// ------------------------------
String[] vernum = value.split("\\x2E");
try {
- this.major = Integer.valueOf(vernum[0]);
- this.minor = Integer.valueOf(vernum[1]);
- this.branch = Integer.valueOf(vernum[2]);
+ this._major = Integer.valueOf(vernum[0]);
+ this._minor = Integer.valueOf(vernum[1]);
+ this._branch = Integer.valueOf(vernum[2]);
}
catch (Exception e) { // NumberFormat or OutOfBound exception if value is not of the form m.n.s
- this.major = 0;
- this.minor = 0;
- this.branch = 0;
+ this._major = 0;
+ this._minor = 0;
+ this._branch = 0;
}
}
public Revision () {
// ------------------
- this.major = 0;
- this.minor = 0;
- this.branch = 0;
+ this._major = 0;
+ this._minor = 0;
+ this._branch = 0;
}
- private Revision (int major, int minor) {
+ private Revision (final int major, final int minor) {
// ---------------------------------------
- this.major = major;
- this.minor = minor;
- this.branch = 0;
+ this._major = major;
+ this._minor = minor;
+ this._branch = 0;
}
- private Revision (int major, int minor, String branch) {
+ private Revision (final int major, final int minor, final String branch) {
// ------------------------------------------------------
- this.major = major;
- this.minor = minor;
- this.branch = Integer.valueOf(branch);
+ this._major = major;
+ this._minor = minor;
+ this._branch = Integer.valueOf(branch);
}
// ==============================================================================================================================
// Public member function
// ==============================================================================================================================
- public Revision incrementAs (ProgressState state) {
+ public Revision incrementAs (final ProgressState state) {
// -------------------------------------------------
- if (state == ProgressState.inWORK || state == ProgressState.inDRAFT) minor += 1;
- else if (state == ProgressState.inCHECK) {
- major = major + 1;
- minor = 0;
+ if (state == ProgressState.inWORK || state == ProgressState.inDRAFT) {
+ _minor += 1;
+ } else if (state == ProgressState.inCHECK) {
+ _major = _major + 1;
+ _minor = 0;
}
return this;
}
- public boolean isGraterThan (Revision base) {
+ public boolean isGraterThan (final Revision base) {
// ------------------------------------------
- if (this.major > base.major) return true;
- if (this.major < base.major) return false;
- return (this.minor > base.minor);
+ if (this._major > base._major) {
+ return true;
+ }
+ if (this._major < base._major) {
+ return false;
+ }
+ return (this._minor > base._minor);
}
public boolean isMinor () {
// -------------------------
- return (minor != 0);
+ return (_minor != 0);
}
public boolean isNull () {
// ------------------------
- return (major+minor == 0);
+ return (_major+_minor == 0);
}
/**
* Sets the branch name of this revision.
* @param name the branch name or the internal representation of a version number (m.n.s)
* @return this revision object
*/
- public Revision setBranch (String name) {
+ public Revision setBranch (final String name) {
// ---------------------------------------
String[] vernum = name.split("\\x2E");
- branch = Integer.valueOf(vernum[vernum.length-1]);
+ _branch = Integer.valueOf(vernum[vernum.length-1]);
return this;
}
/**
* Returns the internal representation of a version number (m.n.s) represented by this Revision object.
*/
- public String toString () {
+ @Override
+ public String toString () {
// -------------------------
StringBuffer version = new StringBuffer();
- return version.append(major).append(".").append(minor).append(".").append(branch).toString();
+ return version.append(_major).append(".").append(_minor).append(".").append(_branch).toString();
}
}
\ No newline at end of file
* @copyright OPEN CASCADE 2012
*/
+import java.util.ArrayList;
import java.util.Collections;
-import java.util.List;
-import java.util.Vector;
import java.util.Iterator;
+import java.util.List;
import org.splat.dal.bo.kernel.User;
import org.splat.dal.bo.som.Document;
public class Step {
- private ProjectSettingsService.Step step;
- private ProjectElement owner;
- private List<SimulationContext> contex;
- private List<Publication> docums;
- private User actor; // Actor involved in operations on published documents and requiring a time-stamp
+ private transient final ProjectSettingsService.Step _step;
+ private transient final ProjectElement _owner;
+ private transient final List<SimulationContext> _contex;
+ private transient final List<Publication> _docums;
+ private User _actor; // Actor involved in operations on published documents and requiring a time-stamp
// ==============================================================================================================================
// Constructor
// ==============================================================================================================================
- public Step(ProjectSettingsService.Step step, ProjectElement owner) {
- // ----------------------------------------------------------------
- this.step = step;
- this.owner = owner;
- this.contex = new Vector<SimulationContext>();
- this.docums = new Vector<Publication>();
- this.actor = null;
+ public Step(final ProjectSettingsService.Step step,
+ final ProjectElement owner) {
+ this._step = step;
+ this._owner = owner;
+ this._contex = new ArrayList<SimulationContext>();
+ this._docums = new ArrayList<Publication>();
+ this._actor = null;
// Filtering of Simulation contexts, if exist
for (Iterator<SimulationContext> i = owner.SimulationContextIterator(); i
.hasNext();) {
SimulationContext adoc = i.next();
- if (!adoc.isInto(this))
+ if (!adoc.isInto(this)) {
continue;
- this.contex.add(adoc);
+ }
+ this._contex.add(adoc);
}
// Filtering of Documents, if exist
for (Iterator<Publication> i = owner.PublicationIterator(); i.hasNext();) {
Publication mydoc = i.next();
- if (!mydoc.value().isInto(this))
+ if (!mydoc.value().isInto(this)) {
continue;
- this.docums.add(mydoc);
+ }
+ mydoc.setStep(this); //RKV
+ this._docums.add(mydoc);
}
}
// ==============================================================================================================================
public User getActor() {
- // -----------------------
- return actor;
+ return _actor;
}
public List<Publication> getAllDocuments() {
- // -------------------------------------------
- return Collections.unmodifiableList(docums);
+ return Collections.unmodifiableList(_docums);
}
/**
* Get the persistent collection of step documents.
+ *
* @return the list of documents
*/
public List<Publication> getDocuments() {
- return docums;
+ return _docums;
}
public List<SimulationContext> getAllSimulationContexts() {
- // ----------------------------------------------------------
- return Collections.unmodifiableList(contex);
+ return Collections.unmodifiableList(_contex);
}
- public Publication getDocument(long l) {
- // ------------------------------------------
- for (Iterator<Publication> i = docums.iterator(); i.hasNext();) {
+ public Publication getDocument(final long docId) {
+ for (Iterator<Publication> i = _docums.iterator(); i.hasNext();) {
Publication found = i.next(); // In a given study step,
- if (found.value().getIndex() == l)
+ if (found.value().getIndex() == docId) {
return found; // there is only one publication of a given document
+ }
}
return null;
}
public int getNumber() {
- // -----------------------
- return step.getNumber();
+ return _step.getNumber();
}
public ProjectElement getOwner() {
- // ---------------------------------
- return owner; // May be a Study or a Scenario
+ return _owner; // May be a Study or a Scenario
}
public Study getOwnerStudy() {
- // -----------------------------
- if (owner instanceof Study)
- return (Study) owner;
- else
- return ((Scenario) owner).getOwnerStudy();
+ if (_owner instanceof Study) {
+ return (Study) _owner;
+ } else {
+ return ((Scenario) _owner).getOwnerStudy();
+ }
}
public String getPath() {
- // ------------------------
- return step.getPath();
+ return _step.getPath();
}
public List<Publication> getResultDocuments() {
- // ----------------------------------------------
- List<Publication> result = new Vector<Publication>();
+ List<Publication> result = new ArrayList<Publication>();
- if (!docums.isEmpty())
- for (Iterator<Publication> i = docums.iterator(); i.hasNext();) {
+ if (!_docums.isEmpty()) {
+ for (Iterator<Publication> i = _docums.iterator(); i.hasNext();) {
Publication content = i.next();
DocumentType type = content.value().getType();
- if (!type.isResultOf(this.getStep()))
+ if (!type.isResultOf(this.getStep())) {
continue;
+ }
result.add(content);
}
+ }
return result;
}
public ProjectSettingsService.Step getStep() {
- // --------------------------------------
- return step;
+ return _step;
}
- public SimulationContext getSimulationContext(long l) {
- // ---------------------------------------------------------
- for (Iterator<SimulationContext> i = owner.SimulationContextIterator(); i
+ public SimulationContext getSimulationContext(final long l) {
+ for (Iterator<SimulationContext> i = _owner.SimulationContextIterator(); i
.hasNext();) {
SimulationContext myctex = i.next();
- if (myctex.getIndex() == l)
+ if (myctex.getIndex() == l) {
return myctex;
+ }
}
return null;
}
public List<SimulationContext> getSimulationContext(
- SimulationContextType type) {
- // --------------------------------------------------------------------------------
- Vector<SimulationContext> result = new Vector<SimulationContext>();
+ final SimulationContextType type) {
+ List<SimulationContext> result = new ArrayList<SimulationContext>();
- for (Iterator<SimulationContext> i = owner.SimulationContextIterator(); i
+ for (Iterator<SimulationContext> i = _owner.SimulationContextIterator(); i
.hasNext();) {
SimulationContext myctex = i.next();
- if (myctex.getType().equals(type))
+ if (myctex.getType().equals(type)) {
result.add(myctex);
+ }
}
return result;
}
public boolean isStarted() {
- // ---------------------------
- if (!step.mayContain(KnowledgeElement.class))
- return !docums.isEmpty();
-
- List<KnowledgeElement> kelm = ((Scenario) owner)
- .getAllKnowledgeElements();
- if (kelm.isEmpty() && docums.isEmpty())
- return false;
- return true;
+ boolean res = _step.mayContain(KnowledgeElement.class);
+ if (res) {
+ List<KnowledgeElement> kelm = ((Scenario) _owner)
+ .getAllKnowledgeElements();
+ res = (!kelm.isEmpty() || !_docums.isEmpty());
+ } else {
+ res = (!_docums.isEmpty());
+ }
+ return res;
}
public boolean isFinished() {
- // ----------------------------
- if (!step.mayContain(KnowledgeElement.class)) { // Check if all result documents are approved
- if (docums.isEmpty())
+ if (_step.mayContain(KnowledgeElement.class)) { // Check if all result documents are approved
+ List<KnowledgeElement> kelm = ((Scenario) _owner)
+ .getAllKnowledgeElements();
+ if (kelm.isEmpty()) {
+ return false;
+ }
+ for (Iterator<KnowledgeElement> i = kelm.iterator(); i.hasNext();) {
+ KnowledgeElement content = i.next();
+ if (content.getProgressState() != ProgressState.APPROVED) {
+ return false;
+ }
+ }
+ return true;
+ } else { // Check if all existing knowledges are approved
+ if (_docums.isEmpty()) {
return false;
+ }
boolean result = false;
- for (Iterator<Publication> i = docums.iterator(); i.hasNext();) {
+ for (Iterator<Publication> i = _docums.iterator(); i.hasNext();) {
Document content = i.next().value();
DocumentType type = content.getType();
- if (!type.isResultOf(this.getStep()))
+ if (!type.isResultOf(this.getStep())) {
continue;
- if (content.getProgressState() == ProgressState.EXTERN)
+ }
+ if (content.getProgressState() == ProgressState.EXTERN) {
continue;
+ }
result = true; // There is at least 1 non external result document
- if (content.getProgressState() != ProgressState.APPROVED)
+ if (content.getProgressState() != ProgressState.APPROVED) {
return false;
+ }
}
return result;
- } else { // Check if all existing knowledges are approved
- List<KnowledgeElement> kelm = ((Scenario) owner)
- .getAllKnowledgeElements();
- if (kelm.isEmpty())
- return false;
- for (Iterator<KnowledgeElement> i = kelm.iterator(); i.hasNext();) {
- KnowledgeElement content = i.next();
- if (content.getProgressState() != ProgressState.APPROVED)
- return false;
- }
- return true;
}
}
- public boolean mayContain(@SuppressWarnings("rawtypes")
- Class type) {
- return step.mayContain(type);
+ @SuppressWarnings("unchecked")
+ public boolean mayContain(final Class type) {
+ return _step.mayContain(type);
}
- public void setActor(User user) {
- actor = user;
+ public void setActor(final User user) {
+ _actor = user;
}
public List<SimulationContext> getContex() {
- return contex;
+ return _contex;
}
}
\ No newline at end of file
public class StepRights {
- private User user;
- private Step operand;
- public StepRights (User user, Step step) {
+ private final transient User _user;
+ private final transient Step _operand;
+ public StepRights (final User user, final Step step) {
// ----------------------------------------
- this.user = user;
- this.operand = step;
+ this._user = user;
+ this._operand = step;
}
- public StepRights (Step step) {
+ public StepRights (final Step step) {
// -----------------------------
- this.user = step.getOwner().getAuthor();
- this.operand = step;
+ this._user = step.getOwner().getAuthor();
+ this._operand = step;
}
// ==============================================================================================================================
*/
public boolean canAddComment () {
// -------------------------------
- Study owner = operand.getOwnerStudy();
- return (owner.getAuthor().equals(user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(owner, user));
+ Study owner = _operand.getOwnerStudy();
+ return (owner.getAuthor().equals(_user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(owner, _user));
}
/**
*/
public boolean canCreateDocument () {
// -----------------------------------
- if (!isEnabled()) return false;
- return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(operand.getOwnerStudy(), user);
+ if (!isEnabled()) {
+ return false;
+ }
+ return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(_operand.getOwnerStudy(), _user);
}
/**
*/
public boolean canCreateKnowledge () {
// ------------------------------------
- return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(operand.getOwnerStudy(), user);
+ return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(_operand.getOwnerStudy(), _user);
}
/**
*/
public boolean canEditSimulationContext () {
// ------------------------------------------
- Study owner = operand.getOwnerStudy();
- return (owner.getAuthor().equals(user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(owner, user));
+ Study owner = _operand.getOwnerStudy();
+ return (owner.getAuthor().equals(_user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(owner, _user));
}
/**
*/
public boolean isEnabled () {
// ---------------------------
- ProjectElement owner = operand.getOwner();
+ ProjectElement owner = _operand.getOwner();
if (owner instanceof Scenario) {
Scenario scene = (Scenario)owner;
- if (scene.isCheckedout()) return false;
+ if (scene.isCheckedout()) {
+ return false;
+ }
}
return true;
}
public Step getOperand () {
// -------------------------
- return operand;
+ return _operand;
}
}
\ No newline at end of file
public class StudyRights {
- private User user;
- private Study operand;
- private boolean author = false; // For optimizing
- public StudyRights (User user, Study study) {
+ private final transient User _user;
+ private final transient Study _operand;
+ private transient boolean _author = false; // For optimizing
+ public StudyRights (final User user, final Study study) {
// -------------------------------------------
- this.user = user;
- this.operand = study;
+ this._user = user;
+ this._operand = study;
- if (operand != null && operand.getAuthor() != null) {
- this.author = operand.getAuthor().equals(user); // user may be null
+ if (_operand != null && _operand.getAuthor() != null) {
+ this._author = _operand.getAuthor().equals(user); // user may be null
}
}
- public StudyRights (Study study) {
+ public StudyRights (final Study study) {
// --------------------------------
- this.user = study.getAuthor();
- this.operand = study;
- this.author = true; // In order to ignore the author in this context
+ this._user = study.getAuthor();
+ this._operand = study;
+ this._author = true; // In order to ignore the author in this context
}
// ==============================================================================================================================
public boolean canAddScenario () {
// --------------------------------
- if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
- return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(operand, user);
+ if (_operand.getProgressState() != ProgressState.inWORK && _operand.getProgressState() != ProgressState.inDRAFT) {
+ return false;
+ }
+ return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(_operand, _user);
}
/**
*/
public boolean canEditDescription () {
// ------------------------------------
- return (operand.getAuthor().equals(user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(operand, user));
+ return (_operand.getAuthor().equals(_user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(_operand, _user));
}
public boolean canEditProperties () {
// -----------------------------------
- return author;
+ return _author;
}
/**
*/
public boolean canPublish () {
// ----------------------------
- if (!author) return false;
- return (!operand.isPublic());
+ if (!_author) {
+ return false;
+ }
+ return (!_operand.isPublic());
}
public boolean canPurge () {
// --------------------------
- if (!author) return false;
- return operand.isVersioned();
+ if (!_author) {
+ return false;
+ }
+ return _operand.isVersioned();
}
public boolean canRemove () {
// ---------------------------
- if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
- return author;
+ if (_operand.getProgressState() != ProgressState.inWORK && _operand.getProgressState() != ProgressState.inDRAFT) {
+ return false;
+ }
+ return _author;
}
public boolean canVersion () {
// ----------------------------
- if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
- return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(operand, user);
+ if (_operand.getProgressState() != ProgressState.inWORK && _operand.getProgressState() != ProgressState.inDRAFT) {
+ return false;
+ }
+ return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(_operand, _user);
}
// ==============================================================================================================================
public Study getOperand () {
// --------------------------
- return operand;
+ return _operand;
}
}
\ No newline at end of file
import java.util.Map;
-import org.splat.log.AppLogger;
-
import net.sf.beanlib.PropertyInfo;
import net.sf.beanlib.spi.BeanTransformerSpi;
import net.sf.beanlib.spi.CustomBeanTransformerSpi;
+import org.splat.log.AppLogger;
+
/**
* DTO transformer used by BeanHelper.
*
/**
* The logger for the service.
*/
- public final static AppLogger logger = AppLogger
+ public final static AppLogger LOG = AppLogger
.getLogger(DTOTransformer.class);
/**
* the bean transformer.
*/
- private final BeanTransformerSpi _beanTransformer;
+ private final transient BeanTransformerSpi _beanTransformer;
/**
* Constructor.
public <T> boolean isTransformable(final Object from,
final Class<T> toClass, final net.sf.beanlib.PropertyInfo info) {
boolean ok = false;
- if (from != null) {
+ if (from == null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("From: null; To: " + toClass.getSimpleName());
+ }
+ } else {
String fromName = from.getClass().getSimpleName();
String toName = toClass.getSimpleName();
- if (logger.isDebugEnabled()) {
- logger.debug("From: " + fromName + "; To: " + toName);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("From: " + fromName + "; To: " + toName);
ok = (fromName.equals(toName + "DTO") || toName.equals(fromName
+ "DTO"));
}
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("From: null; To: " + toClass.getSimpleName());
- }
}
- if (logger.isDebugEnabled()) {
- logger.debug("Can transform from " + info.getFromBean() + "."
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Can transform from " + info.getFromBean() + "."
+ info.getPropertyName() + " to " + info.getToBean() + "."
+ info.getPropertyName() + ": " + ok);
}
*
* @see net.sf.beanlib.spi.Transformable#transform(java.lang.Object, java.lang.Class, net.sf.beanlib.PropertyInfo)
*/
+ @SuppressWarnings("unchecked")
public <T> T transform(final Object in, final Class<T> toClass,
final PropertyInfo info) {
- if (logger.isDebugEnabled()) {
- logger.debug("Transform " + in.getClass().getSimpleName() + ": "
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Transform " + in.getClass().getSimpleName() + ": "
+ in.toString() + " to " + toClass.getSimpleName());
}
Map<Object, Object> cloneMap = _beanTransformer.getClonedMap();
Object clone = cloneMap.get(in);
- if (clone != null) {
- return (T) clone;
- }
-
- if (logger.isDebugEnabled()) {
- logger.debug("Copy bean from " + info.getFromBean() + "."
- + info.getPropertyName() + " to " + info.getToBean() + "."
- + info.getPropertyName());
+ if (clone == null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Copy bean from " + info.getFromBean() + "."
+ + info.getPropertyName() + " to " + info.getToBean() + "."
+ + info.getPropertyName());
+ }
+ clone = BeanHelper.copyBean(in, toClass);
+ cloneMap.put(in, clone);
}
- clone = BeanHelper.copyBean(in, toClass);
- cloneMap.put(in, clone);
-
return (T) clone;
}
}
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
-<!-- Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012 -->
+<!-- Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012 -->
<bean id="persistentDAO" parent="genericDAO"
class="org.splat.dal.dao.kernel.PersistentDAOImpl">
class="org.splat.dal.dao.som.ScenarioDAOImpl">
</bean>
+ <bean id="descriptionAttributeDAO" parent="genericDAO"
+ class="org.splat.dal.dao.som.DescriptionAttributeDAOImpl">
+ </bean>
+
+ <bean id="commentAttributeDAO" parent="genericDAO"
+ class="org.splat.dal.dao.som.CommentAttributeDAOImpl">
+ </bean>
+
<bean id="usesRelationDAO" parent="genericDAO"
class="org.splat.dal.dao.som.UsesRelationDAOImpl">
</bean>
<property name="repositoryService" ref="repositoryService" />
</bean>
- <bean id="genericDAO" class="org.splat.dal.dao.kernel.GenericDAOImpl"
+ <bean id="genericDAO" class="org.splat.dal.dao.kernel.AbstractGenericDAOImpl"
abstract="true">
<property name="sessionFactory" ref="simanSessionFactory" />
</bean>
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import java.util.Vector;
import javax.servlet.ServletContext;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.NamedNodeMap;
import org.apache.log4j.Logger;
import org.splat.dal.bo.kernel.User;
-import org.splat.manox.XDOM;
import org.splat.dal.bo.som.Document;
-import org.splat.som.DocumentRights;
import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.bo.som.ProgressState;
+import org.splat.dal.bo.som.SimulationContext;
+import org.splat.manox.XDOM;
import org.splat.service.DocumentTypeService;
import org.splat.service.technical.ProjectSettingsService;
-import org.splat.simer.Converter;
-import org.splat.dal.bo.som.SimulationContext;
+import org.splat.som.DocumentRights;
import org.splat.som.Step;
import org.splat.som.StudyRights;
import org.splat.wapp.MenuItem;
-import org.splat.wapp.PopupMenu;
import org.splat.wapp.PopupItem;
+import org.splat.wapp.PopupMenu;
import org.splat.wapp.SimpleMenu;
import org.splat.wapp.ToolBar;
import org.springframework.web.context.ServletContextAware;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
public class ApplicationSettings implements ServletContextAware {
/**
* Application settings logger.
*/
- protected final static Logger logger = Logger
+ protected final static Logger LOG = Logger
.getLogger(ApplicationSettings.class);
/**
private String wappserver;
private String wappname;
- private Properties wapprops = new Properties(); // General properties from the application properties files
+ private final Properties wapprops = new Properties(); // General properties from the application properties files
private Locale locale; // Current user locale
- private Map<String, SimpleMenu> menus = new HashMap<String, SimpleMenu>(); // Application menus
+ private final Map<String, SimpleMenu> menus = new HashMap<String, SimpleMenu>(); // Application menus
private Map<Integer, ToolBar> bars = null; // Study module-bars structured by steps
private Map<String, PopupMenu> popups = null;
private Map<String, Map<String, Object>> filter = null; // Named search filters
private Map<String, String> tempfile = null; // Available template files
private String[] viewermap = null; // List of file extensions mapped to a viewer
private Map<String, Converter> convertmap = null; // Available document format converters
- private Properties jndprops = new Properties(); // JNDI context for launching converters
+ private final Properties jndprops = new Properties(); // JNDI context for launching converters
- private static ApplicationSettings my = null; // Singleton instance
+ private static ApplicationSettings my = new ApplicationSettings(); // Singleton instance
/**
* Injected project settings service.
*/
* @param projectSettingsService
* the projectSettingsService to set
*/
- public void setProjectSettings(ProjectSettingsService projectSettingsService) {
+ public void setProjectSettings(final ProjectSettingsService projectSettingsService) {
_projectSettingsService = projectSettingsService;
}
.confirmation("message.delete.study"));
}
- public boolean isEnabled(String name) {
- if (user == null)
+ @Override
+ public boolean isEnabled(final String name) {
+ if (user == null) {
return false; // Should not happen
+ }
Item item = Item.valueOf(name);
- if (item == Item.publish)
+ if (item == Item.publish) {
return user.canPublish();
- if (item == Item.edit)
+ }
+ if (item == Item.edit) {
return user.canEditProperties();
- if (item == Item.script)
+ }
+ if (item == Item.script) {
return user.canAddScenario();
- if (item == Item.version)
+ }
+ if (item == Item.version) {
return user.canVersion();
- if (item == Item.remove)
+ }
+ if (item == Item.remove) {
return user.canRemove();
- if (item == Item.purge)
+ }
+ if (item == Item.purge) {
return user.canPurge();
+ }
return false;
}
- public void setContext(String name, Object context) {
+ @Override
+ public void setContext(final String name, final Object context) {
if (context instanceof StudyRights) {
user = (StudyRights) context; // Just for optimizing
boolean history = user.getOperand().isVersioned();
PopupItem item = this.item("remove");
- if (history)
+ if (history) {
item.rename("menu.remove.version");
- else
+ } else {
item.rename("menu.remove.study");
+ }
}
}
}
"message.delete.document"));
}
- public boolean isEnabled(String name) {
- if (user == null)
+ @Override
+ public boolean isEnabled(final String name) {
+ if (user == null) {
return false; // Should not happen
+ }
Item item = Item.valueOf(name);
- if (item == Item.accept)
+ if (item == Item.accept) {
return user.canAccept();
- if (item == Item.promote)
+ }
+ if (item == Item.promote) {
return user.canPromote();
- if (item == Item.rename)
+ }
+ if (item == Item.rename) {
return user.canRename();
- if (item == Item.attach)
+ }
+ if (item == Item.attach) {
return user.canAttach();
- if (item == Item.version)
+ }
+ if (item == Item.version) {
return user.canVersion();
- if (item == Item.replace)
+ }
+ if (item == Item.replace) {
return user.canReplace();
- if (item == Item.purge)
+ }
+ if (item == Item.purge) {
return user.canPurge();
- if (item == Item.remove)
+ }
+ if (item == Item.remove) {
return user.canRemove();
+ }
return false;
}
- public void setContext(String name, Object context) {
+ @Override
+ public void setContext(final String name, final Object context) {
if (context instanceof DocumentRights) {
user = (DocumentRights) context; // Just for optimizing
Document downer = user.getOperand();
PopupItem item = this.item("remove");
- if (downer.isVersioned())
+ if (downer.isVersioned()) {
item.rename("menu.remove.version");
- else
+ } else {
item.rename("menu.remove.document");
+ }
}
}
}
"notyetimplemented").confirmation("message.purge.document"));
}
- public boolean isEnabled(String name) {
- if (user == null)
+ @Override
+ public boolean isEnabled(final String name) {
+ if (user == null) {
return false; // Should not happen
+ }
Item item = Item.valueOf(name);
- if (item == Item.demote)
+ if (item == Item.demote) {
return user.canDemote();
- if (item == Item.promote)
+ }
+ if (item == Item.promote) {
return user.canReview();
- if (item == Item.attach)
+ }
+ if (item == Item.attach) {
return user.canAttach();
- if (item == Item.version)
+ }
+ if (item == Item.version) {
return user.canVersion();
- if (item == Item.purge)
+ }
+ if (item == Item.purge) {
return user.canPurge();
+ }
return false;
}
- public void setContext(String name, Object context) {
+ @Override
+ public void setContext(final String name, final Object context) {
if (context instanceof DocumentRights) {
user = (DocumentRights) context; // Just for optimizing
}
private static class NotResultDocumentPopup extends PopupMenu {
// ----------------------------------------------------------------
- private DocumentRights user = null;
+ private final DocumentRights user = null;
private NotResultDocumentPopup() {
addItem("demote", new PopupItem("menu.demote").icon(
.confirmation("message.approve.document"));
}
- public boolean isEnabled(String name) {
- if (user == null)
+ @Override
+ public boolean isEnabled(final String name) {
+ if (user == null) {
return false; // Should not happen
+ }
Item item = Item.valueOf(name);
- if (item == Item.undo)
+ if (item == Item.undo) {
return user.canInvalidate();
- if (item == Item.demote)
+ }
+ if (item == Item.demote) {
return user.canDemote();
- if (item == Item.approve)
+ }
+ if (item == Item.approve) {
return user.canApprove();
+ }
return false;
}
- public void setContext(String name, Object context) {
+ @Override
+ public void setContext(final String name, final Object context) {
if (context instanceof DocumentRights) {
user = (DocumentRights) context; // Just for optimizing
}
"message.delete.document"));
}
- public boolean isEnabled(String name) {
- if (user == null)
+ @Override
+ public boolean isEnabled(final String name) {
+ if (user == null) {
return false; // Should not happen
+ }
Item item = Item.valueOf(name);
- if (item == Item.rename)
+ if (item == Item.rename) {
return user.canRename();
- if (item == Item.replace)
+ }
+ if (item == Item.replace) {
return user.canReplace();
- if (item == Item.remove)
+ }
+ if (item == Item.remove) {
return user.canRemove();
+ }
return false;
}
- public void setContext(String name, Object context) {
+ @Override
+ public void setContext(final String name, final Object context) {
if (context instanceof DocumentRights) {
user = (DocumentRights) context; // Just for optimizing
}
"message.delete.context"));
}
- public boolean isEnabled(String name) {
+ @Override
+ public boolean isEnabled(final String name) {
Item item = Item.valueOf(name);
if (item == Item.rename) {
return true;
}
- public void setContext(String name, Object context) {
+ @Override
+ public void setContext(final String name, final Object context) {
if (context instanceof SimulationContextFacade) {
owner = (SimulationContextFacade) context; // Just for optimizing
} else {
"message.delete.knowledge"));
}
- public boolean isEnabled(String name) {
+ @Override
+ public boolean isEnabled(final String name) {
Item item = Item.valueOf(name);
if (item == Item.promote) {
- if (owner.getProgressState() != ProgressState.inDRAFT)
+ if (owner.getProgressState() != ProgressState.inDRAFT) {
return false;
+ }
} else if (item == Item.demote) {
- if (owner.getProgressState() != ProgressState.inCHECK)
+ if (owner.getProgressState() != ProgressState.inCHECK) {
return false;
+ }
}
return true;
}
- public void setContext(String name, Object context) {
- if (context instanceof KnowledgeElement)
+ @Override
+ public void setContext(final String name, final Object context) {
+ if (context instanceof KnowledgeElement) {
owner = (KnowledgeElement) context; // Just for optimizing
- else {
+ } else {
super.setContext(name, context);
}
}
// ==============================================================================================================================
public static ApplicationSettings getMe() {
- // ------------------------------------------
- if (my == null) {
- my = new ApplicationSettings();
- }
return my; // The application is supposed being previously created below
}
* @param lang
* @return
*/
- public ApplicationSettings init(String wappurl, Locale lang)
+ public ApplicationSettings init(final String wappurl, final Locale lang)
throws IOException {
ClassLoader cloader = getClass().getClassLoader();
String[] wurl = wappurl.split("/"); // [0]="http:", [1]="", [2]="{server}:{port}", [3]="name"
wapprops.load(cloader.getResourceAsStream(wappname + ".properties"));
jndprops.load(cloader.getResourceAsStream("jndi.properties"));
- logger.info("Application root set to "
+ LOG.info("Application root set to "
+ wapprops.getProperty("wapp.root"));
if (my == null) {
my = this;
// Public member functions
// ==============================================================================================================================
- public void configure(String filename) {
+ public void configure(final String filename) {
// ---------------------------------------
// Non customizable settings
menus.clear();
fprop.put("author", "0");
fprop.put("reference", "");
fprop.put("title", "");
- fprop.put("context", new Vector<SimulationContext>());
+ fprop.put("context", new ArrayList<SimulationContext>());
Map<String, Object> gprop = new HashMap<String, Object>();
gprop.put("visibility", "PUBLIC");
gprop.put("author", "0");
gprop.put("reference", "");
gprop.put("title", "");
- gprop.put("context", new Vector<SimulationContext>());
+ gprop.put("context", new ArrayList<SimulationContext>());
defdoctype = new LinkedHashMap<String, DocumentType>();
tempfile = new HashMap<String, String>();
if (config.exists()) {
loadCustomization(config); // Sets default document types, installed modules and available templates
} else {
- logger.info("Could not find the application configuration file \""
+ LOG.info("Could not find the application configuration file \""
+ config.getAbsolutePath() + "\", using default settings");
}
// Settings based on the customization
.hasNext();) {
ProjectSettingsService.Step step = i.next();
List<String> formats = getDefaultFormats(step);
- if (formats.size() == 0)
+ if (formats.size() == 0) {
continue;
+ }
ToolBar bar = new ToolBar(24); // Height of the module-bar
HashSet<String> module = new HashSet<String>(); // For not duplicating modules
for (Iterator<String> j = formats.iterator(); j.hasNext();) {
String format = j.next();
String command = getApplicationProperty("executable." + format);
- if (command == null)
+ if (command == null) {
continue; // Module not installed
- if (module.contains(command))
+ }
+ if (module.contains(command)) {
continue;
+ }
module.add(command);
String[] parsed = command.split("/");
String[] name = parsed[parsed.length - 1].split("\\x2E");
File image = new File(ApplicationSettings
.getApplicationSkinPath()
+ icon);
- if (!image.exists())
+ if (!image.exists()) {
icon = "tool.any.png";
+ }
bar.addTool(tool, icon, command);
} else {
docname = "/jsp/newDocument.jsp?type=" + docname;
File image = new File(ApplicationSettings
.getApplicationSkinPath()
+ icon);
- if (!image.exists())
+ if (!image.exists()) {
icon = "tool.any.png";
+ }
bar.addTool(name[0], icon, command, docname);
}
}
- if (!bar.isEmpty())
+ if (!bar.isEmpty()) {
bars.put(step.getNumber(), bar);
+ }
}
}
- public String getApplicationProperty(String name) {
+ public String getApplicationProperty(final String name) {
return wapprops.getProperty(name); // May be null
}
return url.toString();
}
- public Map<String, Object> getFilter(String name) {
+ public Map<String, Object> getFilter(final String name) {
// --------------------------------------------------
return filter.get(name);
}
- public ToolBar getModuleBar(Step step) {
+ public ToolBar getModuleBar(final Step step) {
// -----------------------------------------
return bars.get(step.getNumber());
}
return my.getApplicationRootPath() + "skin/";
}
- public static Converter getConverter(DocumentType type, String format) {
+ public static Converter getConverter(final DocumentType type, final String format) {
// -----------------------------------------------------------------------
return my.convertmap.get(format + type.getName()); // May be null;
}
- public static DocumentType getDefaultDocumentType(Step step, String format) {
+ public static DocumentType getDefaultDocumentType(final Step step, final String format) {
// ----------------------------------------------------------------------------
String[] table = format.split("\\x2E");
return my.defdoctype.get(step.getNumber() + "."
+ table[table.length - 1]); // May be null
}
- public static String getDownloadURL(User user) {
+ public static String getDownloadURL(final User user) {
// --------------------------------------------------
StringBuffer url = new StringBuffer("http://").append(my.wappserver)
.append("/download/").append(user.getUsername()).append("/");
return my.locale;
}
- public static SimpleMenu getMenu(String name) {
+ public static SimpleMenu getMenu(final String name) {
// ----------------------------------------------
return my.menus.get(name);
}
- public static PopupMenu getPopupMenu(String name) {
+ public static PopupMenu getPopupMenu(final String name) {
// --------------------------------------------------
return my.popups.get(name);
}
// ---------------------------------------------
String[] code = my.wapprops.getProperty("locale.supported").split(",");
Locale[] result = new Locale[code.length];
- for (int i = 0; i < code.length; i++)
+ for (int i = 0; i < code.length; i++) {
result[i] = new Locale(code[i]);
+ }
return result;
}
// Private services
// ==============================================================================================================================
- private List<String> getDefaultFormats(ProjectSettingsService.Step step) {
+ private List<String> getDefaultFormats(final ProjectSettingsService.Step step) {
// ------------------------------------------------------------------
Set<String> keys = defdoctype.keySet();
int number = step.getNumber();
- Vector<String> result = new Vector<String>();
+ List<String> result = new ArrayList<String>();
for (Iterator<String> i = keys.iterator(); i.hasNext();) {
String[] key = i.next().split("\\x2E");
- if (Integer.valueOf(key[0]) != number)
+ if (Integer.valueOf(key[0]) != number) {
continue;
- if (key[1].equals("pdf"))
+ }
+ if (key[1].equals("pdf")) {
continue; // PDF is not an authoring format
+ }
result.add(key[1]); // Formats are unique
}
return result;
}
- private void loadCustomization(File config) {
+ private void loadCustomization(final File config) {
// --------------------------------------------
try {
DocumentBuilderFactory dfactory = javax.xml.parsers.DocumentBuilderFactory
}
for (int i = 0; i < nlist.getLength(); i++) {
child = nlist.item(i);
- if (!child.getNodeName().equals("step"))
+ if (!child.getNodeName().equals("step")) {
continue;
+ }
String nstep = child.getAttributes().getNamedItem("number")
.getNodeValue();
NodeList map = child.getChildNodes();
for (int j = 0; j < map.getLength(); j++) {
child = map.item(j);
- if (!child.getNodeName().equals("mapping"))
+ if (!child.getNodeName().equals("mapping")) {
continue;
+ }
NamedNodeMap natr = child.getAttributes();
String dext = natr.getNamedItem("extension").getNodeValue();
String type = natr.getNamedItem("type").getNodeValue();
nlist = child.getChildNodes();
for (int i = 0; i < nlist.getLength(); i++) {
child = nlist.item(i);
- if (!child.getNodeName().equals("mapping"))
+ if (!child.getNodeName().equals("mapping")) {
continue;
+ }
NamedNodeMap natr = child.getAttributes();
String dext = natr.getNamedItem("extension").getNodeValue();
nlist = child.getChildNodes();
for (int i = 0; i < nlist.getLength(); i++) {
child = nlist.item(i);
- if (!child.getNodeName().equals("document"))
+ if (!child.getNodeName().equals("document")) {
continue;
+ }
NamedNodeMap natr = child.getAttributes();
String type = natr.getNamedItem("type").getNodeValue();
tempfile.put(type, file);
}
} catch (Exception error) {
- logger.info("Error in customization", error);
+ LOG.info("Error in customization", error);
}
}
* @param documentTypeService
* the documentTypeService to set
*/
- public void setDocumentTypeService(DocumentTypeService documentTypeService) {
+ public void setDocumentTypeService(final DocumentTypeService documentTypeService) {
_documentTypeService = documentTypeService;
}
* @see org.apache.struts2.util.ServletContextAware#setServletContext(javax.servlet.ServletContext)
*/
@Override
- public void setServletContext(ServletContext context) {
+ public void setServletContext(final ServletContext context) {
_servletContext = context;
}
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.Vector;
+import java.util.Map;
import org.splat.dal.bo.kernel.User;
import org.splat.dal.bo.som.Document;
public abstract class OpenObject implements Proxy {
- protected static HashMap<Long, DocumentFacade> docpres = null;
- protected static HashMap<Long, KnowledgeElementFacade> knowpres = null;
+ protected static Map<Long, DocumentFacade> docpres = null;
+ protected static Map<Long, KnowledgeElementFacade> knowpres = null;
/**
* Connected user.
public List<Document> collectInvolvedDocuments(final DocumentType type) {
// ------------------------------------------------------------------
- List<Document> found = new Vector<Document>();
+ List<Document> found = new ArrayList<Document>();
for (Iterator<Step> i = involving.iterator(); i.hasNext();) {
Step step = i.next();
List<Publication> exist = step.getAllDocuments();
current = more.next();
}
- knowledge = new Vector<KnowledgeIterator>(types.size());
+ knowledge = new ArrayList<KnowledgeIterator>(types.size());
for (Iterator<KnowledgeElementType> i = types.iterator(); i
.hasNext();) {
KnowledgeElementType type = i.next();
- List<KnowledgeElementFacade> display = new Vector<KnowledgeElementFacade>(
+ List<KnowledgeElementFacade> display = new ArrayList<KnowledgeElementFacade>(
kelms.size());
while (current != null && current.getType().equals(type)) {
KnowledgeElementFacade facade = knowpres.get(current
if (ustep.mayContain(Document.class)) {
List<Publication> list = ustep.getAllDocuments();
- contents = new Vector<DocumentFacade>(list.size());
+ contents = new ArrayList<DocumentFacade>(list.size());
for (Iterator<Publication> i = list.iterator(); i.hasNext();) {
Publication present = i.next();
Long index = present.getIndex();