testng-6.8.jar is added to Siman-Common.
<classpathentry exported="true" kind="lib" path="lib/antlr-2.7.6.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-collections-3.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/dom4j-1.6.1.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/hibernate-3.5.jar" sourcepath="/3dparty_src/hibernate/hibernate-distribution-3.5.3-Final-dist.zip"/>
<classpathentry exported="true" kind="lib" path="lib/jta-1.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/log4j-1.2.15.jar"/>
<classpathentry exported="true" kind="lib" path="lib/lucene-core-2.9.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/lucene-queries-2.9.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/mailapi.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/mysql-connector-java-5.1.5-bin.jar"/>
<classpathentry exported="true" kind="lib" path="lib/poi-3.7-20101029.jar"/>
<classpathentry exported="true" kind="lib" path="lib/poi-ooxml-3.7-20101029.jar"/>
<classpathentry exported="true" kind="lib" path="lib/poi-ooxml-schemas-3.7-20101029.jar"/>
<classpathentry exported="true" kind="lib" path="lib/p6spy.jar"/>
<classpathentry exported="true" kind="lib" path="lib/aopalliance.jar"/>
<classpathentry exported="true" kind="lib" path="dist/siman-common.jar" sourcepath="src"/>
+ <classpathentry kind="lib" path="lib/testng-6.8.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/commons-logging-1.1.1.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/beanlib-5.0.1beta.jar"/>
+ <classpathentry kind="lib" path="lib/hibernate-3.5.jar"/>
+ <classpathentry kind="lib" path="lib/mysql-connector-java-5.1.5-bin.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<config>src/spring/businessServiceContext.xml</config>
<config>src/spring/technicalServiceContext.xml</config>
<config>src/spring/daoContext.xml</config>
+ <config>src/spring/datasourceContext.xml</config>
+ <config>src/test/spring/ut-applicationContext.xml</config>
+ <config>src/test/spring/ut-datasourceContext.xml</config>
</configs>
<configSets>
<configSet>
<config>src/spring/businessServiceContext.xml</config>
<config>src/spring/technicalServiceContext.xml</config>
<config>src/spring/daoContext.xml</config>
+ <config>src/spring/datasourceContext.xml</config>
+ </configs>
+ </configSet>
+ <configSet>
+ <name><![CDATA[Siman Unit Tests Beans]]></name>
+ <allowBeanDefinitionOverriding>true</allowBeanDefinitionOverriding>
+ <incomplete>false</incomplete>
+ <configs>
+ <config>src/spring/businessServiceContext.xml</config>
+ <config>src/spring/daoContext.xml</config>
+ <config>src/spring/globalContext.xml</config>
+ <config>src/spring/technicalServiceContext.xml</config>
+ <config>src/test/spring/ut-applicationContext.xml</config>
+ <config>src/test/spring/ut-datasourceContext.xml</config>
</configs>
</configSet>
</configSets>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "../WebContent/META-INF/dtds/log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <!-- Configuration for unit tests -->
+
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%t] %-5p %-11c{1} - %m%n"/>
+ </layout>
+ </appender>
+
+ <appender name="logfile" class="org.apache.log4j.RollingFileAppender">
+ <param name="File" value="${catalina.home}/logs/siman.log" />
+ <param name="MaxFileSize" value="500KB" />
+ <param name="MaxBackupIndex" value="10" />
+ <param name="Append" value="false" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%t] %-5p %-11c{1} - %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- specify the logging level for loggers from other libraries -->
+ <logger name="com.opensymphony">
+ <level value="INFO" />
+ </logger>
+
+ <logger name="org.apache.struts2">
+ <level value="INFO" />
+ </logger>
+
+ <logger name="log4j.logger.org.apache.struts">
+ <level value="DEBUG" />
+ </logger>
+
+ <logger name="org.springframework">
+ <level value="INFO" />
+ </logger>
+
+ <logger name="org.hibernate">
+ <level value="DEBUG" />
+ </logger>
+
+ <logger name="org.splat.siman">
+ <level value="DEBUG" />
+ </logger>
+
+ <logger name="test">
+ <level value="DEBUG" />
+ </logger>
+
+ <logger name="log4j.logger.org.hibernate">
+ <level value="DEBUG" />
+ </logger>
+
+ <category name="com.opensymphony.xwork2.validator">
+ <priority value="INFO"/>
+ </category>
+
+ <category name="org.apache.struts2.interceptor.validation">
+ <priority value="INFO"/>
+ </category>
+
+
+ <!-- for all other loggers log only debug and above log messages -->
+ <root>
+ <priority value="INFO"/>
+ <appender-ref ref="logfile" />
+ <appender-ref ref="console"/>
+ </root>
+
+</log4j:configuration>
<!-- <id name="rid" column="rid" access="field">
<generator class="sequence"/>
</id> -->
- <id name="rid" column="rid" access="field">
+ <id name="rid" column="rid" access="field" type="long">
<generator class="org.hibernate.id.enhanced.SequenceStyleGenerator">
<param name="sequence_name">persistent_id</param>
<param name="initial_value">1000</param>
public abstract class Persistent {
- private int rid; // Primary key of persistent objects
+ private long rid; // Primary key of persistent objects
protected abstract static class Properties implements ObjectProperties {
// ----------------------------------------------------------------------
if (entity == null) return false;
if (entity.getClass().equals(this.getClass())) {
Persistent object = (Persistent)entity;
- int he = object.getIndex(); // getIndex() is supposed fetching the index if not yet done
- int me = this.getIndex(); // getIndex() is supposed fetching the index if not yet done
+ long he = object.getIndex(); // getIndex() is supposed fetching the index if not yet done
+ long me = this.getIndex(); // getIndex() is supposed fetching the index if not yet done
if (me*he != 0) return (he == me);
if (me+he == 0) return (this == object);
}
* @return the PID of this, or 0 if this is not saved.
* @see isSaved()
*/
- public int getIndex () {
+ public long getIndex () {
// ----------------------
return rid;
}
+ /**
+ * Set an id for the object.
+ * @param anId id to set
+ */
+ public void setIndex(long anId) {
+ rid = anId;
+ }
+
public int hashCode () {
// ----------------------
return toString().hashCode();
*/
public String toString () {
// -------------------------
- int oid = getIndex(); // getIndex() is supposed fetching the index if not yet done
+ 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();
}
<!-- Class User
-->
- <union-subclass name="org.splat.dal.bo.kernel.User" extends="org.splat.dal.bo.kernel.Persistent" table="user" lazy="false">
+ <union-subclass name="org.splat.dal.bo.kernel.User" extends="org.splat.dal.bo.kernel.Persistent" table="users" lazy="false">
<!-- <natural-id>-->
<property name="username" column="username" access="field" />
<many-to-one name="role" column="username" insert="false" update="false" unique="true" cascade="save-update" access="field" />
.uniqueResult();
}
- public static DocumentType selectType(int index) {
+ public static DocumentType selectType(long index) {
// -------------------------------------------------
String query = new StringBuffer("from DocumentType where rid='")
.append(index).append("'").toString();
} else
if (entity instanceof DocumentType) {
DocumentType object = (DocumentType)entity;
- int he = object.getIndex();
- int me = this.getIndex();
+ long he = object.getIndex();
+ long me = this.getIndex();
if (me*he != 0) return (he == me);
else return this.getName().equals(object.getName());
} else {
protected KnowledgeElementType () {
}
// Initialization constructor
- protected KnowledgeElementType (String name) {
+ public KnowledgeElementType (String name) {
// --------------------------------------------
super();
this.name = name;
} else
if (entity instanceof KnowledgeElementType) {
KnowledgeElementType object = (KnowledgeElementType)entity;
- int he = object.getIndex();
- int me = this.getIndex();
+ long he = object.getIndex();
+ long me = this.getIndex();
if (me*he != 0) return (he == me);
else return this.getName().equals(object.getName());
} else {
*/
public Publication getPublication (Document doc) {
// ------------------------------------------------
- int index = doc.getIndex();
+ long index = doc.getIndex();
for (Iterator<Publication> i=docums.iterator(); i.hasNext(); ) {
Publication found = i.next();
if (found.value().getIndex() == index) return found; // A document publication is unique in a given ProjectElement
public boolean publishes (Document doc) {
// ---------------------------------------
- int index = doc.getIndex();
+ long index = doc.getIndex();
for (Iterator<Publication> i=docums.iterator(); i.hasNext(); ) {
Document found = i.next().value();
if (found.getIndex() == index) return true;
private Set<KnowledgeElement> kelms;
// Transient fields
- private HashMap<Integer, List<KnowledgeElement>> known;
+ private HashMap<Long, List<KnowledgeElement>> known;
private List<KnowledgeElement> knowl; // Copy of kelms excluding the internal Knowledge Element (ucase below)
private KnowledgeElement ucase; // Internal Knowledge Element for accessing to all used simulation contexts
return Collections.unmodifiableList(knowl);
}
- public KnowledgeElement getKnowledgeElement (int index) {
+ public KnowledgeElement getKnowledgeElement (long l) {
// -------------------------------------------------------
for (Iterator<KnowledgeElement> i=kelms.iterator(); i.hasNext();) {
KnowledgeElement mykelm = i.next();
- if (mykelm.getIndex() == index) return mykelm;
+ if (mykelm.getIndex() == l) return mykelm;
}
return null;
}
public List<KnowledgeElement> getKnowledgeElementsOf (KnowledgeElementType type) {
// --------------------------------------------------------------------------------
if (kelms.isEmpty()) return new Vector<KnowledgeElement>(); // Smarter than returning null
- if (known == null) known = new HashMap<Integer, List<KnowledgeElement>>();
+ if (known == null) known = new HashMap<Long, List<KnowledgeElement>>();
- int numtype = type.getIndex();
+ long numtype = type.getIndex();
List<KnowledgeElement> listype = known.get(numtype);
if (listype == null) {
listype = new Vector<KnowledgeElement>();
} else
if (entity instanceof SimulationContextType) {
SimulationContextType object = (SimulationContextType)entity;
- int he = object.getIndex();
- int me = this.getIndex();
+ long he = object.getIndex();
+ long me = this.getIndex();
if (me*he != 0) return (he == me);
else return this.getName().equals(object.getName());
} else {
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.apache.log4j.Logger;
-public abstract class Database implements ApplicationContextAware {
+public abstract class Database implements ApplicationContextAware {
/**
* The ApplicationContext.
import java.io.Serializable;
/**
- * @author rkv
+ * Generic DAO interface.
*
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ *
+ * @param <T>
+ * Persistent object class
+ * @param <PK>
+ * Primary key class
*/
public interface GenericDAO<T, PK extends Serializable> {
- /** Persist the newInstance object into database */
+ /**
+ * Persist the newInstance object into database.
+ *
+ * @param newInstance
+ * new object as a transient instance
+ * @return new primary key for the created persistent object
+ */
PK create(T newInstance);
/**
- * Retrieve an object that was previously persisted to the database using the indicated id as primary key
+ * 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
*/
T read(PK id);
- /** Save changes made to a persistent object. */
+ /** Save changes made to a persistent object.
+ * @param transientObject transient instance of the object to update
+ */
void update(T transientObject);
- /** Remove an object from persistent storage in the database */
+ /** Remove an object from persistent storage in the database.
+ * @param persistentObject a persistent object to delete from the database
+ */
void delete(T persistentObject);
}
import org.hibernate.Session;
import org.hibernate.SessionFactory;
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
- * @author rkv
+ * 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> implements
+public abstract class GenericDAOImpl<T, PK extends Serializable> extends HibernateDaoSupport implements
GenericDAO<T, PK> {
- private SessionFactory _sessionFactory;
+// /**
+// * Hibernate session factory.
+// */
+// private SessionFactory _sessionFactory;
- public PK create(T o) {
- return (PK) getSession().save(o);
+ /**
+ * 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 read(PK id) {
return (T) getSession().get(getType(), id);
}
- public void update(T o) {
- getSession().update(o);
- }
-
- public void delete(T o) {
- getSession().delete(o);
- }
-
- abstract protected Class<T> getType();
- /**
- * @return hibernate session
+ /** Save changes made to a persistent object.
+ * @param transientObject transient instance of the object to update
*/
- private Session getSession() {
- return getSessionFactory().getCurrentSession();
+ public void update(T transientObject) {
+ getSession().update(transientObject);
}
-
- /**
- * Get the sessionFactory.
- * @return the sessionFactory
+
+ /** Remove an object from persistent storage in the database.
+ * @param persistentObject a persistent object to delete from the database
*/
- public SessionFactory getSessionFactory() {
- return _sessionFactory;
+ public void delete(T persistentObject) {
+ getSession().delete(persistentObject);
}
/**
- * Set the sessionFactory.
- * @param sessionFactory the sessionFactory to set
+ * Get persistent object type.
+ * @return Persistent object class to be processed by this DAO
*/
- public void setSessionFactory(SessionFactory sessionFactory) {
- _sessionFactory = sessionFactory;
- }
+ abstract protected Class<T> getType();
+
+// /**
+// * Get the current hibernate session factory.
+// * @return hibernate session
+// */
+// private Session getSession() {
+// return getSessionFactory().getCurrentSession();
+// }
+//
+// /**
+// * Get the hibernate session factory.
+// * @return the hibernate session factory
+// */
+// public SessionFactory getSessionFactory() {
+// return _sessionFactory;
+// }
+//
+// /**
+// * Set the hibernate session factory.
+// * @param sessionFactory the hibernate session factory to set
+// */
+// public void setSessionFactory(SessionFactory sessionFactory) {
+// _sessionFactory = sessionFactory;
+// }
}
\ No newline at end of file
import org.splat.dal.dao.kernel.GenericDAO;
/**
- * @author RKV
+ * KnowledgeElement DAO class implementation.
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
*
*/
public interface KnowledgeElementDAO extends GenericDAO<KnowledgeElement, Long> {
import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.springframework.transaction.annotation.Transactional;
/**
* Knowledge element DAO.
public interface Name {
- public int getIndex ();
+ public long getIndex ();
public String toString ();
}
\ No newline at end of file
if (!xtag.equals("users")) throw new MismatchException("filetype");
org.w3c.dom.NodeList ulist = inDoc.getElementsByTagName("user");
- List<String> result = (List<String>)session.createSQLQuery("SELECT * FROM user").addScalar("username").list();
+ List<String> result = (List<String>)session.createSQLQuery("SELECT * FROM users").addScalar("username").list();
HashSet<String> members = new HashSet<String>();
HashSet<User> imported = new HashSet<User>();
for (Iterator<String> i=result.iterator(); i.hasNext();) members.add(i.next());
@SuppressWarnings("unchecked") // For the casting List<User>
public static List<User> selectAllUsers () {
// ------------------------------------------
- String query = "from User order by last asc, first asc";
+ String query = "FROM users order by last asc, first asc";
return (List<User>)Database.getSession().createQuery(query).list();
}
public static User selectUser (String username) {
// -----------------------------------------------
- StringBuffer query = new StringBuffer("from User where username='").append(username).append("'");
+ StringBuffer query = new StringBuffer("FROM users where username='").append(username).append("'");
return (User)Database.getSession().createQuery(query.toString()).uniqueResult();
}
// ----------------------------------------------------------------
//WARNING: For not encoding the password here, we better call a selectUsersWhere(User.Properties),
// but this requires a getPassword in User.Properties nested class.
- StringBuffer query = new StringBuffer("from User where username='").append(username).append("' and password");
+ StringBuffer query = new StringBuffer("FROM users where username='").append(username).append("' and password");
if (password == null) query = query.append(" is null");
else query = query.append("='").append(String.valueOf(password.hashCode())).append("'");
public static User selectUser (int index) {
// -----------------------------------------
- StringBuffer query = new StringBuffer("from User where rid='").append(index).append("'");
+ StringBuffer query = new StringBuffer("FROM users where rid='").append(index).append("'");
return (User)Database.getSession().createQuery(query.toString()).uniqueResult();
}
@SuppressWarnings("unchecked")
public static List<User> selectUsersWhere (User.Properties... uprop) {
// --------------------------------------------------------------------
- StringBuffer query = new StringBuffer("from User");
+ StringBuffer query = new StringBuffer("FROM users");
String separator = " where (";
String value;
public void rename(KnowledgeElement knowledgeElement, String title)
throws InvalidPropertyException;
- public KnowledgeElement selectKnowledgeElement(int index);
+ public KnowledgeElement selectKnowledgeElement(long index);
}
update(knowledgeElement);
}
- public KnowledgeElement selectKnowledgeElement(int index) {
+ public KnowledgeElement selectKnowledgeElement(long index) {
// -----------------------------------------------------------------
StringBuffer query = new StringBuffer(
"from KnowledgeElement where rid='").append(index).append("'");
public int generateLocalIndex(Study aStudy);
- public Study selectStudy(int index);
+ public Study selectStudy(long index);
public Study createStudy(Study.Properties sprop)
throws MissedPropertyException, InvalidPropertyException,
return resList;
}
- public Study selectStudy(int index) {
+ public Study selectStudy(long index) {
// -------------------------------------------
StringBuffer query = new StringBuffer("from Study where rid='").append(
index).append("'");
* for selecting the corresponding persistent object from the database.
* @return the internal persistent identifier of the object represented by this proxy.
*/
- public Integer getIndex ();
+ public Long getIndex ();
public ProgressState getProgressState ();
}
public static class ObjectProxy implements Proxy, Serializable {
// --------------------------------------------------------------
- private int rid;
+ private Long rid;
private String sid;
private ProgressState state;
private String title;
private static final long serialVersionUID = -4386494192709562221L;
public ObjectProxy (org.apache.lucene.document.Document ludoc) {
- rid = Integer.valueOf(ludoc.get("index"));
+ rid = Long.valueOf(ludoc.get("index"));
sid = ludoc.get("ref");
state = ProgressState.valueOf(ludoc.get("state"));
title = ludoc.get("title");
public String getAuthorName () {
return name;
}
- public Integer getIndex () {
+ public Long getIndex () {
return rid;
}
public ProgressState getProgressState () {
return Collections.unmodifiableList(contex);
}
- public Publication getDocument (int index) {
+ public Publication getDocument (long l) {
// ------------------------------------------
for (Iterator<Publication> i=docums.iterator(); i.hasNext();) {
Publication found = i.next(); // In a given study step,
- if (found.value().getIndex() == index) return found; // there is only one publication of a given document
+ if (found.value().getIndex() == l) return found; // there is only one publication of a given document
}
return null;
}
return step;
}
- public SimulationContext getSimulationContext (int index) {
+ public SimulationContext getSimulationContext (long l) {
// ---------------------------------------------------------
for (Iterator<SimulationContext> i=owner.SimulationContextIterator(); i.hasNext();) {
SimulationContext myctex = i.next();
- if (myctex.getIndex() == index) return myctex;
+ if (myctex.getIndex() == l) return myctex;
}
return null;
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans
+http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+http://www.springframework.org/schema/aop
+http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+http://www.springframework.org/schema/context
+http://www.springframework.org/schema/context/spring-context-3.0.xsd
+http://www.springframework.org/schema/tx
+http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
+
+ <!-- <bean id="simanDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+ <property name="jndiName" value="jdbc/ibatis"/>
+ </bean> -->
+
+ <!-- <bean id="simanDatasource"
+ class="org.springframework.jdbc.datasource.DriverManagerDataSource">
+ <property name="driverClassName"
+ value="${connection.driver_class}" />
+ <property name="url" value="${connection.url}" />
+ <property name="username" value="${connection.username}" />
+ <property name="password" value="${connection.password}" />
+ </bean>
+ -->
+
+ <bean id="simanDatasource"
+ class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
+ <property name="driverClassName"
+ value="${connection.driver_class}" />
+ <property name="url" value="${connection.url}" />
+ <property name="username" value="${connection.username}" />
+ <property name="password" value="${connection.password}" />
+ <property name="suppressClose" value="true" />
+ <property name="autoCommit" value="false" />
+ </bean>
+
+ <bean id="p6spySimanDatasource"
+ class="com.p6spy.engine.spy.P6DataSource">
+ <constructor-arg>
+ <ref local="simanDatasource" />
+ </constructor-arg>
+ </bean>
+
+
+ <bean id="hibernateProperties"
+ class="org.springframework.beans.factory.config.PropertiesFactoryBean">
+ <property name="properties">
+ <props>
+ <!-- normal properties -->
+ </props>
+ </property>
+ <!-- hibernate.config should be defined somewhere in the spring.properties layers -->
+ <property name="locations">
+ <list>
+ <value>classpath:${hibernate.config.file}</value>
+ </list>
+ </property>
+ </bean>
+
+ <bean id="simanSessionFactory"
+ class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
+ <property name="dataSource" ref="simanDatasource" />
+<!-- <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />-->
+
+ <property name="mappingResources">
+ <list>
+ <value>
+ org/splat/dal/bo/kernel/Persistent.hbm.xml
+ </value>
+ <value>org/splat/dal/bo/kernel/Any.hbm.xml</value>
+ <value>org/splat/dal/bo/kernel/Entity.hbm.xml</value>
+ <value>org/splat/dal/bo/kernel/Attribute.hbm.xml</value>
+ <value>org/splat/dal/bo/kernel/Relation.hbm.xml</value>
+ <value>
+ org/splat/dal/bo/kernel/TextAttribute.hbm.xml
+ </value>
+ <value>org/splat/dal/bo/kernel/User.hbm.xml</value>
+
+ <value>
+ org/splat/dal/bo/som/ProjectElement.hbm.xml
+ </value>
+ <value>org/splat/dal/bo/som/Study.hbm.xml</value>
+ <value>org/splat/dal/bo/som/Scenario.hbm.xml</value>
+ <value>org/splat/dal/bo/som/Attributes.hbm.xml</value>
+ <value>org/splat/dal/bo/som/Relations.hbm.xml</value>
+ <value>org/splat/dal/bo/som/File.hbm.xml</value>
+ <value>org/splat/dal/bo/som/Document.hbm.xml</value>
+ <value>org/splat/dal/bo/som/Publication.hbm.xml</value>
+ <value>
+ org/splat/dal/bo/som/ValidationCycle.hbm.xml
+ </value>
+ <value>org/splat/dal/bo/som/Timestamp.hbm.xml</value>
+ <value>
+ org/splat/dal/bo/som/SimulationContext.hbm.xml
+ </value>
+ <value>
+ org/splat/dal/bo/som/KnowledgeElement.hbm.xml
+ </value>
+ <value>org/splat/dal/bo/som/IDBuilder.hbm.xml</value>
+ </list>
+ </property>
+ <!-- hibernate.connection.driver_class=com.p6spy.engine.spy.P6SpyDriver -->
+
+ <property name="hibernateProperties">
+ <ref local="hibernateProperties" />
+ </property>
+ <!-- The following property is used temporary to be able to manage transactions manually. -->
+ <!-- TODO: use annotations to mark transaction methods
+ instead of programmatic transaction management -->
+ <property name="exposeTransactionAwareSessionFactory">
+ <value>false</value>
+ </property>
+ </bean>
+
+ <bean id="txManager"
+ class="org.springframework.orm.hibernate3.HibernateTransactionManager">
+ <property name="sessionFactory" ref="simanSessionFactory" />
+ </bean>
+
+ <tx:annotation-driven transaction-manager="txManager" />
+
+</beans>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
- xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
-http://www.springframework.org/schema/context/spring-context-3.0.xsd
-http://www.springframework.org/schema/tx
-http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
+http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="baseMessageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
</list>
</property>
</bean>
-
- <!-- <bean id="simanDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
- <property name="jndiName" value="jdbc/ibatis"/>
- </bean> -->
-
- <!-- <bean id="simanDatasource"
- class="org.springframework.jdbc.datasource.DriverManagerDataSource">
- <property name="driverClassName"
- value="${connection.driver_class}" />
- <property name="url" value="${connection.url}" />
- <property name="username" value="${connection.username}" />
- <property name="password" value="${connection.password}" />
- </bean>
- -->
-
- <context:property-placeholder
- location="classpath:siman.properties,classpath:jdbc.properties"
- ignore-unresolvable="true" />
-
- <bean id="simanDatasource"
- class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
- <property name="driverClassName"
- value="${connection.driver_class}" />
- <property name="url" value="${connection.url}" />
- <property name="username" value="${connection.username}" />
- <property name="password" value="${connection.password}" />
- <property name="suppressClose" value="true" />
- <property name="autoCommit" value="false" />
- </bean>
-
- <bean id="p6spySimanDatasource"
- class="com.p6spy.engine.spy.P6DataSource">
- <constructor-arg>
- <ref local="simanDatasource" />
- </constructor-arg>
- </bean>
-
-
- <bean id="hibernateProperties"
- class="org.springframework.beans.factory.config.PropertiesFactoryBean">
- <property name="properties">
- <props>
- <!-- normal properties -->
- </props>
- </property>
- <!-- hibernate.config should be defined somewhere in the spring.properties layers -->
- <property name="locations">
- <list>
- <value>classpath:${hibernate.config.file}</value>
- </list>
- </property>
- </bean>
-
- <bean id="simanSessionFactory"
- class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
- <property name="dataSource" ref="simanDatasource" />
- <property name="mappingResources">
- <list>
- <value>
- org/splat/dal/bo/kernel/Persistent.hbm.xml
- </value>
- <value>org/splat/dal/bo/kernel/Any.hbm.xml</value>
- <value>org/splat/dal/bo/kernel/Entity.hbm.xml</value>
- <value>org/splat/dal/bo/kernel/Attribute.hbm.xml</value>
- <value>org/splat/dal/bo/kernel/Relation.hbm.xml</value>
- <value>
- org/splat/dal/bo/kernel/TextAttribute.hbm.xml
- </value>
- <value>org/splat/dal/bo/kernel/User.hbm.xml</value>
-
- <value>
- org/splat/dal/bo/som/ProjectElement.hbm.xml
- </value>
- <value>org/splat/dal/bo/som/Study.hbm.xml</value>
- <value>org/splat/dal/bo/som/Scenario.hbm.xml</value>
- <value>org/splat/dal/bo/som/Attributes.hbm.xml</value>
- <value>org/splat/dal/bo/som/Relations.hbm.xml</value>
- <value>org/splat/dal/bo/som/File.hbm.xml</value>
- <value>org/splat/dal/bo/som/Document.hbm.xml</value>
- <value>org/splat/dal/bo/som/Publication.hbm.xml</value>
- <value>
- org/splat/dal/bo/som/ValidationCycle.hbm.xml
- </value>
- <value>org/splat/dal/bo/som/Timestamp.hbm.xml</value>
- <value>
- org/splat/dal/bo/som/SimulationContext.hbm.xml
- </value>
- <value>
- org/splat/dal/bo/som/KnowledgeElement.hbm.xml
- </value>
- <value>org/splat/dal/bo/som/IDBuilder.hbm.xml</value>
- </list>
- </property>
- <!-- hibernate.connection.driver_class=com.p6spy.engine.spy.P6SpyDriver -->
-
- <property name="hibernateProperties">
- <ref local="hibernateProperties" />
- </property>
- <!-- The following property is used temporary to be able to manage transactions manually. -->
- <!-- TODO: use annotations to mark transaction methods
- instead of programmatic transaction management -->
- <property name="exposeTransactionAwareSessionFactory">
- <value>false</value>
- </property>
- </bean>
-
- <bean id="txManager"
- class="org.springframework.orm.hibernate3.HibernateTransactionManager">
- <property name="sessionFactory" ref="simanSessionFactory" />
- </bean>
-
- <tx:annotation-driven transaction-manager="txManager" />
-
+
<!-- TODO: Replace database by services and DAOs -->
<bean id="database" class="org.splat.dal.dao.som.Database">
<property name="sessionFactory" ref="simanSessionFactory" />
--- /dev/null
+# Generated at 12/10/2012 07:20:45
+# Don't edit manually. See the source in D:\users\rkv\SIMAN\SIMAN_SRC\Workspace\Siman\conf\templates.
+# Connection properties
+connection.driver_class=com.mysql.jdbc.Driver
+
+# Hibernate config
+hibernate.hbm2ddl.auto=update
+hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
+hibernate.current_session_context_class=thread
+
+# Log properties
+hibernate.show_sql=true
--- /dev/null
+# Connection properties for unit tests
+connection.url=jdbc:mysql://localhost/siman_unit_tests
+connection.username=simer
+connection.password=admin
+connection.driver_class=com.mysql.jdbc.Driver
--- /dev/null
+schema.version = D-0.3
+
+wapp.version = D-0.5
+wapp.root = D:/users/rkv/SIMAN/SIMAN_SRC/Workspace/Siman/WebContent/
+wapp.login = conf/login.conf
+wapp.configuration = conf/som.xml
+wapp.customization = conf/my.xml
+wapp.website = http://www.salome-platform.org
+wapp.onlinehelp = http://docs.salome-platform.org/salome_6_3_1/gui/GUI_index.html
+wapp.context = repository
+
+locale.supported = fr,en
+
+hibernate.config.file=hibernate.properties
\ No newline at end of file
--- /dev/null
+/*****************************************************************************
+ * Company EURIWARE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 12 Oct 2012
+ * @author $Author$
+ * @version $Revision$
+ *****************************************************************************/
+
+package test.splat.common;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.sql.DataSource;
+
+import org.hibernate.SessionFactory;
+import org.splat.log.AppLogger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
+import org.springframework.orm.hibernate3.HibernateTemplate;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.transaction.TransactionConfiguration;
+import org.springframework.transaction.TransactionDefinition;
+import org.springframework.transaction.TransactionStatus;
+import org.springframework.transaction.support.DefaultTransactionDefinition;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Base Siman Test class. Each test method is transactional by default.
+ * Use <code>NotTransactional</code> annotation to declare test method as not transactional.
+ * By default all operations on database are rolledback after each test method.
+ * To avoid this use <code>Rollback(false)</code> annotation.
+ *
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ *
+ */
+
+@ContextConfiguration(locations = {
+ "/test/spring/ut-applicationContext.xml",
+ "/test/spring/ut-datasourceContext.xml",
+ "/spring/businessServiceContext.xml",
+ "/spring/daoContext.xml",
+ "/spring/globalContext.xml",
+ "/spring/technicalServiceContext.xml"
+})
+@TransactionConfiguration(defaultRollback = true, transactionManager = "txManager")
+@Test(sequential=true, groups = {"service", "functional", "business"})
+public class BaseTest extends TestListingAndOrder {
+
+ // ========================================= static methods
+ /**
+ * Logger for the class.
+ */
+ private static final AppLogger LOG = AppLogger.getLogger(BaseTest.class);
+
+ /**
+ * The helper class to work with hibernate session.
+ */
+ private HibernateTemplate _hibernateTemplate;
+
+ /**
+ * Get the hibernateTemplate.
+ * @return the hibernateTemplate
+ */
+ @Test(enabled = false)
+ public HibernateTemplate getHibernateTemplate() {
+ return _hibernateTemplate;
+ }
+
+ // ======================================= static variables
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests#setDataSource(javax.sql.DataSource)
+ */
+ @Override
+ @Autowired
+ @Test(enabled = false)
+// public void setDataSource(@Qualifier("p6spyiBatisDatasource")
+ @SuppressWarnings("deprecation")
+ public void setDataSource(@Qualifier("simanDatasource")
+ final DataSource dataSource) {
+ this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
+ }
+
+ /**
+ * Set a hibernate session factory.
+ * @param aSessionFactory the hibernate session factory
+ */
+ @Autowired
+ @Test(enabled = false)
+ public void setSessionFactory(@Qualifier("simanSessionFactory") SessionFactory aSessionFactory) {
+ _hibernateTemplate = new HibernateTemplate(aSessionFactory);
+ }
+
+ /**
+ * Method for the test data creation. It is called before the first test
+ * starting.
+ */
+ @BeforeClass
+ public void initClass() {
+ try {
+ // Initialize UserContext
+// initUserContext();
+
+ } catch (Exception e) {
+ Assert.fail("Exception occured during the testing data creation. ", e);
+ }
+ }
+
+
+ /**
+ * Insert base data before each method : matricule, department, language, reference.
+ */
+ @BeforeMethod
+ public void insertBaseDataBeforeMethod() {
+ LOG.debug(" >>>>>>>>>>>>>>> COMMON - insertBaseDataBeforeMethod");
+
+ }
+
+ // [PRIVATE METHOD] ------------------------------
+
+ // [DATA PROVIDER METHOD : Insert / Select] ------------------------------
+ /**
+ * Insert data for test : document.
+ * @param document BO
+ */
+// protected void insertData(final DocumentWithBLOBs document) {
+// // Insert document
+// _documentDAO.insert(document);
+// }
+
+ /**
+ * Uses the current transaction to execute SQL statement in order to be able to
+ * see the current state of the database.
+ * @param statement the sql statement
+ */
+ @SuppressWarnings("deprecation")
+ protected void executeAndDisplaySqlStatement(final String statement) {
+ List<Map<String, Object>> resultSet = simpleJdbcTemplate.queryForList(statement);
+ displayResultset(resultSet);
+ }
+
+ /**
+ * Uses the current transaction to execute SQL statement in order to be able to
+ * see the current state of the database.
+ * @param statement the sql statement
+ * @param args the sql statement parameters
+ */
+ @SuppressWarnings("deprecation")
+ protected void executeAndDisplaySqlStatement(final String statement, final Object...args) {
+ List<Map<String, Object>> resultSet = simpleJdbcTemplate.queryForList(statement, args);
+ displayResultset(resultSet);
+ }
+
+ /**
+ * Displays resultset in log.
+ * @param resultSet the resultset to display.
+ */
+ private void displayResultset(final List<Map<String, Object>> resultSet) {
+ if(!resultSet.isEmpty()) {
+ Map<String, Object> firstElement = resultSet.get(0);
+ LOG.debug(firstElement.keySet().toString());
+
+ for (Map<String, Object> line : resultSet) {
+ StringBuilder logLine = new StringBuilder("[");
+ logLine.append(line.values());
+ logLine.append("[");
+ LOG.debug(logLine.toString());
+ }
+ }
+ }
+
+
+ // ==========================================================================
+ // NESTED TRANSACTIONS MANAGEMENT
+ // ==========================================================================
+
+ /**
+ * Used for nested transactions management.
+ */
+ private transient TransactionStatus _nestedTxStatus;
+
+ /**
+ * Use this method to start a new transaction within an existing one.
+ * Consider the following test scenario:
+ * testXX():
+ * 1: check service.XX on valid data:
+ * - createInitialData();
+ * - service.XX(); (performs some changes on initial data)
+ * 2: check service.XX on invalid data:
+ * - deleteInitialData(); (as data were changed by previous call)
+ * - createInitialData();
+ * - adjustInitialData();
+ * - service.XX();
+ * To make such a test we need to provide deleteInitialData() method and call
+ * createInitialData() twice. The latter might lead to significant increasing of
+ * the test execution time.
+ *
+ * Consider an alternative approach:
+ * testXX():
+ * 1: check service.XX on valid data:
+ * - createInitialData();
+ * - startNestedTransaction();
+ * - service.XX();
+ * - rollbackNestedTransaction();
+ * 2: check service.XX on invalid data:
+ * - startNestedTransaction();
+ * - adjustInitialData();
+ * - service.XX();
+ * - rollbackNestedTransaction();
+ * Thus you're able to create and manage the nested transactions programmatically.
+ * @see test.areva.hewis.mlst2.service.gpao.rpta.TaBaseService#rollbackNestedTransaction()
+ */
+ protected void startNestedTransaction() {
+ DataSourceTransactionManager txManager =
+ (DataSourceTransactionManager) applicationContext.getBean("txManager");
+
+ DefaultTransactionDefinition txDefinition = new DefaultTransactionDefinition();
+ txDefinition.setPropagationBehavior(TransactionDefinition.PROPAGATION_NESTED);
+
+ _nestedTxStatus = txManager.getTransaction(txDefinition);
+}
+
+ /**
+ * Rollbacks the nested transaction.
+ * @see test.areva.hewis.mlst2.service.gpao.rpta.TaBaseService#startNestedTransaction()
+ */
+ protected void rollbackNestedTransaction() {
+ DataSourceTransactionManager txManager =
+ (DataSourceTransactionManager) applicationContext.getBean("txManager");
+ txManager.rollback(_nestedTxStatus);
+ }
+
+
+ /**
+ * Rollbacks the nested transaction and start a new one.
+ * @see test.areva.hewis.mlst2.service.gpao.rpta.TaBaseService#startNestedTransaction()
+ * @see test.areva.hewis.mlst2.service.gpao.rpta.TaBaseService#rollbackNestedTransaction()
+ */
+ protected void rollbackAndRestartNestedTransaction() {
+ rollbackNestedTransaction();
+ startNestedTransaction();
+ }
+}
--- /dev/null
+/*****************************************************************************
+ * Company EURIWARE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 12 Oct 2012
+ * @author $Author$
+ * @version $Revision$
+ *****************************************************************************/
+
+package test.splat.common;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * Abstract class for specific search functionality tests. It is necessary to
+ * define method, returning expected search list size, array of properties.
+ *
+ * @author <a href="mailto:vera.polyanskikh@opencascade.com">Vera POLYANSKIKH (VPH)</a>
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
+@Test(sequential=true, groups = {"service", "functional", "business"})
+public class TestListingAndOrder extends AbstractTransactionalTestNGSpringContextTests {
+
+
+
+ /**
+ * Current Specific method name.
+ */
+ protected String _methodName;
+ /**
+ * Common message suffix used to inform that corresponding method should be overridden if this common functionality is used.
+ */
+ private static final String NO_METHOD_OVERRIDEN_MSG_SUFFIX = " should be overridden in test class if common test pagination and order engine is used";
+
+ /**
+ * Error message has been appeared when null object exist in business method result set.
+ */
+ private static final String NULL_OBJECT_EXIST_IN_RESULTSET = "Null object exist in business method result set";
+
+ //////////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////////////
+ /**METHODS TO BE OVERRIDDEN**/
+ /**Throw UnsupportedOperationException if not**/
+ //////////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Return expected size of the whole retrieved list or a page of the objects.
+ * @param methodName - specific search method to be called
+ * @return size of list
+ */
+ @Test(enabled = false)
+ public int getExpectedWholeListSize(final String methodName){
+ // empty default implementation
+ // should be overridden if test of pagination or order is necessary
+ throw new UnsupportedOperationException("TestListingAndOrder.getExpectedWholeListSize"+NO_METHOD_OVERRIDEN_MSG_SUFFIX);
+ }
+
+
+ /**
+ * Returns array of DTO properties which can be used to test order of page or list.
+ * @param methodName - specific search method to be called
+ * @return array of order criteria.
+ */
+ @Test(enabled = false)
+ public String[][] getOrderCriteria(final String methodName){
+ // empty default implementation
+ // should be overridden if test of pagination or order is necessary
+ throw new UnsupportedOperationException("TestListingAndOrder.getOrderCriteria"+NO_METHOD_OVERRIDEN_MSG_SUFFIX);
+ }
+
+ /**
+ * Wrapper for call of specific not paginated search method.
+ * @param <T> object type class
+ * @param methodName - specific search method to be called
+ * @return template list
+ */
+ @Test(enabled = false)
+ public <T>List<T> searchListWrapper(final String methodName){
+ // empty default implementation
+ // should be overridden if test of pagination or order is necessary
+ throw new UnsupportedOperationException("TestListingAndOrder.searchListWrapper"+NO_METHOD_OVERRIDEN_MSG_SUFFIX);
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////////////
+ /**END OF SECTION**/
+ //////////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Returns result of default comparison of two objects by given array of properties.
+ * @param o1 - object 1
+ * @param o2 - object 2
+ * @param methodName - specific search method name
+ * @param propertyNames - properties to be compared by
+ * @param ascDirection - order direction (asc if true, desc - otherwise)
+ * @return result of comparison.
+ */
+ @Test(enabled = false)
+ protected int specificCompare(final Object o1, final Object o2, final String methodName,final String[] propertyNames,final boolean ascDirection){
+ int result = 0;
+ int i=0;
+ while(result==0 && i<propertyNames.length){
+ result =internalCompare(o1,o2, propertyNames[i]);
+ i++;
+ }
+
+ if(!ascDirection){
+ result = result*(-1);
+ }
+ return result;
+ }
+
+ /**
+ * Perform test of not paginated search method.
+ * @param <T> object type class
+ * @param methodName - specific search method to be called
+ */
+ @Test(enabled = false)
+ protected <T> void internalTestSearchList(final String methodName) {
+ setMethodName(methodName);
+ try {
+ // compare the whole set size with expected
+ List<T> list = searchList();
+ Assert.assertEquals(list.size(), getExpectedWholeListSize(methodName),"The whole list size is unexpected!");
+
+ // check ordering by all given criteria
+ String[] orderCriteria = getOrderCriteria(_methodName)[0];
+
+ Assert.assertTrue(checkOrdering(list,orderCriteria,true),"Asc Ordering of list by properties "+orderCriteria[0].toString()+" is wrong!");
+
+ } catch (Exception e) {
+ Assert.fail("Exception occured", e);
+ }
+ }
+
+ /**
+ * Get the methodName.
+ * @return the methodName
+ */
+ @Test(enabled = false)
+ private String getMethodName() {
+ return _methodName;
+ }
+
+
+
+
+ /**
+ * Set the methodName.
+ * @param methodName the methodName to set
+ */
+ @Test(enabled = false)
+ private void setMethodName(final String methodName) {
+ this._methodName = methodName;
+ }
+
+
+ /**
+ * Test of not paginated search method. Specific service method to be called for tests.
+ * @param <T> object type class
+ * @return list -template list
+ */
+ @Test(enabled = false)
+ private <T>List<T> searchList() {
+ return searchListWrapper(_methodName);
+ }
+
+ /**
+ * Order list given list by given order criteria.
+ * @param <T> - object type class
+ * @param list - list of the objects
+ * @param orderCriteria - property to order by
+ * @param ascDirection - order direction (asc if true, desc - otherwise)
+ * @return ordered list
+ */
+ @Test(enabled = false)
+ private <T>List<T> getOrderedList(final List<T> list,
+ final String[] orderCriteria,
+ final boolean ascDirection){
+ // check ordering
+
+ Collections.sort(list,new Comparator<T>(){
+ public int compare(final T o1, final T o2){
+ return specificCompare(o1,o2,null,orderCriteria,ascDirection);
+ }
+ });
+ return list;
+ }
+
+ /**
+ * Check if given list is ordered by given criteria.
+ * @param <T> - object type class
+ * @param list - list of the objects
+ * @param orderCriteria - property to order by
+ * @param ascDirection - order direction (asc if true, desc - otherwise)
+ * @return boolean
+ */
+ @Test(enabled = false)
+ private <T> boolean checkOrdering(final List<T> list,
+ final String[] orderCriteria,
+ final boolean ascDirection){
+ boolean result = true;
+
+ List<T> oldList = new ArrayList<T>();
+ for(T item:list){
+ oldList.add(item);
+ }
+ List<T> sortedList = getOrderedList(list,orderCriteria,ascDirection);
+ int i = 0 ;
+ for(i=0;i<sortedList.size();i++){
+ if(oldList.get(i)==null){
+ Assert.fail(NULL_OBJECT_EXIST_IN_RESULTSET);
+ }
+ if(!oldList.get(i).equals(sortedList.get(i))){
+ result = false;
+ break;
+ }
+ }
+ return result;
+ }
+
+
+ /**
+ * Performs internal default compare by given property.
+ * @param o1 - object 1
+ * @param o2 - object 2
+ * @param propertyName - property to be compared by
+ * @return result
+ */
+ @Test(enabled = false)
+ private int internalCompare(final Object o1, final Object o2, final String propertyName){
+ int result = -2;
+ try {
+ // Use getter method for the given property name.
+ Method getter = o1.getClass().getMethod(
+ "get" + propertyName.substring(0, 1).toUpperCase()
+ + propertyName.substring(1));
+ // Get property values by means of the getter method.
+ Object v1 = getter.invoke(o1);
+ Object v2 = getter.invoke(o2);
+ // Compare values.
+ if(v1==null && v2==null) {
+ result = 0;
+ }else{
+ if(v1==null && v2!=null) {
+ result = 1;
+ }else{
+ if(v1!=null && v2==null){
+ result = -1;
+ }else{
+ if (v1 instanceof Comparable) {
+ result = ((Comparable)v1).compareTo(v2);
+ }
+ }
+ }
+ }
+ }catch (IllegalAccessException e) {
+
+ Assert.fail("IllegalAccessException was thrown by BeanUtils.getProperty ", e);
+ } catch (InvocationTargetException e) {
+
+ Assert.fail("InvocationTargetException was thrown by BeanUtils.getProperty ", e);
+ } catch (NoSuchMethodException e) {
+
+ Assert.fail("NoSuchMethodException was thrown by BeanUtils.getProperty: " + e.getMessage(), e);
+ }
+ return result;
+ }
+}
--- /dev/null
+/*****************************************************************************
+ * Company EURIWARE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 12 Oct 2012
+ * @author $Author$
+ * @version $Revision$
+ *****************************************************************************/
+package test.splat.dao;
+
+import java.util.Date;
+
+import org.splat.dal.bo.kernel.User;
+import org.splat.dal.bo.som.KnowledgeElement;
+import org.splat.dal.bo.som.KnowledgeElementType;
+import org.splat.dal.bo.som.Scenario;
+import org.splat.dal.bo.som.Study;
+import org.splat.dal.dao.som.KnowledgeElementDAO;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.kernel.MissedPropertyException;
+import org.splat.kernel.MultiplyDefinedException;
+import org.splat.log.AppLogger;
+import org.splat.service.StudyService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.orm.hibernate3.HibernateTemplate;
+import org.springframework.test.annotation.Rollback;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import test.splat.common.BaseTest;
+
+/**
+ * Test class for KnowledgeElementDAO.
+ *
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ *
+ */
+public class TestKnowledgeElementDAO extends BaseTest {
+
+ /**
+ * Logger for the class.
+ */
+ private static final AppLogger LOG = AppLogger
+ .getLogger(TestKnowledgeElementDAO.class);
+
+ /**
+ * The tested KnowledgeElementDAO. Later injected by Spring.
+ */
+ @Autowired
+ @Qualifier("knowledgeElementDAO")
+ private transient KnowledgeElementDAO _knowledgeElementDAO;
+
+ /**
+ * The StudyService injected bean.
+ */
+ @Autowired
+ @Qualifier("studyService")
+ private StudyService _studyService;
+
+ /**
+ * Test creation of a knowledge element.<BR>
+ * <B>Description :</B> <BR>
+ * <i>Create a knowledge element.</i><BR>
+ * <B>Action : </B><BR>
+ * <i>1. call DAO's create method for a good transient knowledge element.</i><BR>
+ * <i>2. call DAO's create method for a knowledge element with non-zero id.</i><BR>
+ * <B>Test data : </B><BR>
+ * <i>no input parameters</i><BR>
+ * <i>no input parameters</i><BR>
+ *
+ * <B>Outcome results:</B><BR>
+ * <i>
+ * <ul>
+ * <li>Object is created in the database successfully<BR>
+ * </li>
+ * <li>Exception is thrown<BR>
+ * </li>
+ * </ul>
+ * </i>
+ *
+ * @throws InvalidPropertyException
+ * if an invalid property is used when creating objects
+ * @throws MultiplyDefinedException
+ * when trying to create an object with already existing id
+ * @throws MissedPropertyException
+ * if a mandatory property is not defined for an object to be created
+ *
+ */
+ @Test
+ public void testCreate() throws InvalidPropertyException,
+ MissedPropertyException, MultiplyDefinedException {
+ LOG.debug(">>>>> RUN testCreate()");
+
+ KnowledgeElement aKelm = getKnowledgeElement();
+ // Call DAO's create method for a good transient knowledge element.
+ Long id = _knowledgeElementDAO.create(aKelm);
+ Assert.assertNotNull(id,
+ "Create method returns null instead of a new id.");
+ Assert.assertTrue(id > 0, "The new id is not a positive number.");
+ KnowledgeElement aKelmFound = getHibernateTemplate().get(
+ KnowledgeElement.class, id);
+ Assert.assertNotNull(aKelmFound,
+ "Created object is not found in the database.");
+ Assert.assertEquals(aKelmFound.getAuthor(), aKelm.getAuthor(),
+ "Knowledge Element author is not saved.");
+ Assert.assertEquals(aKelmFound.getDate(), aKelm.getDate(),
+ "Knowledge Element date is not saved.");
+ Assert
+ .assertEquals(aKelmFound.getOwnerScenario(), aKelm
+ .getOwnerScenario(),
+ "Knowledge Element scenario is not saved.");
+ Assert.assertEquals(aKelmFound.getProgressState(), aKelm
+ .getProgressState(), "Knowledge Element state is not saved.");
+ Assert.assertEquals(aKelmFound.getTitle(), aKelm.getTitle(),
+ "Knowledge Element title is not saved.");
+ Assert.assertEquals(aKelmFound.getType(), aKelm.getType(),
+ "Knowledge Element type is not saved.");
+ Assert.assertEquals(aKelmFound.getValue(), aKelm.getValue(),
+ "Knowledge Element value is not saved.");
+ Assert.assertEquals(aKelmFound.getIndex(), aKelm.getIndex(),
+ "Knowledge Element index is not saved.");
+
+ // Call DAO's create method for a knowledge element with non-zero id.
+ KnowledgeElement aBadKelm = new KnowledgeElement(
+ (new KnowledgeElement.Properties())
+ .setTitle("Test knowledge element")
+ .setAuthor(aKelm.getAuthor())
+ .setOwnerScenario(aKelm.getOwnerScenario())
+ .setType(aKelm.getType())
+ .setDate(aKelm.getDate())
+ .setValue(
+ "This is another test knowledge element.\nIt is created by the unit test."));
+ aBadKelm.setIndex(aKelmFound.getIndex());
+ try {
+ _knowledgeElementDAO.create(aBadKelm);
+ getHibernateTemplate().flush();
+ Assert.fail("Creation with existing id must be failed.");
+ } catch (Exception e) {
+ LOG.debug("Expected exception is thrown: "
+ + e.getClass().getSimpleName() + ": " + e.getMessage());
+ }
+ }
+
+ /**
+ * Create a transient KnowledgeElement for tests.
+ *
+ * @return a transient KnowledgeElement
+ * @throws InvalidPropertyException
+ * if an invalid property is used when creating objects
+ * @throws MultiplyDefinedException
+ * when trying to create an object with already existing id
+ * @throws MissedPropertyException
+ * if a mandatory property is not defined for an object to be created
+ */
+ private KnowledgeElement getKnowledgeElement()
+ throws InvalidPropertyException, MissedPropertyException,
+ MultiplyDefinedException {
+ // Create a test knowledge type
+ HibernateTemplate ht = getHibernateTemplate();
+
+ KnowledgeElement.Properties kprops = new KnowledgeElement.Properties();
+ KnowledgeElementType aKType = new KnowledgeElementType("TST_kelmtype");
+ ht.save(aKType);
+ // Create a test user
+ User.Properties uprop = new User.Properties();
+ uprop.setUsername("TST_Username").setName("TST_SimanUnitTestsUser")
+ .setFirstName("TST_FirstName").setDisplayName("TST_test.user")
+ .addRole("TST_user").setMailAddress(
+ "noreply@salome-platform.org");
+ uprop.disableCheck();
+ User anAuthor = new User(uprop);
+ ht.update(anAuthor);
+ // Create a test study
+ Study.Properties stprops = new Study.Properties().setReference(
+ "TST_SID_01").setTitle("TST_Study").setManager(anAuthor);
+ Study aStudy = new Study(stprops);
+ ht.saveOrUpdate(aStudy);
+ // Create a test scenario
+ Scenario.Properties sprops = new Scenario.Properties().setTitle(
+ "TST_Study").setManager(anAuthor).setOwnerStudy(aStudy);
+ Scenario aScenario = new Scenario(sprops);
+ aStudy.getScenariiList().add(aScenario);
+ ht.saveOrUpdate(anAuthor);
+ ht.saveOrUpdate(aKType);
+ ht.update(aStudy);
+ ht.saveOrUpdate(aScenario);
+
+ Date aDate = new Date();
+
+ // Prepare a knowledge element transient object
+ kprops
+ .setTitle("Test knowledge element")
+ .setAuthor(anAuthor)
+ .setOwnerScenario(aScenario)
+ .setType(aKType)
+ .setDate(aDate)
+ .setValue(
+ "This is the test knowledge element.\nIt is created by the unit test.");
+
+ return new KnowledgeElement(kprops);
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans
+http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+http://www.springframework.org/schema/aop
+http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+http://www.springframework.org/schema/context
+http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+
+ <context:property-placeholder
+ location="classpath:test/siman.properties,classpath:test/jdbc.properties"
+ ignore-unresolvable="true" />
+
+ <!-- configuration i18n -->
+ <bean id="i18nUtils"
+ class="org.splat.i18n.I18nUtils">
+ <property name="resourceBundleMessageSource"
+ ref="messageSource" />
+ </bean>
+
+ <bean id="messageSource"
+ class="org.springframework.context.support.ResourceBundleMessageSource">
+ <property name="basenames">
+ <list>
+ <value>application</value>
+ <value>log-messages</value>
+ </list>
+ </property>
+ </bean>
+ <!-- ref 'baseMessageSource' into Siman-common\src\spring\globalContext.xml -->
+ <!-- property name="parentMessageSource" ref="baseMessageSource"/-->
+</beans>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans
+http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+http://www.springframework.org/schema/aop
+http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+http://www.springframework.org/schema/context
+http://www.springframework.org/schema/context/spring-context-3.0.xsd
+http://www.springframework.org/schema/tx
+http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
+
+ <!-- <bean id="simanDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+ <property name="jndiName" value="jdbc/ibatis"/>
+ </bean> -->
+
+ <!-- <bean id="simanDatasource"
+ class="org.springframework.jdbc.datasource.DriverManagerDataSource">
+ <property name="driverClassName"
+ value="${connection.driver_class}" />
+ <property name="url" value="${connection.url}" />
+ <property name="username" value="${connection.username}" />
+ <property name="password" value="${connection.password}" />
+ </bean>
+ -->
+
+ <bean id="simanDatasource"
+ class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
+ <property name="driverClassName"
+ value="${connection.driver_class}" />
+ <property name="url" value="${connection.url}" />
+ <property name="username" value="${connection.username}" />
+ <property name="password" value="${connection.password}" />
+ <property name="suppressClose" value="true" />
+ <property name="autoCommit" value="false" />
+ </bean>
+
+ <bean id="p6spySimanDatasource"
+ class="com.p6spy.engine.spy.P6DataSource">
+ <constructor-arg>
+ <ref local="simanDatasource" />
+ </constructor-arg>
+ </bean>
+
+
+ <bean id="hibernateProperties"
+ class="org.springframework.beans.factory.config.PropertiesFactoryBean">
+ <property name="properties">
+ <props>
+ <!-- normal properties -->
+ </props>
+ </property>
+ <!-- hibernate.config should be defined somewhere in the spring.properties layers -->
+ <property name="locations">
+ <list>
+ <value>classpath:test/${hibernate.config.file}</value>
+ </list>
+ </property>
+ </bean>
+
+ <bean id="simanSessionFactory"
+ class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
+ <property name="dataSource" ref="simanDatasource" />
+ <property name="mappingResources">
+ <list>
+ <value>
+ org/splat/dal/bo/kernel/Persistent.hbm.xml
+ </value>
+ <value>org/splat/dal/bo/kernel/Any.hbm.xml</value>
+ <value>org/splat/dal/bo/kernel/Entity.hbm.xml</value>
+ <value>org/splat/dal/bo/kernel/Attribute.hbm.xml</value>
+ <value>org/splat/dal/bo/kernel/Relation.hbm.xml</value>
+ <value>
+ org/splat/dal/bo/kernel/TextAttribute.hbm.xml
+ </value>
+ <value>org/splat/dal/bo/kernel/User.hbm.xml</value>
+
+ <value>
+ org/splat/dal/bo/som/ProjectElement.hbm.xml
+ </value>
+ <value>org/splat/dal/bo/som/Study.hbm.xml</value>
+ <value>org/splat/dal/bo/som/Scenario.hbm.xml</value>
+ <value>org/splat/dal/bo/som/Attributes.hbm.xml</value>
+ <value>org/splat/dal/bo/som/Relations.hbm.xml</value>
+ <value>org/splat/dal/bo/som/File.hbm.xml</value>
+ <value>org/splat/dal/bo/som/Document.hbm.xml</value>
+ <value>org/splat/dal/bo/som/Publication.hbm.xml</value>
+ <value>
+ org/splat/dal/bo/som/ValidationCycle.hbm.xml
+ </value>
+ <value>org/splat/dal/bo/som/Timestamp.hbm.xml</value>
+ <value>
+ org/splat/dal/bo/som/SimulationContext.hbm.xml
+ </value>
+ <value>
+ org/splat/dal/bo/som/KnowledgeElement.hbm.xml
+ </value>
+ <value>org/splat/dal/bo/som/IDBuilder.hbm.xml</value>
+ </list>
+ </property>
+ <!-- hibernate.connection.driver_class=com.p6spy.engine.spy.P6SpyDriver -->
+
+ <property name="hibernateProperties">
+ <ref local="hibernateProperties" />
+ </property>
+ <!-- The following property is used temporary to be able to manage transactions manually. -->
+ <!-- TODO: use annotations to mark transaction methods
+ instead of programmatic transaction management -->
+<!-- <property name="exposeTransactionAwareSessionFactory">
+ <value>false</value>
+ </property>-->
+<!-- <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />-->
+ </bean>
+
+ <bean id="txManager"
+ class="org.springframework.orm.hibernate3.HibernateTransactionManager">
+ <property name="sessionFactory" ref="simanSessionFactory" />
+ </bean>
+
+ <tx:annotation-driven transaction-manager="txManager" />
+
+</beans>
--- /dev/null
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
+
+<suite name="SimanCommonTests" verbose="1">
+ <test name="all">
+ <method-selectors>
+ <method-selector>
+ <script language="beanshell">
+ <![CDATA[
+ (groups.containsKey("business") || groups.containsKey("functional") || groups.containsKey("service") ) && method.getName().toUpperCase().startsWith("TEST")
+ ]]>
+ </script>
+ </method-selector>
+ </method-selectors>
+ <groups>
+ <!--
+ <define name="all">
+ <include name="business"/>
+ <include name="functional"/>
+ <include name="service"/>
+ </define>
+ <define name="new">
+ <include name="newservice"/>
+ </define>
+ <run>
+ <include name="all"/>
+ <exclude name="old"/>
+ </run>
+ -->
+
+ </groups>
+ <packages>
+ <package name="test.*" />
+ </packages>
+ </test>
+</suite>
<wb-resource deploy-path="/" source-path="/WebContent"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/.apt_src"/>
- <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/SPlat/lib/hibernate-3.5.jar">
- <dependency-type>uses</dependency-type>
- </dependent-module>
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/Siman-Common/lib/org.springframework.aop-3.1.2.RELEASE.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/SPlat/lib/mailapi.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
- <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/SPlat/lib/mysql-connector-java-5.1.5-bin.jar">
- <dependency-type>uses</dependency-type>
- </dependent-module>
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/SPlat/lib/poi-3.7-20101029.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/Siman-Common/lib/cglib-nodep-2.2.3.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
+ <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/Siman-Common/lib/commons-logging-1.1.1.jar">
+ <dependency-type>uses</dependency-type>
+ </dependent-module>
+ <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/Siman-Common/lib/beanlib-5.0.1beta.jar">
+ <dependency-type>uses</dependency-type>
+ </dependent-module>
+ <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/Siman-Common/lib/hibernate-3.5.jar">
+ <dependency-type>uses</dependency-type>
+ </dependent-module>
+ <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/Siman-Common/lib/mysql-connector-java-5.1.5-bin.jar">
+ <dependency-type>uses</dependency-type>
+ </dependent-module>
<property name="java-output-path" value="build/classes"/>
<property name="context-root" value="siman"/>
</wb-module>
uses = new ArrayList<DocumentFacade>(relist.size());
for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
Publication used = i.next();
- Integer index = used.getIndex();
+ long index = used.getIndex();
DocumentFacade facade = OpenObject.docpres.get(index);
if (facade == null) {
facade = new DocumentFacade(owner, used, getProjectSettings(), getPublicationService());
public class ImportDocumentAction extends UploadBaseNextAction {
private List<DocumentType> doctypes = null;
- private int doctype = 0;
+ private long doctype = 0;
private String docref = null; // Reference extracted from the imported file, if exist
private String docver = ""; // Version number extracted from the imported file, if exist
private String date = ""; // Date extracted from the imported file, if exist
mystudy = getOpenStudy();
User user = getConnectedUser();
Step step = mystudy.getSelectedStep();
- DocumentType type = Document.selectType(doctype);
+ DocumentType type = Document.selectType((int)doctype);
File updir = Database.getDownloadDirectory(user);
File upfile = new File(updir.getPath() + "/" + filename);
String[] table = filename.split("\\x2E");
return doctypes;
}
- public int getDocumentType() {
+ public long getDocumentType() {
// -----------------------------
return doctype;
}
private List<Scenario> myscene;
private String mytitle;
private String selection;
- private int scindex;
+ private long scindex;
private int bastep;
private ToDo action;
private StudyService _studyService;
// ------------------------------------
return myscene;
}
- public int getSelectedScenarioIndex () {
+ public long getSelectedScenarioIndex () {
// --------------------------------------
return scindex;
}
Step step = i.next();
int number = step.getNumber();
Scenario group = (Scenario) step.getOwner(); // The menu includes first scenario steps only
- int index = group.getIndex();
+ long index = group.getIndex();
String value = index + "." + number;
String icon;
if (getScenarioService().isEmpty(group))
if (number == askdex)
stopen = step;
Scenario group = (Scenario) step.getOwner();
- int index = group.getIndex();
+ long index = group.getIndex();
String value = index + "." + number;
if (index != scenew.getIndex()) {
if (getScenarioService().isEmpty(group))
return credate;
}
- public Integer getIndex() {
+ public Long getIndex() {
// -------------------------
return myknelm.getIndex();
}
private ProjectSettingsService _projectSettingsService;
private PublicationService _publicationService;
- protected static HashMap<Integer, DocumentFacade> docpres = null;
- protected static HashMap<Integer, KnowledgeElementFacade> knowpres = null;
+ protected static HashMap<Long, DocumentFacade> docpres = null;
+ protected static HashMap<Long, KnowledgeElementFacade> knowpres = null;
public class KnowledgeIterator {
// ------------------------------
protected OpenObject () {
// -----------------------
// All member fields are supposed initialized by subclasses
- if (docpres == null) docpres = new HashMap<Integer, DocumentFacade>();
- if (knowpres == null) knowpres = new HashMap<Integer, KnowledgeElementFacade>();
+ if (docpres == null) docpres = new HashMap<Long, DocumentFacade>();
+ if (knowpres == null) knowpres = new HashMap<Long, KnowledgeElementFacade>();
}
// ==============================================================================================================================
contents = new Vector<DocumentFacade>(list.size());
for (Iterator<Publication> i=list.iterator(); i.hasNext();) {
Publication present = i.next();
- Integer index = present.getIndex();
+ Long index = present.getIndex();
DocumentFacade facade = docpres.get(index);
if (facade == null) {
facade = new DocumentFacade(this, present, getProjectSettings(), getPublicationService());
// -----------------------------
return mystudy.getAuthor().toString();
}
- public Integer getIndex() {
+ public Long getIndex() {
// -------------------------
return mystudy.getIndex();
}
protected void remove (KnowledgeElement kelm) {
// ---------------------------------------------
- KnowledgeIterator known = knowledge.get(kelm.getType().getIndex() - 2);
+ KnowledgeIterator known = knowledge.get((int)(kelm.getType().getIndex() - 2));
// Knowledges are ordered by type index, from 0 to n-1, the first one being reserved (reason for -2)
knowpres.remove(kelm.getIndex());
for (Iterator<KnowledgeElementFacade> i=known.list.iterator(); i.hasNext(); ) {
// WARNING: The selection number must end the action's parameters for the need of refreshGivenStepItem()
} else {
Scenario group = (Scenario)step.getOwner();
- int index = group.getIndex();
+ long index = group.getIndex();
String value = index + "." + number;
if (group.isCheckedout()) icon = "icon.checkedout.png";
else if (getScenarioService().isEmpty(group)) icon = "icon.empty.png";
addItem("0." + number, "menu.step." + number, icon, "step-study?selection=0." + number);
} else {
Scenario group = (Scenario)step.getOwner();
- int index = group.getIndex();
+ long index = group.getIndex();
String value = index + "." + number;
if (index != scenew.getIndex()) {
if (group.isCheckedout()) icon = "icon.checkedout.png";
private String stitle; // Title of the study
private String contributors; // List of existing contributors, some of them may have been removed
private String candidates; // List of added contributors
- private int type; // Type of document to be included in the validation process
+ private long type; // Type of document to be included in the validation process
private int publisher;
private int reviewer;
private int approver;
if (parsekept[i].length() == 0) continue; // Yet no contributor
int index = Integer.valueOf(parsekept[i].trim());
for (Iterator<User> j=toremove.iterator(); j.hasNext(); ){
- int present = j.next().getIndex();
+ long present = j.next().getIndex();
if (present != index) continue;
j.remove();
break;
// -----------------------------------------------
return validefault;
}
- public int getDocumentTypeIndex () {
+ public long getDocumentTypeIndex () {
// ----------------------------------
return type;
}
protected static abstract class UserOption implements Name {
// ----------------------------------------------------------
protected String name;
- protected int index;
+ protected long index;
- public int getIndex() {
+ public long getIndex() {
return index;
}
public String toString () {
// --------------------------------
return myname;
}
- public int getApproverIndex () {
+ public long getApproverIndex () {
// ------------------------------
return myapprover.getIndex();
}
// ------------------------
return myicon;
}
- public int getPublisherIndex () {
+ public long getPublisherIndex () {
// -------------------------------
return mypublisher.getIndex();
}
// ---------------------------------
return mypublisher.toString();
}
- public int getReviewerIndex () {
+ public long getReviewerIndex () {
// ------------------------------
return myreviewer.getIndex();
}
public class ProjectElementFacade {
- private int index; // For checking the equality between ProjectElementFacade objects
+ private long index; // For checking the equality between ProjectElementFacade objects
private Study my;
private String subtitle;
private String step;
}
public int hashCode () {
// ----------------------
- return index;
+ return (int) index;
}
// ==============================================================================================================================
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
+ xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
-http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
-
+http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+http://www.springframework.org/schema/context
+http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+ <context:property-placeholder
+ location="classpath:siman.properties,classpath:jdbc.properties"
+ ignore-unresolvable="true" />
+
<!-- configuration i18n -->
<bean id="i18nUtils"
class="org.splat.i18n.I18nUtils">