diff --git a/INSTALL.rst b/INSTALL.rst
index 8e14342fb..7f56a1817 100644
--- a/INSTALL.rst
+++ b/INSTALL.rst
@@ -326,7 +326,7 @@ Microsoft Windows
Instructions:
-* Download and install latest Java Runtime Environment 7u80 (JRE7u79)::
+* Download and install latest Java Runtime Environment 7u80 (JRE7u80)::
# http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1880261.html
diff --git a/libreplan-business/pom.xml b/libreplan-business/pom.xml
index 84b8c847a..dac0c093d 100644
--- a/libreplan-business/pom.xml
+++ b/libreplan-business/pom.xml
@@ -67,6 +67,7 @@
junit
junit
+
com.jolbox
@@ -105,6 +106,7 @@
org.slf4j
slf4j-log4j12
+
joda-time
@@ -127,6 +129,7 @@
+
liquibase-update
@@ -155,6 +158,7 @@
+
liquibase-updatesql
diff --git a/libreplan-business/src/main/java/org/libreplan/business/common/entities/Configuration.java b/libreplan-business/src/main/java/org/libreplan/business/common/entities/Configuration.java
index f78c4fe3a..1d0930102 100644
--- a/libreplan-business/src/main/java/org/libreplan/business/common/entities/Configuration.java
+++ b/libreplan-business/src/main/java/org/libreplan/business/common/entities/Configuration.java
@@ -135,6 +135,8 @@ public class Configuration extends BaseEntity {
*/
private Integer maxResources = 0;
+ private String repositoryLocation;
+
public void setDefaultCalendar(BaseCalendar defaultCalendar) {
this.defaultCalendar = defaultCalendar;
@@ -533,4 +535,11 @@ public class Configuration extends BaseEntity {
this.enabledAutomaticBudget = enabledAutomaticBudget;
}
+ public String getRepositoryLocation() {
+ return repositoryLocation;
+ }
+ public void setRepositoryLocation(String repositoryLocation) {
+ this.repositoryLocation = repositoryLocation;
+ }
+
}
diff --git a/libreplan-business/src/main/java/org/libreplan/business/email/daos/EmailNotificationDAO.java b/libreplan-business/src/main/java/org/libreplan/business/email/daos/EmailNotificationDAO.java
index e67a9047b..8324c709b 100644
--- a/libreplan-business/src/main/java/org/libreplan/business/email/daos/EmailNotificationDAO.java
+++ b/libreplan-business/src/main/java/org/libreplan/business/email/daos/EmailNotificationDAO.java
@@ -19,8 +19,10 @@
package org.libreplan.business.email.daos;
+import org.hibernate.criterion.Restrictions;
import org.libreplan.business.common.daos.GenericDAOHibernate;
import org.libreplan.business.email.entities.EmailNotification;
+import org.libreplan.business.email.entities.EmailTemplateEnum;
import org.springframework.stereotype.Repository;
import java.util.List;
@@ -40,6 +42,12 @@ public class EmailNotificationDAO extends GenericDAOHibernate getAllByType(EmailTemplateEnum enumeration) {
+ return getSession().createCriteria(EmailNotification.class)
+ .add(Restrictions.eq("type", enumeration)).list();
+ }
+
@Override
public boolean deleteAll() {
List notifications = list(EmailNotification.class);
@@ -47,8 +55,28 @@ public class EmailNotificationDAO extends GenericDAOHibernate notifications = getSession().createCriteria(EmailNotification.class)
+ .add(Restrictions.eq("type", enumeration)).list();
+ for (Object item : notifications){
+ getSession().delete(item);
+ }
+
+ if ( getSession().createCriteria(EmailNotification.class)
+ .add(Restrictions.eq("type", enumeration.ordinal())).list().size() == 0 ) return true;
return false;
}
+ @Override
+ public boolean deleteById(EmailNotification notification) {
+ getSession().delete(notification);
+ if ( getSession().createCriteria(EmailNotification.class).add(Restrictions.eq("id", notification.getId()))
+ .uniqueResult() != null ) return false;
+ return true;
+ }
+
}
diff --git a/libreplan-business/src/main/java/org/libreplan/business/email/daos/IEmailNotificationDAO.java b/libreplan-business/src/main/java/org/libreplan/business/email/daos/IEmailNotificationDAO.java
index 5b4a545a1..140d85547 100644
--- a/libreplan-business/src/main/java/org/libreplan/business/email/daos/IEmailNotificationDAO.java
+++ b/libreplan-business/src/main/java/org/libreplan/business/email/daos/IEmailNotificationDAO.java
@@ -21,6 +21,7 @@ package org.libreplan.business.email.daos;
import org.libreplan.business.common.daos.IGenericDAO;
import org.libreplan.business.email.entities.EmailNotification;
+import org.libreplan.business.email.entities.EmailTemplateEnum;
import java.util.List;
@@ -33,5 +34,9 @@ import java.util.List;
*/
public interface IEmailNotificationDAO extends IGenericDAO {
List getAll();
+ List getAllByType(EmailTemplateEnum enumeration);
+
boolean deleteAll();
+ boolean deleteAllByType(EmailTemplateEnum enumeration);
+ boolean deleteById(EmailNotification notification);
}
diff --git a/libreplan-business/src/main/java/org/libreplan/business/orders/daos/IOrderFileDAO.java b/libreplan-business/src/main/java/org/libreplan/business/orders/daos/IOrderFileDAO.java
new file mode 100644
index 000000000..6b7c4ee35
--- /dev/null
+++ b/libreplan-business/src/main/java/org/libreplan/business/orders/daos/IOrderFileDAO.java
@@ -0,0 +1,41 @@
+/*
+ * This file is part of LibrePlan
+ *
+ * Copyright (C) 2015 LibrePlan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package org.libreplan.business.orders.daos;
+
+import org.libreplan.business.common.daos.IGenericDAO;
+import org.libreplan.business.orders.entities.OrderElement;
+import org.libreplan.business.orders.entities.OrderFile;
+
+import java.util.List;
+
+/**
+ * Created by
+ * @author Vova Perebykivskiy
+ * on 12.24.2015.
+ */
+
+public interface IOrderFileDAO extends IGenericDAO {
+
+ List getAll();
+
+ void delete(OrderFile file);
+
+ List findByParent(OrderElement parent);
+}
diff --git a/libreplan-business/src/main/java/org/libreplan/business/orders/daos/OrderFileDAO.java b/libreplan-business/src/main/java/org/libreplan/business/orders/daos/OrderFileDAO.java
new file mode 100644
index 000000000..6d20f8313
--- /dev/null
+++ b/libreplan-business/src/main/java/org/libreplan/business/orders/daos/OrderFileDAO.java
@@ -0,0 +1,57 @@
+/*
+ * This file is part of LibrePlan
+ *
+ * Copyright (C) 2015 LibrePlan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package org.libreplan.business.orders.daos;
+
+import org.hibernate.criterion.Restrictions;
+import org.libreplan.business.common.daos.GenericDAOHibernate;
+import org.libreplan.business.common.exceptions.InstanceNotFoundException;
+import org.libreplan.business.orders.entities.OrderElement;
+import org.libreplan.business.orders.entities.OrderFile;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * Created by
+ * @author Vova Perebykivskiy
+ * on 12.24.2015.
+ */
+
+@Repository
+public class OrderFileDAO extends GenericDAOHibernate implements IOrderFileDAO {
+
+ @Override
+ public List getAll() {
+ return list(OrderFile.class);
+ }
+
+ @Override
+ public void delete(OrderFile file) {
+ try {
+ remove(file.getId());
+ } catch (InstanceNotFoundException e) {}
+ }
+
+ @Override
+ public List findByParent(OrderElement parent) {
+ return getSession().createCriteria(OrderFile.class)
+ .add(Restrictions.eq("parent", parent)).list();
+ }
+}
diff --git a/libreplan-business/src/main/java/org/libreplan/business/orders/entities/OrderFile.java b/libreplan-business/src/main/java/org/libreplan/business/orders/entities/OrderFile.java
new file mode 100644
index 000000000..77604487d
--- /dev/null
+++ b/libreplan-business/src/main/java/org/libreplan/business/orders/entities/OrderFile.java
@@ -0,0 +1,83 @@
+/*
+ * This file is part of LibrePlan
+ *
+ * Copyright (C) 2015 LibrePlan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package org.libreplan.business.orders.entities;
+
+import org.libreplan.business.common.BaseEntity;
+import org.libreplan.business.users.entities.User;
+
+import java.util.Date;
+
+/**
+ * OrderFile entity representing table: files.
+ * This class is intended to work as a Hibernate component.
+ * It represents the LibrePlan File to be stored in customer`s HDD.
+ *
+ * Created by
+ * @author Vova Perebykivskiy
+ * on 25.12.2015.
+ */
+
+public class OrderFile extends BaseEntity {
+
+ private String name;
+
+ private String type;
+
+ private Date date;
+
+ private User uploader;
+
+ private OrderElement parent;
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ public User getUploader() {
+ return uploader;
+ }
+ public void setUploader(User uploader) {
+ this.uploader = uploader;
+ }
+
+ public OrderElement getParent() {
+ return parent;
+ }
+ public void setParent(OrderElement parent) {
+ this.parent = parent;
+ }
+}
diff --git a/libreplan-business/src/main/java/org/libreplan/business/users/entities/UserRole.java b/libreplan-business/src/main/java/org/libreplan/business/users/entities/UserRole.java
index dc7994017..7eb2a4363 100644
--- a/libreplan-business/src/main/java/org/libreplan/business/users/entities/UserRole.java
+++ b/libreplan-business/src/main/java/org/libreplan/business/users/entities/UserRole.java
@@ -89,8 +89,14 @@ public enum UserRole {
ROLE_PROJECT_STATUS_REPORT(_("Project Status Report")),
ROLE_EDIT_EMAIL_TEMPLATES(_("Edit E-mail Templates")),
+ ROLE_USE_FILES(_("Use files for order")),
- ROLE_EMAIL_TASK_ASSIGNED_TO_RESOURCE(_("Email task assigned to resource"));
+ ROLE_EMAIL_TASK_ASSIGNED_TO_RESOURCE(_("Email: task assigned to resource")),
+ ROLE_EMAIL_RESOURCE_REMOVED_FROM_TASK(_("Email: resource removed from task")),
+ ROLE_EMAIL_MILESTONE_REACHED(_("Email: milestone reached")),
+ ROLE_EMAIL_TASK_SHOULD_FINISH(_("Email: task should finish")),
+ ROLE_EMAIL_TASK_SHOULD_START(_("Email: task should start")),
+ ROLE_EMAIL_TIMESHEET_DATA_MISSING(_("Email: timesheet data missing"));
private final String displayName;
diff --git a/libreplan-business/src/main/resources/db.changelog-1.4.xml b/libreplan-business/src/main/resources/db.changelog-1.4.xml
index b33d15e11..cb53fcb45 100644
--- a/libreplan-business/src/main/resources/db.changelog-1.4.xml
+++ b/libreplan-business/src/main/resources/db.changelog-1.4.xml
@@ -57,7 +57,7 @@
-
+
@@ -30,6 +30,14 @@
+
+ INSERT INTO email_template VALUES(1, 0, 3, 'Task assigned to resource : Autogenerated content text', 'Autogenerated subject text');
+ INSERT INTO email_template VALUES(2, 1, 3, 'Resource removed from task : Autogenerated content text', 'Autogenerated subject text');
+ INSERT INTO email_template VALUES(3, 2, 3, 'Milestone reached : Autogenerated content text', 'Autogenerated subject text');
+ INSERT INTO email_template VALUES(4, 3, 3, 'Task should start : Autogenerated content text', 'Autogenerated subject text');
+ INSERT INTO email_template VALUES(5, 4, 3, 'Task should finish : Autogenerated content text', 'Autogenerated subject text');
+ INSERT INTO email_template VALUES(6, 5, 3, 'Enter data to timesheet : Autogenerated content text', 'Autogenerated subject text');
+
@@ -45,13 +53,13 @@
-
+
@@ -89,7 +97,7 @@
/>
-
+
@@ -127,4 +135,34 @@
/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ UPDATE configuration SET repository_location = '' WHERE id = 404;
+
+
+
diff --git a/libreplan-business/src/main/resources/liquibase.properties b/libreplan-business/src/main/resources/liquibase.properties
index 39ed9ab18..a6921e37d 100644
--- a/libreplan-business/src/main/resources/liquibase.properties
+++ b/libreplan-business/src/main/resources/liquibase.properties
@@ -6,3 +6,6 @@ password ${dataSource.password}
verbose true
dropFirst false
promptOnNonLocalDatabase false
+
+# If there will be an error with checksum use this command:
+#clearCheckSums true
\ No newline at end of file
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/common/entities/Configuration.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/common/entities/Configuration.hbm.xml
index d0a09f150..519c11a7a 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/common/entities/Configuration.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/common/entities/Configuration.hbm.xml
@@ -126,6 +126,8 @@
+
+
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/orders/entities/Orders.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/orders/entities/Orders.hbm.xml
index 5d1172ce4..979c458f1 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/orders/entities/Orders.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/orders/entities/Orders.hbm.xml
@@ -16,9 +16,9 @@
+ column="last_advance_meausurement_for_spreading" />
+ column="dirty_last_advance_measurement_for_spreading" />
@@ -52,34 +52,34 @@
+ access="field"
+ cascade="all"
+ class="org.libreplan.business.orders.entities.OrderLineGroup"
+ index="idx_order_element_on_parent"
+ lazy="false" />
+ access="field"
+ cascade="none"
+ class="org.libreplan.business.templates.entities.OrderElementTemplate"
+ index="idx_order_element_on_template"/>
+ cascade="delete" property-ref="orderElement" />
+ cascade="delete" property-ref="orderElement" />
@@ -102,11 +102,11 @@
+ column="dependencies_constraints_have_priority" access="field" />
+ access="field" />
+ column="last_order_element_sequence_code" access="field" />
@@ -134,7 +134,7 @@
+ class="org.libreplan.business.calendars.entities.BaseCalendar"/>
@@ -144,9 +144,9 @@
@@ -154,16 +154,16 @@
-
-
-
+
+
+
-
-
-
+
+
+
@@ -179,7 +179,7 @@
+ column="last_hours_group_sequence_code" access="field" />
@@ -214,13 +214,13 @@
+ class="org.libreplan.business.orders.entities.OrderLine"
+ index="idx_hours_group_on_parent_order_line"/>
+ class="org.libreplan.business.templates.entities.OrderLineTemplate"
+ index="idx_hours_group_on_order_line_template"/>
@@ -236,7 +236,7 @@
org.libreplan.business.orders.entities.SchedulingState$Type
-
+
@@ -248,9 +248,9 @@
+ cascade="none" unique="true" access="field" lazy="false" />
+ constrained="true" cascade="delete" access="field" lazy="false"/>
@@ -267,21 +267,21 @@
+ class="OrderElement" cascade="none" unique="true" />
+ column="direct_charged_effort"
+ type="org.libreplan.business.workingday.hibernate.EffortDurationType" />
+ column="indirect_charged_effort"
+ type="org.libreplan.business.workingday.hibernate.EffortDurationType" />
+ column="first_timesheet_date" />
+ column="last_timesheet_date" />
+ column="finished_timesheets" />
@@ -294,7 +294,7 @@
+ class="OrderElement" />
@@ -316,4 +316,25 @@
+
+
+
+ 100
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/libreplan-webapp/pom.xml b/libreplan-webapp/pom.xml
index f80cf8816..f93231d2b 100644
--- a/libreplan-webapp/pom.xml
+++ b/libreplan-webapp/pom.xml
@@ -294,6 +294,7 @@
+
net.sf.jasperreports
@@ -303,16 +304,19 @@
net.sf.jasperreports
jasperreports-fonts
+
com.igalia.java.zk.components
jasperreportcomponent
+
com.igalia.java.zk.components
jfreechartengine
+
com.igalia.java.zk.components
@@ -331,6 +335,7 @@
org.springframework.security
spring-security-acl
+
org.springframework.security
@@ -365,11 +370,13 @@
jfree
jcommon
+
commons-fileupload
commons-fileupload
+
org.zkoss.zk
@@ -383,11 +390,13 @@
org.zkoss.zk
zk
+
org.libreplan
ganttzk
+
org.libreplan
@@ -434,7 +443,7 @@
servlet-api
-
+
javax.mail
mail
@@ -446,6 +455,7 @@
javax.ws.rs
jsr311-api
+
org.apache.cxf
@@ -463,6 +473,7 @@
org.codehaus.jackson
jackson-xc
+
org.zkoss.zkforge
@@ -472,26 +483,31 @@
org.zkoss.zkforge
timeplotz
+
org.jgrapht
jgrapht-jdk1.5
+
br.com.digilabs.jqplot
jqplot4java
+
net.sourceforge
mpxj
+
commons-io
commons-io
+
org.quartz-scheduler
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationController.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationController.java
index 8c69d2eea..8c0c1824e 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationController.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationController.java
@@ -1172,6 +1172,14 @@ public class ConfigurationController extends GenericForwardComposer {
configurationModel.setSecondsPlanningWarning(secondsPlanningWarning);
}
+ public String getRepositoryLocation(){
+ return configurationModel.getRepositoryLocation();
+ }
+
+ public void setRepositoryLocation(String location){
+ configurationModel.setRepositoryLocation(location);
+ }
+
public List getConnectors() {
return configurationModel.getConnectors();
}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationModel.java
index 4d7bd2cc1..1a7385573 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationModel.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationModel.java
@@ -63,6 +63,7 @@ import org.springframework.transaction.annotation.Transactional;
/**
* @author Manuel Rego Casasnovas
* @author Cristina Alvarino Perez
+ * @author Vova Perebykivskiy
*/
@Service
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
@@ -538,8 +539,7 @@ public class ConfigurationModel implements IConfigurationModel {
return entitySequences.get(entityName);
}
- public void addEntitySequence(EntityNameEnum entityName, String prefix,
- Integer digits) {
+ public void addEntitySequence(EntityNameEnum entityName, String prefix, Integer digits) {
List sequences = entitySequences.get(entityName);
EntitySequence entitySequence = EntitySequence.create(prefix,
entityName, digits);
@@ -692,6 +692,16 @@ public class ConfigurationModel implements IConfigurationModel {
configuration.setSecondsPlanningWarning(secondsPlanningWarning);
}
+ @Override
+ public String getRepositoryLocation() {
+ return configuration.getRepositoryLocation();
+ }
+
+ @Override
+ public void setRepositoryLocation(String location) {
+ configuration.setRepositoryLocation(location);
+ }
+
private void saveConnectors() {
for (Connector connector : connectors) {
connectorDAO.save(connector);
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/IConfigurationModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/IConfigurationModel.java
index 5a423e31e..099e43fa8 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/common/IConfigurationModel.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/IConfigurationModel.java
@@ -37,6 +37,7 @@ import org.libreplan.business.costcategories.entities.TypeOfWorkHours;
* Contract for {@link ConfigurationModel}.
*
* @author Manuel Rego Casasnovas
+ * @author Vova Perebykivskiy
*/
public interface IConfigurationModel {
@@ -102,8 +103,7 @@ public interface IConfigurationModel {
List getEntitySequences(EntityNameEnum entityName);
- void addEntitySequence(EntityNameEnum entityName, String prefix,
- Integer digits);
+ void addEntitySequence(EntityNameEnum entityName, String prefix, Integer digits);
void removeEntitySequence(EntitySequence entitySequence)
throws IllegalArgumentException;
@@ -186,6 +186,10 @@ public interface IConfigurationModel {
void setSecondsPlanningWarning(
Integer planningWarningExitWithoutSavingSeconds);
+ String getRepositoryLocation();
+
+ void setRepositoryLocation(String location);
+
List getConnectors();
Connector getConnectorByName(String name);
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/email/EmailNotificationModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/email/EmailNotificationModel.java
index d40b15a92..6e29c659b 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/email/EmailNotificationModel.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/email/EmailNotificationModel.java
@@ -52,17 +52,7 @@ public class EmailNotificationModel implements IEmailNotificationModel {
@Autowired
private IEmailNotificationDAO emailNotificationDAO;
- private EmailTemplateEnum type;
-
- private Date updated;
-
- private Resource resource;
-
- private TaskElement task;
-
- private TaskElement project;
-
- private EmailNotification emailNotification = new EmailNotification();
+ private EmailNotification emailNotification;
@Override
@Transactional
@@ -76,12 +66,29 @@ public class EmailNotificationModel implements IEmailNotificationModel {
return emailNotificationDAO.getAll();
}
+ @Override
+ @Transactional
+ public List getAllByType(EmailTemplateEnum enumeration) {
+ return emailNotificationDAO.getAllByType(enumeration);
+ }
+
@Override
@Transactional
public boolean deleteAll() {
return emailNotificationDAO.deleteAll();
}
+ @Override
+ public boolean deleteAllByType(EmailTemplateEnum enumeration) {
+ return emailNotificationDAO.deleteAllByType(enumeration);
+ }
+
+ @Override
+ @Transactional
+ public boolean deleteById(EmailNotification notification){
+ return emailNotificationDAO.deleteById(notification);
+ }
+
@Override
public void setType(EmailTemplateEnum type) {
this.emailNotification.setType(type);
@@ -107,4 +114,13 @@ public class EmailNotificationModel implements IEmailNotificationModel {
this.emailNotification.setProject(project);
}
+
+ public EmailNotification getEmailNotification() {
+ return emailNotification;
+ }
+
+ public void setNewObject(){
+ this.emailNotification = new EmailNotification();
+ }
+
}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/email/EmailTemplateController.java b/libreplan-webapp/src/main/java/org/libreplan/web/email/EmailTemplateController.java
index 5d48f8ff3..28866de20 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/email/EmailTemplateController.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/email/EmailTemplateController.java
@@ -75,8 +75,7 @@ public class EmailTemplateController extends GenericForwardComposer{
public static ListitemRenderer languagesRenderer = new ListitemRenderer() {
@Override
- public void render(org.zkoss.zul.Listitem item, Object data)
- throws Exception {
+ public void render(Listitem item, Object data) throws Exception {
Language language = (Language) data;
String displayName = language.getDisplayName();
item.setLabel(displayName);
@@ -90,7 +89,7 @@ public class EmailTemplateController extends GenericForwardComposer{
messages = new MessagesForUser(messagesContainer);
// Set default template and language for user
- // And content and subject for it
+ // And content and subject for that language & template
setUser();
setSelectedLanguage(user.getApplicationLanguage());
@@ -108,7 +107,9 @@ public class EmailTemplateController extends GenericForwardComposer{
return true;
} catch (ValidationException e) {
messages.showInvalidValues(e);
- } catch (InstanceNotFoundException e) {}
+ } catch (InstanceNotFoundException e) {
+ e.printStackTrace();
+ }
return false;
}
@@ -193,7 +194,7 @@ public class EmailTemplateController extends GenericForwardComposer{
subjectTextbox.setValue(emailTemplateModel.getSubjectBySelectedLanguage(getSelectedLanguage().ordinal(), getSelectedEmailTemplateEnum().ordinal()));
}
private void getSubjectDataBySelectedTemplate(){
- subjectTextbox.setValue( emailTemplateModel.getContentBySelectedTemplate(getSelectedEmailTemplateEnum().ordinal(), getSelectedLanguage().ordinal()) );
+ subjectTextbox.setValue( emailTemplateModel.getSubjectBySelectedTemplate(getSelectedEmailTemplateEnum().ordinal(), getSelectedLanguage().ordinal()) );
}
@Transactional
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/email/EmailTemplateModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/email/EmailTemplateModel.java
index adbb0dba8..10a52166f 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/email/EmailTemplateModel.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/email/EmailTemplateModel.java
@@ -24,10 +24,7 @@ import org.libreplan.business.settings.entities.Language;
import org.libreplan.business.email.daos.IEmailTemplateDAO;
import org.libreplan.business.email.entities.EmailTemplate;
import org.libreplan.business.email.entities.EmailTemplateEnum;
-import org.libreplan.business.users.daos.IUserDAO;
-import org.libreplan.business.users.entities.User;
import org.libreplan.web.common.concurrentdetection.OnConcurrentModification;
-import org.libreplan.web.security.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
@@ -51,26 +48,13 @@ public class EmailTemplateModel implements IEmailTemplateModel {
@Autowired
private IEmailTemplateDAO emailTemplateDAO;
- @Autowired
- private IUserDAO userDAO;
-
- private Language language = Language.ENGLISH_LANGUAGE;
-
- private EmailTemplateEnum emailTemplateEnum = EmailTemplateEnum.TEMPLATE_TASK_ASSIGNED_TO_RESOURCE;
-
- private String content;
-
- private String subject;
-
- private User user;
-
private EmailTemplate emailTemplate = new EmailTemplate();
@Override
@Transactional
public void confirmSave() throws InstanceNotFoundException {
- /* If current EmailTemplate entity (id) is existing in DB than it needs to update.
+ /* If current EmailTemplate entity (id) is existing in DB than it needs to be updated.
* Else current EmailTemplate entity (id) is creating and getting new values from form.
*/
List emailTemplates = emailTemplateDAO.getAll();
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/email/IEmailNotificationModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/email/IEmailNotificationModel.java
index f4ed94648..96320d94f 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/email/IEmailNotificationModel.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/email/IEmailNotificationModel.java
@@ -40,8 +40,11 @@ public interface IEmailNotificationModel {
void confirmSave() throws ValidationException;
List getAll();
+ List getAllByType(EmailTemplateEnum enumeration);
boolean deleteAll();
+ boolean deleteAllByType(EmailTemplateEnum enumeration);
+ boolean deleteById(EmailNotification notification);
void setType(EmailTemplateEnum type);
void setUpdated(Date date);
@@ -49,4 +52,7 @@ public interface IEmailNotificationModel {
void setTask(TaskElement task);
void setProject(TaskElement project);
+ EmailNotification getEmailNotification();
+
+ void setNewObject();
}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/orders/OrderCRUDController.java b/libreplan-webapp/src/main/java/org/libreplan/web/orders/OrderCRUDController.java
index d5c7904d3..d88a50627 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/orders/OrderCRUDController.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/orders/OrderCRUDController.java
@@ -72,6 +72,7 @@ import org.libreplan.web.common.components.finders.FilterPair;
import org.libreplan.web.common.components.finders.OrderFilterEnum;
import org.libreplan.web.common.components.finders.TaskGroupFilterEnum;
import org.libreplan.web.orders.criterionrequirements.AssignedCriterionRequirementToOrderElementController;
+import org.libreplan.web.orders.files.OrderFilesController;
import org.libreplan.web.orders.labels.AssignedLabelsToOrderElementController;
import org.libreplan.web.orders.labels.LabelsAssignmentToOrderElementComponent;
import org.libreplan.web.orders.materials.AssignedMaterialsToOrderElementController;
@@ -278,17 +279,17 @@ public class OrderCRUDController extends GenericForwardComposer {
List sessionFilters = FilterUtils
.readProjectsParameters();
// Allow labels when list is empty
- if (sessionFilters != null) {
+ if ( sessionFilters != null ) {
bdFilters.addSelectedElements(toOrderFilterEnum(sessionFilters));
return;
}
User user = orderModel.getUser();
// Calculate filter based on user preferences
- if ((user != null) && (user.getProjectsFilterLabel() != null)) {
+ if ( (user != null) && (user.getProjectsFilterLabel() != null) ) {
bdFilters.addSelectedElement(new FilterPair(OrderFilterEnum.Label,
- user.getProjectsFilterLabel().getFinderPattern(), user
- .getProjectsFilterLabel()));
+ user.getProjectsFilterLabel().getFinderPattern(),
+ user.getProjectsFilterLabel()));
}
}
@@ -298,23 +299,23 @@ public class OrderCRUDController extends GenericForwardComposer {
TaskGroupFilterEnum type = (TaskGroupFilterEnum) filterPair
.getType();
switch (type) {
- case Label:
- result.add(new FilterPair(OrderFilterEnum.Label, filterPair
- .getPattern(), filterPair.getValue()));
- break;
- case Criterion:
- result.add(new FilterPair(OrderFilterEnum.Criterion, filterPair
- .getPattern(), filterPair.getValue()));
- break;
- case ExternalCompany:
- result.add(new FilterPair(OrderFilterEnum.ExternalCompany,
- filterPair.getPattern(), filterPair.getValue()));
- break;
- case State:
- result.add(new FilterPair(OrderFilterEnum.State, filterPair
- .getPattern(), filterPair.getValue()));
- break;
- default:
+ case Label:
+ result.add(new FilterPair(OrderFilterEnum.Label, filterPair
+ .getPattern(), filterPair.getValue()));
+ break;
+ case Criterion:
+ result.add(new FilterPair(OrderFilterEnum.Criterion, filterPair
+ .getPattern(), filterPair.getValue()));
+ break;
+ case ExternalCompany:
+ result.add(new FilterPair(OrderFilterEnum.ExternalCompany,
+ filterPair.getPattern(), filterPair.getValue()));
+ break;
+ case State:
+ result.add(new FilterPair(OrderFilterEnum.State, filterPair
+ .getPattern(), filterPair.getValue()));
+ break;
+ default:
}
}
return result;
@@ -452,8 +453,7 @@ public class OrderCRUDController extends GenericForwardComposer {
});
}
- private Comboitem createCombo(Object value, String label,
- String description) {
+ private Comboitem createCombo(Object value, String label, String description) {
Comboitem result = new Comboitem();
result.setValue(value);
result.setLabel(label);
@@ -646,7 +646,7 @@ public class OrderCRUDController extends GenericForwardComposer {
if (assignedLabelsController == null) {
LabelsAssignmentToOrderElementComponent labelsAssignment = (LabelsAssignmentToOrderElementComponent) editWindow
- .getFellow("orderElementLabels");
+ .getFellow("orderElementLabels");
assignedLabelsController = labelsAssignment.getController();
final IOrderElementModel orderElementModel = getOrderElementModel();
@@ -664,9 +664,9 @@ public class OrderCRUDController extends GenericForwardComposer {
if (assignedCriterionRequirementController == null) {
Component orderElementCriterionRequirements = editWindow
- .getFellowIfAny("orderElementCriterionRequirements");
+ .getFellowIfAny("orderElementCriterionRequirements");
assignedCriterionRequirementController = (AssignedCriterionRequirementToOrderElementController) orderElementCriterionRequirements
- .getVariable("assignedCriterionRequirementController", true);
+ .getVariable("assignedCriterionRequirementController", true);
final IOrderElementModel orderElementModel = getOrderElementModel();
assignedCriterionRequirementController
@@ -686,7 +686,7 @@ public class OrderCRUDController extends GenericForwardComposer {
if (assignedMaterialsController == null) {
OrderElementMaterialAssignmentsComponent assignmentsComponent = (OrderElementMaterialAssignmentsComponent) editWindow
- .getFellowIfAny("orderElementMaterials");
+ .getFellowIfAny("orderElementMaterials");
assignedMaterialsController = assignmentsComponent.getController();
final IOrderElementModel orderElementModel = getOrderElementModel();
@@ -707,7 +707,7 @@ public class OrderCRUDController extends GenericForwardComposer {
.getFellowIfAny("orderElementTaskQualityForms");
if (assignedTaskQualityFormController == null) {
assignedTaskQualityFormController = (AssignedTaskQualityFormsToOrderElementController) orderElementTaskQualityForms
- .getVariable("assignedTaskQualityFormsController", true);
+ .getVariable("assignedTaskQualityFormsController", true);
final IOrderElementModel orderElementModel = getOrderElementModel();
assignedTaskQualityFormController.openWindow(orderElementModel);
} else {
@@ -716,6 +716,29 @@ public class OrderCRUDController extends GenericForwardComposer {
}
}
+ private OrderFilesController orderFilesController;
+
+ public void setupOrderFilesController(){
+ if ( !confirmLastTab() ){
+ return;
+ }
+ setCurrentTab();
+
+ Component orderFiles = editWindow.getFellowIfAny("orderElementFiles");
+
+ if ( orderFilesController == null ){
+ orderFilesController = (OrderFilesController) orderFiles
+ .getVariable("orderFilesController", true);
+
+ final IOrderElementModel orderElementModel = getOrderElementModel();
+
+ orderFilesController.openWindow(orderElementModel);
+
+ } else {
+
+ }
+ }
+
private OrderAuthorizationController orderAuthorizationController;
public void setupOrderAuthorizationController() {
@@ -771,29 +794,29 @@ public class OrderCRUDController extends GenericForwardComposer {
.getSelectedElements()) {
OrderFilterEnum type = (OrderFilterEnum) filterPair.getType();
switch (type) {
- case Label:
- labels.add((org.libreplan.business.labels.entities.Label) filterPair
- .getValue());
- break;
- case Criterion:
- criteria.add((Criterion) filterPair.getValue());
- break;
- case ExternalCompany:
- if (customer != null) {
- // It's impossible to have an Order associated to more than
- // 1 customer
- return Collections.emptyList();
- }
- customer = (ExternalCompany) filterPair.getValue();
- break;
- case State:
- if (state != null) {
- // It's impossible to have an Order associated with more
- // than 1 state
- return Collections.emptyList();
- }
- state = (OrderStatusEnum) filterPair.getValue();
- break;
+ case Label:
+ labels.add((org.libreplan.business.labels.entities.Label) filterPair
+ .getValue());
+ break;
+ case Criterion:
+ criteria.add((Criterion) filterPair.getValue());
+ break;
+ case ExternalCompany:
+ if (customer != null) {
+ // It's impossible to have an Order associated to more than
+ // 1 customer
+ return Collections.emptyList();
+ }
+ customer = (ExternalCompany) filterPair.getValue();
+ break;
+ case State:
+ if (state != null) {
+ // It's impossible to have an Order associated with more
+ // than 1 state
+ return Collections.emptyList();
+ }
+ state = (OrderStatusEnum) filterPair.getValue();
+ break;
}
}
@@ -862,7 +885,7 @@ public class OrderCRUDController extends GenericForwardComposer {
private void refreshCodeTextboxesOnly() {
if (orderElementTreeController != null) {
Map orderElementCodeTextBoxes =
- orderElementTreeController.getOrderElementCodeTextboxes();
+ orderElementTreeController.getOrderElementCodeTextboxes();
for (OrderElement element : orderElementCodeTextBoxes.keySet()) {
if (element.getId() != null) {
@@ -1423,10 +1446,9 @@ public class OrderCRUDController extends GenericForwardComposer {
public void validate(Component comp, Object value)
throws WrongValueException {
Date finishDate = (Date) value;
- if ((finishDate != null)
+ if ( (finishDate != null)
&& (filterStartDate.getRawValue() != null)
- && (finishDate.compareTo((Date) filterStartDate
- .getRawValue()) < 0)) {
+ && (finishDate.compareTo((Date) filterStartDate.getRawValue()) < 0) ) {
throw new WrongValueException(comp,
_("must be after start date"));
}
@@ -1440,11 +1462,9 @@ public class OrderCRUDController extends GenericForwardComposer {
public void validate(Component comp, Object value)
throws WrongValueException {
Date startDate = (Date) value;
- if ((startDate != null)
+ if ( (startDate != null)
&& (filterFinishDate.getRawValue() != null)
- && (startDate.compareTo((Date) filterFinishDate
- .getRawValue()) > 0)) {
- // filterStartDate.setValue(null);
+ && (startDate.compareTo((Date) filterFinishDate.getRawValue()) > 0) ) {
throw new WrongValueException(comp,
_("must be lower than end date"));
}
@@ -1480,26 +1500,26 @@ public class OrderCRUDController extends GenericForwardComposer {
OrderFilterEnum type = (OrderFilterEnum) filterPair
.getType();
switch (type) {
- case Label:
- result.add(new FilterPair(TaskGroupFilterEnum.Label, filterPair
- .getPattern(), filterPair.getValue()));
- break;
- case Criterion:
- result.add(new FilterPair(TaskGroupFilterEnum.Criterion,
- filterPair.getPattern(), filterPair.getValue()));
- break;
- case ExternalCompany:
- result.add(new FilterPair(TaskGroupFilterEnum.ExternalCompany,
- filterPair.getPattern(), filterPair.getValue()));
- break;
- case State:
- result.add(new FilterPair(TaskGroupFilterEnum.State, filterPair
- .getPattern(), filterPair.getValue()));
- break;
- default:
- result.add(new FilterPair(OrderFilterEnum.Label, filterPair
- .getPattern(), filterPair.getValue()));
- break;
+ case Label:
+ result.add(new FilterPair(TaskGroupFilterEnum.Label, filterPair
+ .getPattern(), filterPair.getValue()));
+ break;
+ case Criterion:
+ result.add(new FilterPair(TaskGroupFilterEnum.Criterion,
+ filterPair.getPattern(), filterPair.getValue()));
+ break;
+ case ExternalCompany:
+ result.add(new FilterPair(TaskGroupFilterEnum.ExternalCompany,
+ filterPair.getPattern(), filterPair.getValue()));
+ break;
+ case State:
+ result.add(new FilterPair(TaskGroupFilterEnum.State, filterPair
+ .getPattern(), filterPair.getValue()));
+ break;
+ default:
+ result.add(new FilterPair(OrderFilterEnum.Label, filterPair
+ .getPattern(), filterPair.getValue()));
+ break;
}
}
return result;
@@ -1582,7 +1602,7 @@ public class OrderCRUDController extends GenericForwardComposer {
if (!(orderElement instanceof Order)
&& orderElementTreeController != null) {
final Treeitem item = orderElementTreeController
- .getTreeitemByOrderElement(orderElement);
+ .getTreeitemByOrderElement(orderElement);
if (item != null) {
orderElementTreeController
@@ -1641,7 +1661,7 @@ public class OrderCRUDController extends GenericForwardComposer {
public SortedSet getDeliverDates() {
if(getOrder() != null){
- return getOrder().getDeliveringDates();
+ return getOrder().getDeliveringDates();
}
return new TreeSet(new DeliverDateComparator());
}
@@ -1870,12 +1890,10 @@ public class OrderCRUDController extends GenericForwardComposer {
public BigDecimal getResourcesBudget() {
return Registry.getTransactionService().runOnReadOnlyTransaction(
- new IOnTransaction() {
-
- @Override
- public BigDecimal execute() {
- return getOrderElementModel().getOrderElement()
- .getResourcesBudget();
+ new IOnTransaction() {
+ @Override
+ public BigDecimal execute() {
+ return getOrderElementModel().getOrderElement().getResourcesBudget();
}
});
}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/orders/files/IOrderFileModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/orders/files/IOrderFileModel.java
new file mode 100644
index 000000000..d3759acb1
--- /dev/null
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/orders/files/IOrderFileModel.java
@@ -0,0 +1,40 @@
+package org.libreplan.web.orders.files;
+
+import org.libreplan.business.orders.entities.OrderElement;
+import org.libreplan.business.orders.entities.OrderFile;
+import org.libreplan.business.users.entities.User;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Contract for {@link OrderFile}
+ *
+ * Created by
+ * @author Vova Perebykivskiy
+ * on 12.24.2015.
+ */
+public interface IOrderFileModel {
+
+ void confirmSave();
+
+ void setFileName(String name);
+
+ void setFileType(String type);
+
+ void setUploadDate(Date date);
+
+ void setUploader(User user);
+
+ void setParent(OrderElement project);
+
+ void createNewFileObject();
+
+ List getAll();
+
+ void delete(OrderFile file);
+
+ List findByParent(OrderElement parent);
+
+ OrderFile getOrderFile();
+}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/orders/files/OrderFileModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/orders/files/OrderFileModel.java
new file mode 100644
index 000000000..deff9c733
--- /dev/null
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/orders/files/OrderFileModel.java
@@ -0,0 +1,88 @@
+package org.libreplan.web.orders.files;
+
+import org.libreplan.business.orders.daos.IOrderFileDAO;
+import org.libreplan.business.orders.entities.OrderElement;
+import org.libreplan.business.orders.entities.OrderFile;
+import org.libreplan.business.users.entities.User;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Created by
+ * @author Vova Perebykivskiy
+ * on 12.24.2015.
+ */
+
+@Service
+@Scope(BeanDefinition.SCOPE_PROTOTYPE)
+public class OrderFileModel implements IOrderFileModel {
+
+ @Autowired
+ private IOrderFileDAO fileDAO;
+
+ private OrderFile orderFile;
+
+ @Override
+ @Transactional
+ public void confirmSave() {
+ fileDAO.save(orderFile);
+ }
+
+ @Override
+ public void setFileName(String name) {
+ orderFile.setName(name);
+ }
+
+ @Override
+ public void setFileType(String type) {
+ orderFile.setType(type);
+ }
+
+ @Override
+ public void setUploadDate(Date date) {
+ orderFile.setDate(date);
+ }
+
+ @Override
+ public void setUploader(User user) {
+ orderFile.setUploader(user);
+ }
+
+ @Override
+ public void setParent(OrderElement project) {
+ orderFile.setParent(project);
+ }
+
+ @Override
+ public void createNewFileObject() {
+ orderFile = new OrderFile();
+ }
+
+ @Override
+ @Transactional
+ public List getAll() {
+ return fileDAO.getAll();
+ }
+
+ @Override
+ @Transactional
+ public void delete(OrderFile file){
+ fileDAO.delete(file);
+ }
+
+ @Override
+ @Transactional
+ public List findByParent(OrderElement parent) {
+ return fileDAO.findByParent(parent);
+ }
+
+ public OrderFile getOrderFile() {
+ return orderFile;
+ }
+}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/orders/files/OrderFilesController.java b/libreplan-webapp/src/main/java/org/libreplan/web/orders/files/OrderFilesController.java
new file mode 100644
index 000000000..8adb61286
--- /dev/null
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/orders/files/OrderFilesController.java
@@ -0,0 +1,297 @@
+/*
+ * This file is part of LibrePlan
+ *
+ * Copyright (C) 2016 LibrePlan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package org.libreplan.web.orders.files;
+
+import org.apache.commons.io.FilenameUtils;
+import org.hibernate.engine.jdbc.ReaderInputStream;
+import org.libreplan.business.orders.entities.OrderElement;
+import org.libreplan.business.orders.entities.OrderFile;
+
+import org.libreplan.business.users.daos.IUserDAO;
+
+import org.libreplan.web.common.IConfigurationModel;
+import org.libreplan.web.common.IMessagesForUser;
+import org.libreplan.web.common.Level;
+import org.libreplan.web.common.Util;
+import org.libreplan.web.common.MessagesForUser;
+import org.libreplan.web.orders.IOrderElementModel;
+import org.libreplan.web.security.SecurityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.zkoss.util.media.Media;
+import org.zkoss.zk.ui.Component;
+import org.zkoss.zk.ui.event.Event;
+import org.zkoss.zk.ui.event.EventListener;
+import org.zkoss.zk.ui.util.GenericForwardComposer;
+import org.zkoss.zul.Fileupload;
+import org.zkoss.zul.ListModelList;
+import org.zkoss.zul.Listbox;
+import org.zkoss.zul.ListitemRenderer;
+import org.zkoss.zul.Messagebox;
+import org.zkoss.zul.Listitem;
+import org.zkoss.zul.Listcell;
+import org.zkoss.zul.Label;
+import org.zkoss.zul.Filedownload;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import static org.libreplan.web.I18nHelper._;
+
+
+/**
+ * Controller for managing Order files
+ * Created by
+ * @author Vova Perebykivskiy
+ * on 12.24.2015.
+ */
+
+public class OrderFilesController extends GenericForwardComposer {
+
+ @Autowired
+ IConfigurationModel configurationModel;
+
+ @Autowired
+ IUserDAO userDAO;
+
+ private Component messagesContainer;
+
+ private IMessagesForUser messages;
+
+ private IOrderElementModel orderElementModel;
+
+ private IOrderFileModel orderFileModel;
+
+ private Listbox filesList;
+
+ @Override
+ public void doAfterCompose(Component comp) throws Exception {
+ super.doAfterCompose(comp);
+ comp.setVariable("orderFilesController", this, true);
+ messages = new MessagesForUser(messagesContainer);
+ }
+
+ public boolean isRepositoryExists() {
+ configurationModel.init();
+
+ File repositoryDirectory = null;
+ if ( !(configurationModel.getRepositoryLocation() == null) )
+ repositoryDirectory = new File(configurationModel.getRepositoryLocation());
+
+ if ( repositoryDirectory != null && repositoryDirectory.exists() ) return true;
+
+ return false;
+ }
+
+ public boolean isUploadButtonDisabled(){
+ if ( isRepositoryExists() ) return false;
+
+ return true;
+ }
+
+ public ListitemRenderer getFilesRenderer(){
+ return new ListitemRenderer() {
+ @Override
+ public void render(Listitem listitem, Object data) throws Exception {
+ final OrderFile file = (OrderFile) data;
+
+ Listcell nameCell = new Listcell();
+ listitem.appendChild(nameCell);
+ Label label = new Label(file.getName());
+ label.addEventListener("onClick", new EventListener() {
+ @Override
+ public void onEvent(Event event) throws Exception {
+ configurationModel.init();
+ String projectCode = orderElementModel.getOrderElement().getCode();
+ String directory = configurationModel.getRepositoryLocation() + "orders" + "/" + projectCode;
+
+ File fileToDownload = new File(directory + "/" + file.getName() + "." + file.getType());
+ Filedownload.save(fileToDownload.getAbsoluteFile(), null);
+ }
+ });
+ label.setClass("label-highlight");
+ label.setTooltiptext("Download file");
+ nameCell.appendChild(label);
+
+
+ Listcell typeCell = new Listcell();
+ listitem.appendChild(typeCell);
+ typeCell.appendChild(new Label(file.getType()));
+
+ Listcell dateCell = new Listcell();
+ listitem.appendChild(dateCell);
+ SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
+ dateCell.appendChild(new Label(sdf.format(file.getDate())));
+
+ Listcell uploaderCell = new Listcell();
+ listitem.appendChild(uploaderCell);
+ uploaderCell.appendChild(new Label(file.getUploader().getLoginName()));
+
+ Listcell operationsCell = new Listcell();
+ listitem.appendChild(operationsCell);
+ operationsCell.appendChild(Util.createRemoveButton(new EventListener() {
+ @Override
+ public void onEvent(Event event) throws Exception {
+ confirmRemove(file);
+ }
+ }));
+
+ }
+ };
+ }
+
+
+ public void confirmRemove(OrderFile file){
+
+ try {
+ int status = Messagebox.show(_("Confirm deleting this file. Are you sure?"), _("Delete"),
+ Messagebox.OK | Messagebox.CANCEL, Messagebox.QUESTION);
+ if ( Messagebox.OK != status ) {
+ return;
+ }
+ } catch (InterruptedException e) {}
+
+
+ if ( isRepositoryExists() ) {
+
+ String projectCode = orderElementModel.getOrderElement().getCode();
+ configurationModel.init();
+ String directory = configurationModel.getRepositoryLocation() + "orders" + "/" + projectCode;
+
+ File fileToDelete = new File(directory + "/" + file.getName() + "." + file.getType());
+
+ boolean deleted = fileToDelete.delete();
+
+ if ( deleted ){
+ orderFileModel.delete(file);
+
+ messages.clearMessages();
+ messages.showMessage(Level.INFO, "File successfully deleted");
+
+ updateListbox();
+ } else {
+ messages.clearMessages();
+ messages.showMessage(Level.ERROR, "Error while deleting");
+ }
+
+ } else {
+ messages.clearMessages();
+ messages.showMessage(Level.ERROR, "Repository not created");
+ }
+
+
+ }
+
+ public void upload() {
+ configurationModel.init();
+
+ String directory = "";
+ if ( isRepositoryExists() ){
+
+ String projectCode = orderElementModel.getOrderElement().getCode();
+ directory = configurationModel.getRepositoryLocation() + "orders" + "/" + projectCode;
+
+ try {
+ Fileupload fileupload = new Fileupload();
+
+ // Location of file: libreplan-webapp/src/main/webapp/planner/fileupload.zul
+ fileupload.setTemplate("fileupload.zul");
+
+
+ Media media = fileupload.get();
+
+ File dir = new File(directory);
+ String filename = media.getName();
+ File file = new File(dir, filename);
+
+ // By default Java do not create directories itself
+ file.getParentFile().mkdirs();
+
+ OutputStream outputStream = new FileOutputStream(file);
+
+ InputStream inputStream = media.isBinary() ? (media.getStreamData()) :
+ (new ReaderInputStream(media.getReaderData()));
+
+ if ( inputStream != null ){
+ byte[] buffer = new byte[1024];
+ for ( int count; (count = inputStream.read(buffer)) != -1; )
+ outputStream.write(buffer, 0, count);
+ }
+
+ outputStream.flush();
+ outputStream.close();
+ inputStream.close();
+
+
+ orderFileModel.createNewFileObject();
+ orderFileModel.setFileName(FilenameUtils.getBaseName(media.getName()));
+ orderFileModel.setFileType(FilenameUtils.getExtension(media.getName()));
+ orderFileModel.setUploadDate(new Date());
+ orderFileModel.setUploader(userDAO.findByLoginName(SecurityUtils.getSessionUserLoginName()));
+ orderFileModel.setParent(orderElementModel.getOrderElement());
+
+ orderFileModel.confirmSave();
+
+
+ } catch (Exception e){
+ e.printStackTrace();
+ }
+
+ finally {
+ updateListbox();
+ }
+
+ } else messages.showMessage(Level.ERROR, _("Please, make repository"));
+
+ }
+
+ /**
+ * This method is a:
+ * 1. setter for current opened {@link org.libreplan.business.orders.entities.Order}
+ * 2. setter for model of ListBox of files
+ *
+ * The easiest way is to set a model in zul file, but its setter was invoking before
+ * setter of current {@link org.libreplan.business.orders.entities.Order}
+ */
+ public void openWindow(IOrderElementModel orderElementModel) {
+ setOrderElementModel(orderElementModel);
+
+ if ( isRepositoryExists() ) updateListbox();
+ }
+
+ /**
+ * Listbox is updating after re set the model for it
+ */
+ public void updateListbox(){
+ OrderElement currentOrder = orderElementModel.getOrderElement();
+ filesList.setModel(new ListModelList(orderFileModel.findByParent(currentOrder)));
+ }
+
+ public IOrderElementModel getOrderElementModel() {
+ return orderElementModel;
+ }
+ public void setOrderElementModel(IOrderElementModel orderElementModel) {
+ this.orderElementModel = orderElementModel;
+ }
+}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/resources/machine/MachineCRUDController.java b/libreplan-webapp/src/main/java/org/libreplan/web/resources/machine/MachineCRUDController.java
index 6860100b3..bade77223 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/resources/machine/MachineCRUDController.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/resources/machine/MachineCRUDController.java
@@ -626,7 +626,7 @@ public class MachineCRUDController extends BaseCRUDController {
public boolean isCreateButtonDisabled(){
Limits resourcesTypeLimit = limitsModel.getResourcesType();
- Integer resourcesCount = (Integer) resourceDAO.getRowCount();
+ Integer resourcesCount = resourceDAO.getRowCount().intValue();
if ( resourcesTypeLimit != null )
if ( resourcesCount >= resourcesTypeLimit.getValue() )
@@ -637,7 +637,7 @@ public class MachineCRUDController extends BaseCRUDController {
public String getShowCreateFormLabel(){
Limits resourcesTypeLimit = limitsModel.getResourcesType();
- Integer resourcesCount = (Integer) resourceDAO.getRowCount();
+ Integer resourcesCount = resourceDAO.getRowCount().intValue();
int resourcesLeft = resourcesTypeLimit.getValue() - resourcesCount;
if ( resourcesTypeLimit != null )
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/resources/worker/WorkerCRUDController.java b/libreplan-webapp/src/main/java/org/libreplan/web/resources/worker/WorkerCRUDController.java
index 5a5169343..d9a83d324 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/resources/worker/WorkerCRUDController.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/resources/worker/WorkerCRUDController.java
@@ -1172,7 +1172,7 @@ public class WorkerCRUDController extends GenericForwardComposer implements
public boolean isCreateButtonDisabled(){
Limits resourcesTypeLimit = limitsModel.getResourcesType();
- Integer resourcesCount = (Integer) resourceDAO.getRowCount();
+ Integer resourcesCount = resourceDAO.getRowCount().intValue();
if ( resourcesTypeLimit != null )
if ( resourcesCount >= resourcesTypeLimit.getValue() )
@@ -1183,7 +1183,7 @@ public class WorkerCRUDController extends GenericForwardComposer implements
public String getShowCreateFormLabel(){
Limits resourcesTypeLimit = limitsModel.getResourcesType();
- Integer resourcesCount = (Integer) resourceDAO.getRowCount();
+ Integer resourcesCount = resourceDAO.getRowCount().intValue();
int resourcesLeft = resourcesTypeLimit.getValue() - resourcesCount;
if ( resourcesTypeLimit != null )
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/UserCRUDController.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/UserCRUDController.java
index 775f3ee32..ddf437dc8 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/users/UserCRUDController.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/UserCRUDController.java
@@ -505,7 +505,7 @@ public class UserCRUDController extends BaseCRUDController implements
public boolean isCreateButtonDisabled(){
Limits usersTypeLimit = limitsModel.getUsersType();
- Integer usersCount = (Integer) userModel.getRowCount();
+ Integer usersCount = userModel.getRowCount().intValue();
if (usersTypeLimit != null)
if ( usersCount >= usersTypeLimit.getValue() )
return true;
@@ -514,7 +514,7 @@ public class UserCRUDController extends BaseCRUDController implements
public String getShowCreateFormLabel(){
Limits usersTypeLimit = limitsModel.getUsersType();
- Integer usersCount = (Integer) userModel.getRowCount();
+ Integer usersCount = userModel.getRowCount().intValue();
int usersLeft = usersTypeLimit.getValue() - usersCount;
if (usersTypeLimit != null)
if ( usersCount >= usersTypeLimit.getValue() )
diff --git a/libreplan-webapp/src/main/resources/i18n/keys.pot b/libreplan-webapp/src/main/resources/i18n/keys.pot
index 252da9e64..e7266bcf4 100644
--- a/libreplan-webapp/src/main/resources/i18n/keys.pot
+++ b/libreplan-webapp/src/main/resources/i18n/keys.pot
@@ -145,6 +145,7 @@ msgstr ""
#: libreplan-webapp/src/main/webapp/qualityforms/_listQualityForm.zul:38
#: libreplan-webapp/src/main/webapp/qualityforms/_editQualityForm.zul:87
#: libreplan-webapp/src/main/webapp/limitingresources/limitingResourcesLayout.zul:143
+#: libreplan-webapp/src/main/webapp/orders/_listOrderElementFiles.zul:40
msgid "Operations"
msgstr ""
@@ -3547,6 +3548,7 @@ msgid "Unschedule"
msgstr ""
#: libreplan-webapp/src/main/webapp/users/_editUser.zul:36
+#: libreplan-webapp/src/main/webapp/email/email_template.zul:42
msgid "General user data"
msgstr ""
@@ -4648,6 +4650,7 @@ msgstr ""
#: libreplan-webapp/src/main/webapp/qualityforms/_editQualityForm.zul:42
#: libreplan-webapp/src/main/webapp/qualityforms/_editQualityForm.zul:83
#: libreplan-webapp/src/main/webapp/limitingresources/limitingResourcesLayout.zul:96
+#: libreplan-webapp/src/main/webapp/orders/_listOrderElementFiles.zul:36
msgid "Name"
msgstr ""
@@ -8129,6 +8132,7 @@ msgstr ""
#: libreplan-webapp/src/main/webapp/orders/_listOrderElementCriterionRequirements.zul:47
#: libreplan-webapp/src/main/webapp/orders/_listOrderElementCriterionRequirements.zul:153
#: libreplan-webapp/src/main/webapp/advance/_editAdvanceTypes.zul:62
+#: libreplan-webapp/src/main/webapp/orders/_listOrderElementFiles.zul:37
msgid "Type"
msgstr ""
@@ -8760,6 +8764,7 @@ msgstr ""
#: libreplan-webapp/src/main/webapp/orders/_listOrderElementCriterionRequirements.zul:212
#: libreplan-webapp/src/main/webapp/qualityforms/_listQualityForm.zul:52
#: libreplan-webapp/src/main/webapp/qualityforms/_editQualityForm.zul:116
+#: libreplan-webapp/src/main/java/org/libreplan/web/orders/files/OrderFilesController.java:148
msgid "Delete"
msgstr ""
@@ -9226,6 +9231,7 @@ msgid "Task assigned to resource"
msgstr ""
#: libreplan-webapp/src/main/java/org/libreplan/web/common/CustomMenuController.java:425
+#: libreplan-business/src/main/java/org/libreplan/business/users/entities/UserRole.java:91
msgid "Edit E-mail Templates"
msgstr ""
@@ -9314,3 +9320,43 @@ msgstr ""
#: libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationController.java:247
msgid "Check fields"
msgstr ""
+
+#: libreplan-webapp/src/main/webapp/orders/_edition.zul:59
+msgid "Files"
+msgstr ""
+
+#: libreplan-business/src/main/java/org/libreplan/business/users/entities/UserRole.java:92
+msgid "Use files for order"
+msgstr ""
+
+#: libreplan-webapp/src/main/java/org/libreplan/web/orders/files/OrderFilesController.java:252
+msgid "Please, make repository"
+msgstr ""
+
+#: libreplan-webapp/src/main/java/org/libreplan/web/orders/files/OrderFilesController.java:148
+msgid "Confirm deleting this file. Are you sure?"
+msgstr ""
+
+#: libreplan-webapp/src/main/webapp/orders/_listOrderElementFiles.zul:26
+msgid "Upload"
+msgstr ""
+
+#: libreplan-webapp/src/main/webapp/orders/_listOrderElementFiles.zul:38
+msgid "Upload date"
+msgstr ""
+
+#: libreplan-webapp/src/main/webapp/orders/_listOrderElementFiles.zul:39
+msgid "Uploaded by"
+msgstr ""
+
+#: libreplan-webapp/src/main/webapp/email/email_template.zul:50
+msgid "Select template language"
+msgstr ""
+
+#: libreplan-webapp/src/main/webapp/email/email_template.zul:59
+msgid "Select template type"
+msgstr ""
+
+#: libreplan-webapp/src/main/webapp/common/configuration.zul:240
+msgid "Local document repository location"
+msgstr ""
diff --git a/libreplan-webapp/src/main/webapp/common/configuration.zul b/libreplan-webapp/src/main/webapp/common/configuration.zul
index 88638ff9b..0b700cc2d 100644
--- a/libreplan-webapp/src/main/webapp/common/configuration.zul
+++ b/libreplan-webapp/src/main/webapp/common/configuration.zul
@@ -236,6 +236,14 @@
value="${i18n:_('Defines the time since last saving operation at project planning perspectives after which a warning is raised on leaving. Set to 0 in order to disable the warning.')}" />
+
+
+
+
diff --git a/libreplan-webapp/src/main/webapp/dashboard/_pipeline.zul b/libreplan-webapp/src/main/webapp/dashboard/_pipeline.zul
index 7b2e5a08a..04b578b77 100644
--- a/libreplan-webapp/src/main/webapp/dashboard/_pipeline.zul
+++ b/libreplan-webapp/src/main/webapp/dashboard/_pipeline.zul
@@ -1,5 +1,6 @@
-
+
diff --git a/libreplan-webapp/src/main/webapp/email/email_templates.zul b/libreplan-webapp/src/main/webapp/email/email_templates.zul
index 6b754eb50..6413c8d2f 100644
--- a/libreplan-webapp/src/main/webapp/email/email_templates.zul
+++ b/libreplan-webapp/src/main/webapp/email/email_templates.zul
@@ -39,7 +39,7 @@
-
+
@@ -47,7 +47,7 @@
-
+
-
+
+
@@ -56,6 +57,8 @@
onSelect = "controller.setupAssignedMaterialsToOrderElementController();"/>
+
@@ -334,6 +337,9 @@
+
+
+
diff --git a/libreplan-webapp/src/main/webapp/orders/_listOrderElementFiles.zul b/libreplan-webapp/src/main/webapp/orders/_listOrderElementFiles.zul
new file mode 100644
index 000000000..e1935f6c4
--- /dev/null
+++ b/libreplan-webapp/src/main/webapp/orders/_listOrderElementFiles.zul
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/libreplan-webapp/src/main/webapp/planner/fileupload.zul b/libreplan-webapp/src/main/webapp/planner/fileupload.zul
new file mode 100644
index 000000000..09a623fd5
--- /dev/null
+++ b/libreplan-webapp/src/main/webapp/planner/fileupload.zul
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/libreplan-webapp/src/test/java/org/libreplan/web/orders/OrderFilesTest.java b/libreplan-webapp/src/test/java/org/libreplan/web/orders/OrderFilesTest.java
new file mode 100644
index 000000000..46609fe45
--- /dev/null
+++ b/libreplan-webapp/src/test/java/org/libreplan/web/orders/OrderFilesTest.java
@@ -0,0 +1,269 @@
+/*
+ * This file is part of LibrePlan
+ *
+ * Copyright (C) 2016 LibrePlan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package org.libreplan.web.orders;
+
+
+import org.hibernate.PropertyValueException;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.libreplan.business.BusinessGlobalNames.BUSINESS_SPRING_CONFIG_FILE;
+import static org.libreplan.web.WebappGlobalNames.WEBAPP_SPRING_CONFIG_FILE;
+import static org.libreplan.web.WebappGlobalNames.WEBAPP_SPRING_SECURITY_CONFIG_FILE;
+import static org.libreplan.web.test.WebappGlobalNames.WEBAPP_SPRING_CONFIG_TEST_FILE;
+import static org.libreplan.web.test.WebappGlobalNames.WEBAPP_SPRING_SECURITY_CONFIG_TEST_FILE;
+
+import org.hibernate.Transaction;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+import org.libreplan.business.orders.entities.HoursGroup;
+import org.libreplan.business.orders.entities.OrderElement;
+import org.libreplan.business.orders.entities.OrderFile;
+import org.libreplan.business.orders.entities.OrderLine;
+import org.libreplan.business.users.entities.User;
+import org.libreplan.web.orders.files.IOrderFileModel;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import java.util.Date;
+import java.util.List;
+
+
+/**
+ * Tests for {@link OrderFile}.
+ * Created by
+ * @author Vova Perebykivskiy
+ * on 11.01.2016.
+ */
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = { BUSINESS_SPRING_CONFIG_FILE,
+ WEBAPP_SPRING_CONFIG_FILE, WEBAPP_SPRING_CONFIG_TEST_FILE,
+ WEBAPP_SPRING_SECURITY_CONFIG_FILE,
+ WEBAPP_SPRING_SECURITY_CONFIG_TEST_FILE })
+public class OrderFilesTest {
+
+ @Autowired
+ private IOrderFileModel orderFileModel;
+
+ @Autowired
+ private IOrderElementModel orderElementModel;
+
+ @Autowired
+ private SessionFactory sessionFactory;
+
+ private Session newSession;
+
+ private Transaction transaction;
+
+ /**
+ * A new session is opened because there was a lot of errors with {@link Transaction}, {@link Session}
+ *
+ * CRUD test
+ * 1. Add row to files table
+ * 2. Add row and read it
+ * 3. Add row and update added row
+ * 4. Add row and delete it
+ *
+ * Negative test
+ * 1. Create row with null field value and try to save it
+ */
+ @Test
+ public void testRead() {
+ // This initialize method is for all test methods
+ initialize();
+
+ // Make OrderFile
+ orderFileModel.createNewFileObject();
+ orderFileModel.setFileName("noname");
+ orderFileModel.setFileType(".htaccess");
+ orderFileModel.setUploadDate(new Date());
+ orderFileModel.setUploader( (User) newSession.createCriteria(User.class).list().get(0) );
+ orderFileModel.setParent( (OrderElement) newSession.createCriteria(OrderElement.class).list().get(0) );
+
+ newSession.save(orderFileModel.getOrderFile());
+ transactionBeginCommit();
+
+ List file = orderFileModel.getAll();
+ assertEquals(file.get(0).getName(), "noname");
+
+ // Clean data
+ OrderFile orderFile = (OrderFile) newSession.createCriteria(OrderFile.class).list().get(0);
+ newSession.delete(orderFile);
+ transactionBeginCommit();
+
+ newSession.close();
+ }
+
+ @Test
+ public void testCreate(){
+ newSession = sessionFactory.openSession();
+
+ int sizeBefore = orderFileModel.getAll().size();
+
+ // Make OrderFile
+ orderFileModel.createNewFileObject();
+ orderFileModel.setFileName("Index");
+ orderFileModel.setFileType("html");
+ orderFileModel.setUploadDate(new Date());
+ orderFileModel.setUploader( (User) newSession.createCriteria(User.class).list().get(0) );
+ orderFileModel.setParent( (OrderElement) newSession.createCriteria(OrderElement.class).list().get(0) );
+
+ newSession.save(orderFileModel.getOrderFile());
+ transactionBeginCommit();
+
+ int sizeWithNewRow = orderFileModel.getAll().size();
+
+ assertEquals(sizeBefore + 1, sizeWithNewRow);
+
+ // Clean data
+ OrderFile orderFile = (OrderFile) newSession.createCriteria(OrderFile.class).list().get(0);
+ newSession.delete(orderFile);
+ transactionBeginCommit();
+
+ newSession.close();
+ }
+
+ @Test
+ public void testDelete(){
+ newSession = sessionFactory.openSession();
+
+ int sizeBefore = orderFileModel.getAll().size();
+
+ // Make OrderFile
+ orderFileModel.createNewFileObject();
+ orderFileModel.setFileName("Main");
+ orderFileModel.setFileType("java");
+ orderFileModel.setUploadDate(new Date());
+ orderFileModel.setUploader( (User) newSession.createCriteria(User.class).list().get(0) );
+ orderFileModel.setParent( (OrderElement) newSession.createCriteria(OrderElement.class).list().get(0) );
+
+ newSession.save(orderFileModel.getOrderFile());
+ transactionBeginCommit();
+
+ newSession.delete(orderFileModel.getOrderFile());
+ transactionBeginCommit();
+
+ int sizeAfter = orderFileModel.getAll().size();
+
+ assertEquals(sizeBefore, sizeAfter);
+
+ newSession.close();
+ }
+
+ @Test(expected = PropertyValueException.class)
+ public void testCreateNotValidRow(){
+ newSession = sessionFactory.openSession();
+
+ // Make OrderFile
+ orderFileModel.createNewFileObject();
+ orderFileModel.setFileName(null);
+ orderFileModel.setFileType("html");
+ orderFileModel.setUploadDate(new Date());
+ orderFileModel.setUploader( (User) newSession.createCriteria(User.class).list().get(0) );
+ orderFileModel.setParent( (OrderElement) newSession.createCriteria(OrderElement.class).list().get(0) );
+
+ newSession.save(orderFileModel.getOrderFile());
+ transactionBeginCommit();
+
+ newSession.close();
+ }
+
+ @Test
+ public void testUpdate(){
+ newSession = sessionFactory.openSession();
+
+ // Make OrderFile
+ orderFileModel.createNewFileObject();
+ orderFileModel.setFileName("yii");
+ orderFileModel.setFileType("bat");
+ orderFileModel.setUploadDate(new Date());
+ orderFileModel.setUploader( (User) newSession.createCriteria(User.class).list().get(0) );
+ orderFileModel.setParent( (OrderElement) newSession.createCriteria(OrderElement.class).list().get(0) );
+
+ newSession.save(orderFileModel.getOrderFile());
+ transactionBeginCommit();
+
+ // Get saved OrderFile and update it
+ OrderFile orderFile = (OrderFile) newSession.createCriteria(OrderFile.class).list().get(0);
+ orderFile.setName("yii2");
+
+ newSession.save(orderFile);
+ transactionBeginCommit();
+
+ // Get updated OrderFile and check for equality
+ OrderFile newOrderFile = (OrderFile) newSession.createCriteria(OrderFile.class).list().get(0);
+ assertTrue( newOrderFile.getName().equals("yii2") );
+
+ /**
+ * It is necessary to delete user and order element because it make influence on some other tests
+ */
+ OrderFile orderFileToDelete = (OrderFile) newSession.createCriteria(OrderFile.class).list().get(0);
+ User userToDelete = (User) newSession.createCriteria(User.class).list().get(0);
+ OrderElement orderElementToDelete = (OrderElement) newSession.createCriteria(OrderElement.class).list().get(0);
+
+ newSession.delete(orderFileToDelete);
+ newSession.delete(userToDelete);
+ newSession.delete(orderElementToDelete);
+ transactionBeginCommit();
+
+ newSession.close();
+ }
+
+
+ public void initialize(){
+ newSession = sessionFactory.openSession();
+ createUser();
+ createOrderElement();
+ }
+
+ private void createUser(){
+ User user = User.create("harry-potter", "somePassword", "harry-potter@hogwarts.uk");
+ newSession.save(user);
+ transactionBeginCommit();
+ }
+
+ private void createOrderElement(){
+ OrderLine result = OrderLine.create();
+ result.setName("OrderLineB");
+ result.setCode("1a1k1k1k");
+ HoursGroup hoursGroup = HoursGroup.create(result);
+ hoursGroup.setWorkingHours(0);
+ hoursGroup.setCode("hoursGroupName1");
+ result.addHoursGroup(hoursGroup);
+
+ OrderElement orderElement = result;
+ orderElementModel.setCurrent(orderElement, new OrderModel());
+ newSession.save(orderElement);
+ transactionBeginCommit();
+ }
+
+ private void transactionBeginCommit(){
+ transaction = newSession.beginTransaction();
+ transaction.commit();
+ }
+}
diff --git a/pom.xml b/pom.xml
index 7c94b0034..6f291baad 100644
--- a/pom.xml
+++ b/pom.xml
@@ -159,6 +159,7 @@
gettext-commons-site
http://gettext-commons.googlecode.com/svn/maven-repository
+
thirdparty
@@ -184,6 +185,7 @@
+
net.sf.jasperreports
@@ -195,24 +197,28 @@
jasperreports-fonts
4.0.0
+
com.igalia.java.zk.components
jasperreportcomponent
1.0
+
com.igalia.java.zk.components
jfreechartengine
1.1
+
com.igalia.java.zk.components
customdetailrowcomponent
1.0.0
+
org.xnap.commons
@@ -318,6 +324,7 @@
spring-security-acl
3.2.3.RELEASE
+
org.springframework.security
@@ -332,6 +339,7 @@
4.12
test
+
com.jolbox
@@ -379,18 +387,21 @@
ezmorph
1.0.6
+
commons-lang
commons-lang
2.4
+
commons-math
commons-math
1.2
+
commons-logging
@@ -407,6 +418,7 @@
slf4j-log4j12
1.7.7
+
org.beanshell
@@ -414,6 +426,7 @@
2.0b4
runtime
+
commons-fileupload
@@ -421,6 +434,7 @@
1.2.1
runtime
+
org.zkoss.zk
@@ -443,12 +457,14 @@
+
org.jgrapht
jgrapht-jdk1.5
0.7.3
+
jfree
@@ -460,18 +476,21 @@
jcommon
1.0.16
+
joda-time
joda-time
2.3
+
org.libreplan
ganttzk
${project.version}
+
org.libreplan
@@ -490,12 +509,14 @@
jar
provided
+
javax.ws.rs
jsr311-api
1.0
+
org.apache.cxf
@@ -539,6 +560,7 @@
+
org.codehaus.jackson
@@ -550,6 +572,7 @@
jackson-xc
1.9.9
+
org.zkoss.zkforge
@@ -579,24 +602,28 @@
liquibase-maven-plugin
2.0.5
+
br.com.digilabs.jqplot
jqplot4java
1.2.3-javascript
+
net.sourceforge
mpxj
4.3.0
+
commons-io
commons-io
1.4
+
org.quartz-scheduler
@@ -811,12 +838,14 @@
${jdbcDriver.artifactId}
${jdbcDriver.version}
+
com.jolbox
bonecp
0.7.1.RELEASE
+
org.slf4j