Documents uploading/downloading feature + tests.

i18n.
Resolving bugs/issues.
Code refactoring.
Add Liquibase tip.
This commit is contained in:
Vova Perebykivskiy 2016-02-18 15:53:05 +02:00 committed by Tester
parent a2a936b313
commit d780b187bf
38 changed files with 1435 additions and 190 deletions

View file

@ -326,7 +326,7 @@ Microsoft Windows
Instructions: 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 # http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1880261.html

View file

@ -67,6 +67,7 @@
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
</dependency> </dependency>
<!-- datasource for testing --> <!-- datasource for testing -->
<dependency> <dependency>
<groupId>com.jolbox</groupId> <groupId>com.jolbox</groupId>
@ -105,6 +106,7 @@
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>slf4j-log4j12</artifactId>
</dependency> </dependency>
<!-- Joda Time --> <!-- Joda Time -->
<dependency> <dependency>
<groupId>joda-time</groupId> <groupId>joda-time</groupId>
@ -127,6 +129,7 @@
<profiles> <profiles>
<profile> <profile>
<!-- LiquiBase liquibase:update --> <!-- LiquiBase liquibase:update -->
<id>liquibase-update</id> <id>liquibase-update</id>
<activation> <activation>
@ -155,6 +158,7 @@
</build> </build>
</profile> </profile>
<profile> <profile>
<!-- LiquiBase liquibase:updateSQL --> <!-- LiquiBase liquibase:updateSQL -->
<id>liquibase-updatesql</id> <id>liquibase-updatesql</id>
<activation> <activation>

View file

@ -135,6 +135,8 @@ public class Configuration extends BaseEntity {
*/ */
private Integer maxResources = 0; private Integer maxResources = 0;
private String repositoryLocation;
public void setDefaultCalendar(BaseCalendar defaultCalendar) { public void setDefaultCalendar(BaseCalendar defaultCalendar) {
this.defaultCalendar = defaultCalendar; this.defaultCalendar = defaultCalendar;
@ -533,4 +535,11 @@ public class Configuration extends BaseEntity {
this.enabledAutomaticBudget = enabledAutomaticBudget; this.enabledAutomaticBudget = enabledAutomaticBudget;
} }
public String getRepositoryLocation() {
return repositoryLocation;
}
public void setRepositoryLocation(String repositoryLocation) {
this.repositoryLocation = repositoryLocation;
}
} }

View file

@ -19,8 +19,10 @@
package org.libreplan.business.email.daos; package org.libreplan.business.email.daos;
import org.hibernate.criterion.Restrictions;
import org.libreplan.business.common.daos.GenericDAOHibernate; import org.libreplan.business.common.daos.GenericDAOHibernate;
import org.libreplan.business.email.entities.EmailNotification; import org.libreplan.business.email.entities.EmailNotification;
import org.libreplan.business.email.entities.EmailTemplateEnum;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
@ -40,6 +42,12 @@ public class EmailNotificationDAO extends GenericDAOHibernate<EmailNotification,
return list(EmailNotification.class); return list(EmailNotification.class);
} }
@Override
public List<EmailNotification> getAllByType(EmailTemplateEnum enumeration) {
return getSession().createCriteria(EmailNotification.class)
.add(Restrictions.eq("type", enumeration)).list();
}
@Override @Override
public boolean deleteAll() { public boolean deleteAll() {
List<EmailNotification> notifications = list(EmailNotification.class); List<EmailNotification> notifications = list(EmailNotification.class);
@ -47,8 +55,28 @@ public class EmailNotificationDAO extends GenericDAOHibernate<EmailNotification,
getSession().delete(item); getSession().delete(item);
} }
if ( list(EmailNotification.class).size() == 0 ) return true; return list(EmailNotification.class).size() == 0;
}
@Override
public boolean deleteAllByType(EmailTemplateEnum enumeration) {
List<EmailNotification> 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; 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;
}
} }

View file

@ -21,6 +21,7 @@ package org.libreplan.business.email.daos;
import org.libreplan.business.common.daos.IGenericDAO; import org.libreplan.business.common.daos.IGenericDAO;
import org.libreplan.business.email.entities.EmailNotification; import org.libreplan.business.email.entities.EmailNotification;
import org.libreplan.business.email.entities.EmailTemplateEnum;
import java.util.List; import java.util.List;
@ -33,5 +34,9 @@ import java.util.List;
*/ */
public interface IEmailNotificationDAO extends IGenericDAO<EmailNotification, Long> { public interface IEmailNotificationDAO extends IGenericDAO<EmailNotification, Long> {
List<EmailNotification> getAll(); List<EmailNotification> getAll();
List<EmailNotification> getAllByType(EmailTemplateEnum enumeration);
boolean deleteAll(); boolean deleteAll();
boolean deleteAllByType(EmailTemplateEnum enumeration);
boolean deleteById(EmailNotification notification);
} }

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
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 <vova@libreplan-enterprise.com>
* on 12.24.2015.
*/
public interface IOrderFileDAO extends IGenericDAO<OrderFile, Long> {
List<OrderFile> getAll();
void delete(OrderFile file);
List<OrderFile> findByParent(OrderElement parent);
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
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 <vova@libreplan-enterprise.com>
* on 12.24.2015.
*/
@Repository
public class OrderFileDAO extends GenericDAOHibernate<OrderFile, Long> implements IOrderFileDAO {
@Override
public List<OrderFile> getAll() {
return list(OrderFile.class);
}
@Override
public void delete(OrderFile file) {
try {
remove(file.getId());
} catch (InstanceNotFoundException e) {}
}
@Override
public List<OrderFile> findByParent(OrderElement parent) {
return getSession().createCriteria(OrderFile.class)
.add(Restrictions.eq("parent", parent)).list();
}
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
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 <vova@libreplan-enterprise.com>
* 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;
}
}

View file

@ -89,8 +89,14 @@ public enum UserRole {
ROLE_PROJECT_STATUS_REPORT(_("Project Status Report")), ROLE_PROJECT_STATUS_REPORT(_("Project Status Report")),
ROLE_EDIT_EMAIL_TEMPLATES(_("Edit E-mail Templates")), 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; private final String displayName;

View file

@ -57,7 +57,7 @@
</createTable> </createTable>
<addUniqueConstraint <addUniqueConstraint
constraintName="type" constraintName="limits_type_uc"
columnNames="type" columnNames="type"
deferrable="false" deferrable="false"
disabled="false" disabled="false"

View file

@ -5,7 +5,7 @@
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd"> http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">
<changeSet id="adding-email_template_table" author="vova/jeroen"> <changeSet id="adding-email_template-table" author="vova/jeroen">
<createTable tableName="email_template"> <createTable tableName="email_template">
<column name="id" type="BIGINT" autoIncrement="true"> <column name="id" type="BIGINT" autoIncrement="true">
<constraints primaryKey="true" nullable="false" primaryKeyName="email_templates_pkey"/> <constraints primaryKey="true" nullable="false" primaryKeyName="email_templates_pkey"/>
@ -30,6 +30,14 @@
<createIndex tableName="email_template" indexName="type_index"> <createIndex tableName="email_template" indexName="type_index">
<column name="type"></column> <column name="type"></column>
</createIndex> </createIndex>
<sql>
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');
</sql>
</changeSet> </changeSet>
<changeSet id="adding-notification_notification_queue" author="vova"> <changeSet id="adding-notification_notification_queue" author="vova">
@ -45,13 +53,13 @@
</createTable> </createTable>
<addUniqueConstraint <addUniqueConstraint
tableName="notification_queue" tableName="notification_queue"
columnNames="resource, task, project" columnNames="type, resource, task, project"
deferrable="false" deferrable="false"
disabled="false" disabled="false"
initiallyDeferred="false"/> initiallyDeferred="false"/>
</changeSet> </changeSet>
<changeSet id="adding-issue_log_table" author="misha/vova"> <changeSet id="adding-issue_log-table" author="misha/vova">
<createTable tableName="issue_log"> <createTable tableName="issue_log">
<column name="id" type="BIGINT" autoIncrement="true"> <column name="id" type="BIGINT" autoIncrement="true">
<constraints primaryKey="true" nullable="false" primaryKeyName="issue_log_pkey"/> <constraints primaryKey="true" nullable="false" primaryKeyName="issue_log_pkey"/>
@ -89,7 +97,7 @@
/> />
</changeSet> </changeSet>
<changeSet id="adding-risk_log_table" author="misha/vova"> <changeSet id="adding-risk_log-table" author="misha/vova">
<createTable tableName="risk_log"> <createTable tableName="risk_log">
<column name="id" type="BIGINT" autoIncrement="true"> <column name="id" type="BIGINT" autoIncrement="true">
<constraints primaryKey="true" nullable="false" primaryKeyName="risk_log_pkey"/> <constraints primaryKey="true" nullable="false" primaryKeyName="risk_log_pkey"/>
@ -127,4 +135,34 @@
/> />
</changeSet> </changeSet>
<changeSet id="adding-local-repository_location-to-configuration-table" author="vova">
<addColumn tableName="configuration">
<column name="repository_location" type="varchar(1024)" />
</addColumn>
</changeSet>
<changeSet id="adding-files-table" author="vova/jeroen">
<createTable tableName="files">
<column name="id" type="BIGINT" autoIncrement="true">
<constraints primaryKey="true" nullable="false" primaryKeyName="files_pkey"/>
</column>
<column name="name" type="varchar(1024)"/>
<column name="type" type="varchar(22)"/>
<column name="date" type="timestamp with time zone"/>
<column name="uploader" type="BIGINT"/>
<column name="parent" type="BIGINT"/>
</createTable>
<addForeignKeyConstraint baseTableName="files" baseColumnNames="uploader"
constraintName="files_uploader_fkey" referencedTableName="user_table"
referencedColumnNames="id"/>
<addForeignKeyConstraint baseTableName="files" baseColumnNames="parent"
constraintName="files_parent_fkey" referencedTableName="order_element"
referencedColumnNames="id"/>
<sql>
UPDATE configuration SET repository_location = '' WHERE id = 404;
</sql>
</changeSet>
</databaseChangeLog> </databaseChangeLog>

View file

@ -6,3 +6,6 @@ password ${dataSource.password}
verbose true verbose true
dropFirst false dropFirst false
promptOnNonLocalDatabase false promptOnNonLocalDatabase false
# If there will be an error with checksum use this command:
#clearCheckSums true

View file

@ -126,6 +126,8 @@
</set> </set>
</component> </component>
<property name="repositoryLocation" column="repository_location"/>
</class> </class>
</hibernate-mapping> </hibernate-mapping>

View file

@ -16,9 +16,9 @@
<property name="initDate" access="field" column="init_date" /> <property name="initDate" access="field" column="init_date" />
<property name="deadline" access="field" /> <property name="deadline" access="field" />
<property name="lastAdvanceMeausurementForSpreading" access="field" <property name="lastAdvanceMeausurementForSpreading" access="field"
column="last_advance_meausurement_for_spreading" /> column="last_advance_meausurement_for_spreading" />
<property name="dirtyLastAdvanceMeasurementForSpreading" access="field" <property name="dirtyLastAdvanceMeasurementForSpreading" access="field"
column="dirty_last_advance_measurement_for_spreading" /> column="dirty_last_advance_measurement_for_spreading" />
<!-- Indexed the other side --> <!-- Indexed the other side -->
<set name="directAdvanceAssignments" access="field" cascade="all,delete-orphan" inverse="true" batch-size="10"> <set name="directAdvanceAssignments" access="field" cascade="all,delete-orphan" inverse="true" batch-size="10">
@ -52,34 +52,34 @@
<!-- Inverse navigation from OrderElement to OrderLineGroup --> <!-- Inverse navigation from OrderElement to OrderLineGroup -->
<!-- Indexed --> <!-- Indexed -->
<many-to-one name="parent" <many-to-one name="parent"
access="field" access="field"
cascade="all" cascade="all"
class="org.libreplan.business.orders.entities.OrderLineGroup" class="org.libreplan.business.orders.entities.OrderLineGroup"
index="idx_order_element_on_parent" index="idx_order_element_on_parent"
lazy="false" /> lazy="false" />
<many-to-one name="template" <many-to-one name="template"
access="field" access="field"
cascade="none" cascade="none"
class="org.libreplan.business.templates.entities.OrderElementTemplate" class="org.libreplan.business.templates.entities.OrderElementTemplate"
index="idx_order_element_on_template"/> index="idx_order_element_on_template"/>
<property name="externalCode" access="field" column="external_code" /> <property name="externalCode" access="field" column="external_code" />
<map name="schedulingDatasForVersion" table="scheduling_states_by_order_version" <map name="schedulingDatasForVersion" table="scheduling_states_by_order_version"
cascade="all-delete-orphan"> cascade="all-delete-orphan">
<key column="order_element_id"></key> <key column="order_element_id"></key>
<map-key-many-to-many column="order_version_id" <map-key-many-to-many column="order_version_id"
class="org.libreplan.business.scenarios.entities.OrderVersion" /> class="org.libreplan.business.scenarios.entities.OrderVersion" />
<many-to-many class="SchedulingDataForVersion" <many-to-many class="SchedulingDataForVersion"
column="scheduling_state_for_version_id" /> column="scheduling_state_for_version_id" />
</map> </map>
<one-to-one name="sumChargedEffort" class="SumChargedEffort" <one-to-one name="sumChargedEffort" class="SumChargedEffort"
cascade="delete" property-ref="orderElement" /> cascade="delete" property-ref="orderElement" />
<one-to-one name="sumExpenses" class="SumExpenses" <one-to-one name="sumExpenses" class="SumExpenses"
cascade="delete" property-ref="orderElement" /> cascade="delete" property-ref="orderElement" />
<joined-subclass name="OrderLineGroup" table="order_line_group"> <joined-subclass name="OrderLineGroup" table="order_line_group">
<key column="order_element_id"></key> <key column="order_element_id"></key>
@ -102,11 +102,11 @@
<property name="responsible" access="field" /> <property name="responsible" access="field" />
<property name="dependenciesConstraintsHavePriority" <property name="dependenciesConstraintsHavePriority"
column="dependencies_constraints_have_priority" access="field" /> column="dependencies_constraints_have_priority" access="field" />
<property name="codeAutogenerated" column="code_autogenerated" <property name="codeAutogenerated" column="code_autogenerated"
access="field" /> access="field" />
<property name="lastOrderElementSequenceCode" <property name="lastOrderElementSequenceCode"
column="last_order_element_sequence_code" access="field" /> column="last_order_element_sequence_code" access="field" />
<property name="workBudget" column="work_budget" access="field" /> <property name="workBudget" column="work_budget" access="field" />
<property name="materialsBudget" column="materials_budget" access="field" /> <property name="materialsBudget" column="materials_budget" access="field" />
@ -134,7 +134,7 @@
<!-- Not indexed --> <!-- Not indexed -->
<many-to-one name="calendar" column="base_calendar_id" cascade="none" <many-to-one name="calendar" column="base_calendar_id" cascade="none"
class="org.libreplan.business.calendars.entities.BaseCalendar"/> class="org.libreplan.business.calendars.entities.BaseCalendar"/>
<set name="orderAuthorizations" cascade="all-delete-orphan" inverse="true" batch-size="10"> <set name="orderAuthorizations" cascade="all-delete-orphan" inverse="true" batch-size="10">
<key column="order_id" /> <key column="order_id" />
@ -144,9 +144,9 @@
<map name="scenarios" table="scenario_orders" cascade="save-update"> <map name="scenarios" table="scenario_orders" cascade="save-update">
<key column="order_id" /> <key column="order_id" />
<map-key-many-to-many column="scenario_id" <map-key-many-to-many column="scenario_id"
class="org.libreplan.business.scenarios.entities.Scenario" /> class="org.libreplan.business.scenarios.entities.Scenario" />
<many-to-many column="order_version_id" <many-to-many column="order_version_id"
class="org.libreplan.business.scenarios.entities.OrderVersion"/> class="org.libreplan.business.scenarios.entities.OrderVersion"/>
</map> </map>
<set name="customerCommunications" cascade="delete-orphan" inverse="true" > <set name="customerCommunications" cascade="delete-orphan" inverse="true" >
@ -154,16 +154,16 @@
<one-to-many class="org.libreplan.business.externalcompanies.entities.CustomerCommunication" /> <one-to-many class="org.libreplan.business.externalcompanies.entities.CustomerCommunication" />
</set> </set>
<set name="deliveringDates" inverse="false" cascade="all,delete-orphan" access="field" <set name="deliveringDates" inverse="false" cascade="all,delete-orphan" access="field"
sort="org.libreplan.business.externalcompanies.entities.DeliverDateComparator"> sort="org.libreplan.business.externalcompanies.entities.DeliverDateComparator">
<key column="order_id" /> <key column="order_id" />
<one-to-many class="org.libreplan.business.externalcompanies.entities.DeadlineCommunication" /> <one-to-many class="org.libreplan.business.externalcompanies.entities.DeadlineCommunication" />
</set> </set>
<set name="endDateCommunicationToCustomer" inverse="false" cascade="all,delete-orphan" access="field" <set name="endDateCommunicationToCustomer" inverse="false" cascade="all,delete-orphan" access="field"
sort="org.libreplan.business.externalcompanies.entities.EndDateCommunicationComparator"> sort="org.libreplan.business.externalcompanies.entities.EndDateCommunicationComparator">
<key column="order_id" /> <key column="order_id" />
<one-to-many class="org.libreplan.business.externalcompanies.entities.EndDateCommunication" /> <one-to-many class="org.libreplan.business.externalcompanies.entities.EndDateCommunication" />
</set> </set>
</joined-subclass> </joined-subclass>
@ -179,7 +179,7 @@
</set> </set>
<property name="lastHoursGroupSequenceCode" <property name="lastHoursGroupSequenceCode"
column="last_hours_group_sequence_code" access="field" /> column="last_hours_group_sequence_code" access="field" />
<property name="budget" scale="2" access="field" /> <property name="budget" scale="2" access="field" />
</joined-subclass> </joined-subclass>
@ -214,13 +214,13 @@
<!-- Indexed --> <!-- Indexed -->
<many-to-one name="parentOrderLine" column="parent_order_line" <many-to-one name="parentOrderLine" column="parent_order_line"
class="org.libreplan.business.orders.entities.OrderLine" class="org.libreplan.business.orders.entities.OrderLine"
index="idx_hours_group_on_parent_order_line"/> index="idx_hours_group_on_parent_order_line"/>
<!-- Indexed --> <!-- Indexed -->
<many-to-one name="orderLineTemplate" column="order_line_template" <many-to-one name="orderLineTemplate" column="order_line_template"
class="org.libreplan.business.templates.entities.OrderLineTemplate" class="org.libreplan.business.templates.entities.OrderLineTemplate"
index="idx_hours_group_on_order_line_template"/> index="idx_hours_group_on_order_line_template"/>
</class> </class>
@ -236,7 +236,7 @@
<param name="enumClass">org.libreplan.business.orders.entities.SchedulingState$Type</param> <param name="enumClass">org.libreplan.business.orders.entities.SchedulingState$Type</param>
</type> </type>
</property> </property>
<many-to-one name="orderElement" column="order_element_id"></many-to-one> <many-to-one name="orderElement" column="order_element_id" lazy="false"></many-to-one>
<one-to-one name="taskSource" class="TaskSource" cascade="delete" access="field" property-ref="schedulingData" /> <one-to-one name="taskSource" class="TaskSource" cascade="delete" access="field" property-ref="schedulingData" />
</class> </class>
@ -248,9 +248,9 @@
</id> </id>
<version name="version" access="property" type="long" /> <version name="version" access="property" type="long" />
<many-to-one name="schedulingData" class="SchedulingDataForVersion" <many-to-one name="schedulingData" class="SchedulingDataForVersion"
cascade="none" unique="true" access="field" /> cascade="none" unique="true" access="field" lazy="false" />
<one-to-one name="task" class="org.libreplan.business.planner.entities.TaskElement" <one-to-one name="task" class="org.libreplan.business.planner.entities.TaskElement"
constrained="true" cascade="delete" access="field" lazy="false"/> constrained="true" cascade="delete" access="field" lazy="false"/>
<set name="hoursGroups" table="task_source_hours_groups" cascade="none" inverse="false" access="field" batch-size="10"> <set name="hoursGroups" table="task_source_hours_groups" cascade="none" inverse="false" access="field" batch-size="10">
<key column="task_source_id"></key> <key column="task_source_id"></key>
@ -267,21 +267,21 @@
<version name="version" access="property" type="long" /> <version name="version" access="property" type="long" />
<many-to-one name="orderElement" column="order_element" <many-to-one name="orderElement" column="order_element"
class="OrderElement" cascade="none" unique="true" /> class="OrderElement" cascade="none" unique="true" />
<property name="directChargedEffort" access="field" <property name="directChargedEffort" access="field"
column="direct_charged_effort" column="direct_charged_effort"
type="org.libreplan.business.workingday.hibernate.EffortDurationType" /> type="org.libreplan.business.workingday.hibernate.EffortDurationType" />
<property name="indirectChargedEffort" access="field" <property name="indirectChargedEffort" access="field"
column="indirect_charged_effort" column="indirect_charged_effort"
type="org.libreplan.business.workingday.hibernate.EffortDurationType" /> type="org.libreplan.business.workingday.hibernate.EffortDurationType" />
<property name="firstTimesheetDate" access="field" <property name="firstTimesheetDate" access="field"
column="first_timesheet_date" /> column="first_timesheet_date" />
<property name="lastTimesheetDate" access="field" <property name="lastTimesheetDate" access="field"
column="last_timesheet_date" /> column="last_timesheet_date" />
<property name="finishedTimesheets" <property name="finishedTimesheets"
column="finished_timesheets" /> column="finished_timesheets" />
</class> </class>
@ -294,7 +294,7 @@
<version name="version" access="property" type="long" /> <version name="version" access="property" type="long" />
<many-to-one name="orderElement" column="order_element_id" cascade="none" unique="true" <many-to-one name="orderElement" column="order_element_id" cascade="none" unique="true"
class="OrderElement" /> class="OrderElement" />
<property name="totalDirectExpenses" access="field" column="total_direct_expenses"/> <property name="totalDirectExpenses" access="field" column="total_direct_expenses"/>
<property name="totalIndirectExpenses" access="field" column="total_indirect_expenses"/> <property name="totalIndirectExpenses" access="field" column="total_indirect_expenses"/>
@ -316,4 +316,25 @@
</many-to-one> </many-to-one>
</class> </class>
<class name="OrderFile" abstract="true" table="files">
<id name="id" column="id" type="long" access="property">
<generator class="hilo">
<param name="max_lo">100</param>
</generator>
</id>
<property name="name" column="name" not-null="true" />
<property name="type" column="type" not-null="true" />
<property name="date" column="date"/>
<many-to-one name="uploader"
class="org.libreplan.business.users.entities.User" column="uploader" lazy="false"/>
<many-to-one name="parent"
class="org.libreplan.business.orders.entities.OrderElement" column="parent" lazy="false"/>
</class>
</hibernate-mapping> </hibernate-mapping>

View file

@ -294,6 +294,7 @@
</build> </build>
<dependencies> <dependencies>
<!-- Jasper Reports --> <!-- Jasper Reports -->
<dependency> <dependency>
<groupId>net.sf.jasperreports</groupId> <groupId>net.sf.jasperreports</groupId>
@ -303,16 +304,19 @@
<groupId>net.sf.jasperreports</groupId> <groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports-fonts</artifactId> <artifactId>jasperreports-fonts</artifactId>
</dependency> </dependency>
<!-- GPL Jasperreport Component for ZK --> <!-- GPL Jasperreport Component for ZK -->
<dependency> <dependency>
<groupId>com.igalia.java.zk.components</groupId> <groupId>com.igalia.java.zk.components</groupId>
<artifactId>jasperreportcomponent</artifactId> <artifactId>jasperreportcomponent</artifactId>
</dependency> </dependency>
<!-- GPL Jasperreport Component for ZK --> <!-- GPL Jasperreport Component for ZK -->
<dependency> <dependency>
<groupId>com.igalia.java.zk.components</groupId> <groupId>com.igalia.java.zk.components</groupId>
<artifactId>jfreechartengine</artifactId> <artifactId>jfreechartengine</artifactId>
</dependency> </dependency>
<!-- GPL detailrow Component for ZK --> <!-- GPL detailrow Component for ZK -->
<dependency> <dependency>
<groupId>com.igalia.java.zk.components</groupId> <groupId>com.igalia.java.zk.components</groupId>
@ -331,6 +335,7 @@
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
<artifactId>spring-security-acl</artifactId> <artifactId>spring-security-acl</artifactId>
</dependency> </dependency>
<!-- Spring Dependency LDAP --> <!-- Spring Dependency LDAP -->
<dependency> <dependency>
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
@ -365,11 +370,13 @@
<groupId>jfree</groupId> <groupId>jfree</groupId>
<artifactId>jcommon</artifactId> <artifactId>jcommon</artifactId>
</dependency> </dependency>
<!-- Apache Commons Fileupload (required by ZK) --> <!-- Apache Commons Fileupload (required by ZK) -->
<dependency> <dependency>
<groupId>commons-fileupload</groupId> <groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId> <artifactId>commons-fileupload</artifactId>
</dependency> </dependency>
<!-- ZK --> <!-- ZK -->
<dependency> <dependency>
<groupId>org.zkoss.zk</groupId> <groupId>org.zkoss.zk</groupId>
@ -383,11 +390,13 @@
<groupId>org.zkoss.zk</groupId> <groupId>org.zkoss.zk</groupId>
<artifactId>zk</artifactId> <artifactId>zk</artifactId>
</dependency> </dependency>
<!-- LibrePlan ZK Components --> <!-- LibrePlan ZK Components -->
<dependency> <dependency>
<groupId>org.libreplan</groupId> <groupId>org.libreplan</groupId>
<artifactId>ganttzk</artifactId> <artifactId>ganttzk</artifactId>
</dependency> </dependency>
<!-- LibrePlan Business --> <!-- LibrePlan Business -->
<dependency> <dependency>
<groupId>org.libreplan</groupId> <groupId>org.libreplan</groupId>
@ -434,7 +443,7 @@
<artifactId>servlet-api</artifactId> <artifactId>servlet-api</artifactId>
</dependency> </dependency>
<!--Java mail--> <!-- Java mail -->
<dependency> <dependency>
<groupId>javax.mail</groupId> <groupId>javax.mail</groupId>
<artifactId>mail</artifactId> <artifactId>mail</artifactId>
@ -446,6 +455,7 @@
<groupId>javax.ws.rs</groupId> <groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId> <artifactId>jsr311-api</artifactId>
</dependency> </dependency>
<!-- CXF --> <!-- CXF -->
<dependency> <dependency>
<groupId>org.apache.cxf</groupId> <groupId>org.apache.cxf</groupId>
@ -463,6 +473,7 @@
<groupId>org.codehaus.jackson</groupId> <groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-xc</artifactId> <artifactId>jackson-xc</artifactId>
</dependency> </dependency>
<!-- ZK Timeplot --> <!-- ZK Timeplot -->
<dependency> <dependency>
<groupId>org.zkoss.zkforge</groupId> <groupId>org.zkoss.zkforge</groupId>
@ -472,26 +483,31 @@
<groupId>org.zkoss.zkforge</groupId> <groupId>org.zkoss.zkforge</groupId>
<artifactId>timeplotz</artifactId> <artifactId>timeplotz</artifactId>
</dependency> </dependency>
<!-- JGraphT --> <!-- JGraphT -->
<dependency> <dependency>
<groupId>org.jgrapht</groupId> <groupId>org.jgrapht</groupId>
<artifactId>jgrapht-jdk1.5</artifactId> <artifactId>jgrapht-jdk1.5</artifactId>
</dependency> </dependency>
<!-- jqPlot --> <!-- jqPlot -->
<dependency> <dependency>
<groupId>br.com.digilabs.jqplot</groupId> <groupId>br.com.digilabs.jqplot</groupId>
<artifactId>jqplot4java</artifactId> <artifactId>jqplot4java</artifactId>
</dependency> </dependency>
<!-- MPXJ Library --> <!-- MPXJ Library -->
<dependency> <dependency>
<groupId>net.sourceforge</groupId> <groupId>net.sourceforge</groupId>
<artifactId>mpxj</artifactId> <artifactId>mpxj</artifactId>
</dependency> </dependency>
<!-- ZK fileupload --> <!-- ZK fileupload -->
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
</dependency> </dependency>
<!-- Quartz framework --> <!-- Quartz framework -->
<dependency> <dependency>
<groupId>org.quartz-scheduler</groupId> <groupId>org.quartz-scheduler</groupId>

View file

@ -1172,6 +1172,14 @@ public class ConfigurationController extends GenericForwardComposer {
configurationModel.setSecondsPlanningWarning(secondsPlanningWarning); configurationModel.setSecondsPlanningWarning(secondsPlanningWarning);
} }
public String getRepositoryLocation(){
return configurationModel.getRepositoryLocation();
}
public void setRepositoryLocation(String location){
configurationModel.setRepositoryLocation(location);
}
public List<Connector> getConnectors() { public List<Connector> getConnectors() {
return configurationModel.getConnectors(); return configurationModel.getConnectors();
} }

View file

@ -63,6 +63,7 @@ import org.springframework.transaction.annotation.Transactional;
/** /**
* @author Manuel Rego Casasnovas <mrego@igalia.com> * @author Manuel Rego Casasnovas <mrego@igalia.com>
* @author Cristina Alvarino Perez <cristina.alvarino@comtecsf.es> * @author Cristina Alvarino Perez <cristina.alvarino@comtecsf.es>
* @author Vova Perebykivskiy <vova@libreplan-enterprise.com>
*/ */
@Service @Service
@Scope(BeanDefinition.SCOPE_PROTOTYPE) @Scope(BeanDefinition.SCOPE_PROTOTYPE)
@ -538,8 +539,7 @@ public class ConfigurationModel implements IConfigurationModel {
return entitySequences.get(entityName); return entitySequences.get(entityName);
} }
public void addEntitySequence(EntityNameEnum entityName, String prefix, public void addEntitySequence(EntityNameEnum entityName, String prefix, Integer digits) {
Integer digits) {
List<EntitySequence> sequences = entitySequences.get(entityName); List<EntitySequence> sequences = entitySequences.get(entityName);
EntitySequence entitySequence = EntitySequence.create(prefix, EntitySequence entitySequence = EntitySequence.create(prefix,
entityName, digits); entityName, digits);
@ -692,6 +692,16 @@ public class ConfigurationModel implements IConfigurationModel {
configuration.setSecondsPlanningWarning(secondsPlanningWarning); configuration.setSecondsPlanningWarning(secondsPlanningWarning);
} }
@Override
public String getRepositoryLocation() {
return configuration.getRepositoryLocation();
}
@Override
public void setRepositoryLocation(String location) {
configuration.setRepositoryLocation(location);
}
private void saveConnectors() { private void saveConnectors() {
for (Connector connector : connectors) { for (Connector connector : connectors) {
connectorDAO.save(connector); connectorDAO.save(connector);

View file

@ -37,6 +37,7 @@ import org.libreplan.business.costcategories.entities.TypeOfWorkHours;
* Contract for {@link ConfigurationModel}. * Contract for {@link ConfigurationModel}.
* *
* @author Manuel Rego Casasnovas <mrego@igalia.com> * @author Manuel Rego Casasnovas <mrego@igalia.com>
* @author Vova Perebykivskiy <vova@libreplan-enterprise.com>
*/ */
public interface IConfigurationModel { public interface IConfigurationModel {
@ -102,8 +103,7 @@ public interface IConfigurationModel {
List<EntitySequence> getEntitySequences(EntityNameEnum entityName); List<EntitySequence> getEntitySequences(EntityNameEnum entityName);
void addEntitySequence(EntityNameEnum entityName, String prefix, void addEntitySequence(EntityNameEnum entityName, String prefix, Integer digits);
Integer digits);
void removeEntitySequence(EntitySequence entitySequence) void removeEntitySequence(EntitySequence entitySequence)
throws IllegalArgumentException; throws IllegalArgumentException;
@ -186,6 +186,10 @@ public interface IConfigurationModel {
void setSecondsPlanningWarning( void setSecondsPlanningWarning(
Integer planningWarningExitWithoutSavingSeconds); Integer planningWarningExitWithoutSavingSeconds);
String getRepositoryLocation();
void setRepositoryLocation(String location);
List<Connector> getConnectors(); List<Connector> getConnectors();
Connector getConnectorByName(String name); Connector getConnectorByName(String name);

View file

@ -52,17 +52,7 @@ public class EmailNotificationModel implements IEmailNotificationModel {
@Autowired @Autowired
private IEmailNotificationDAO emailNotificationDAO; private IEmailNotificationDAO emailNotificationDAO;
private EmailTemplateEnum type; private EmailNotification emailNotification;
private Date updated;
private Resource resource;
private TaskElement task;
private TaskElement project;
private EmailNotification emailNotification = new EmailNotification();
@Override @Override
@Transactional @Transactional
@ -76,12 +66,29 @@ public class EmailNotificationModel implements IEmailNotificationModel {
return emailNotificationDAO.getAll(); return emailNotificationDAO.getAll();
} }
@Override
@Transactional
public List<EmailNotification> getAllByType(EmailTemplateEnum enumeration) {
return emailNotificationDAO.getAllByType(enumeration);
}
@Override @Override
@Transactional @Transactional
public boolean deleteAll() { public boolean deleteAll() {
return emailNotificationDAO.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 @Override
public void setType(EmailTemplateEnum type) { public void setType(EmailTemplateEnum type) {
this.emailNotification.setType(type); this.emailNotification.setType(type);
@ -107,4 +114,13 @@ public class EmailNotificationModel implements IEmailNotificationModel {
this.emailNotification.setProject(project); this.emailNotification.setProject(project);
} }
public EmailNotification getEmailNotification() {
return emailNotification;
}
public void setNewObject(){
this.emailNotification = new EmailNotification();
}
} }

View file

@ -75,8 +75,7 @@ public class EmailTemplateController extends GenericForwardComposer{
public static ListitemRenderer languagesRenderer = new ListitemRenderer() { public static ListitemRenderer languagesRenderer = new ListitemRenderer() {
@Override @Override
public void render(org.zkoss.zul.Listitem item, Object data) public void render(Listitem item, Object data) throws Exception {
throws Exception {
Language language = (Language) data; Language language = (Language) data;
String displayName = language.getDisplayName(); String displayName = language.getDisplayName();
item.setLabel(displayName); item.setLabel(displayName);
@ -90,7 +89,7 @@ public class EmailTemplateController extends GenericForwardComposer{
messages = new MessagesForUser(messagesContainer); messages = new MessagesForUser(messagesContainer);
// Set default template and language for user // Set default template and language for user
// And content and subject for it // And content and subject for that language & template
setUser(); setUser();
setSelectedLanguage(user.getApplicationLanguage()); setSelectedLanguage(user.getApplicationLanguage());
@ -108,7 +107,9 @@ public class EmailTemplateController extends GenericForwardComposer{
return true; return true;
} catch (ValidationException e) { } catch (ValidationException e) {
messages.showInvalidValues(e); messages.showInvalidValues(e);
} catch (InstanceNotFoundException e) {} } catch (InstanceNotFoundException e) {
e.printStackTrace();
}
return false; return false;
} }
@ -193,7 +194,7 @@ public class EmailTemplateController extends GenericForwardComposer{
subjectTextbox.setValue(emailTemplateModel.getSubjectBySelectedLanguage(getSelectedLanguage().ordinal(), getSelectedEmailTemplateEnum().ordinal())); subjectTextbox.setValue(emailTemplateModel.getSubjectBySelectedLanguage(getSelectedLanguage().ordinal(), getSelectedEmailTemplateEnum().ordinal()));
} }
private void getSubjectDataBySelectedTemplate(){ private void getSubjectDataBySelectedTemplate(){
subjectTextbox.setValue( emailTemplateModel.getContentBySelectedTemplate(getSelectedEmailTemplateEnum().ordinal(), getSelectedLanguage().ordinal()) ); subjectTextbox.setValue( emailTemplateModel.getSubjectBySelectedTemplate(getSelectedEmailTemplateEnum().ordinal(), getSelectedLanguage().ordinal()) );
} }
@Transactional @Transactional

View file

@ -24,10 +24,7 @@ import org.libreplan.business.settings.entities.Language;
import org.libreplan.business.email.daos.IEmailTemplateDAO; import org.libreplan.business.email.daos.IEmailTemplateDAO;
import org.libreplan.business.email.entities.EmailTemplate; import org.libreplan.business.email.entities.EmailTemplate;
import org.libreplan.business.email.entities.EmailTemplateEnum; 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.common.concurrentdetection.OnConcurrentModification;
import org.libreplan.web.security.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
@ -51,26 +48,13 @@ public class EmailTemplateModel implements IEmailTemplateModel {
@Autowired @Autowired
private IEmailTemplateDAO emailTemplateDAO; 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(); private EmailTemplate emailTemplate = new EmailTemplate();
@Override @Override
@Transactional @Transactional
public void confirmSave() throws InstanceNotFoundException { 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. * Else current EmailTemplate entity (id) is creating and getting new values from form.
*/ */
List<EmailTemplate> emailTemplates = emailTemplateDAO.getAll(); List<EmailTemplate> emailTemplates = emailTemplateDAO.getAll();

View file

@ -40,8 +40,11 @@ public interface IEmailNotificationModel {
void confirmSave() throws ValidationException; void confirmSave() throws ValidationException;
List<EmailNotification> getAll(); List<EmailNotification> getAll();
List<EmailNotification> getAllByType(EmailTemplateEnum enumeration);
boolean deleteAll(); boolean deleteAll();
boolean deleteAllByType(EmailTemplateEnum enumeration);
boolean deleteById(EmailNotification notification);
void setType(EmailTemplateEnum type); void setType(EmailTemplateEnum type);
void setUpdated(Date date); void setUpdated(Date date);
@ -49,4 +52,7 @@ public interface IEmailNotificationModel {
void setTask(TaskElement task); void setTask(TaskElement task);
void setProject(TaskElement project); void setProject(TaskElement project);
EmailNotification getEmailNotification();
void setNewObject();
} }

View file

@ -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.OrderFilterEnum;
import org.libreplan.web.common.components.finders.TaskGroupFilterEnum; import org.libreplan.web.common.components.finders.TaskGroupFilterEnum;
import org.libreplan.web.orders.criterionrequirements.AssignedCriterionRequirementToOrderElementController; 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.AssignedLabelsToOrderElementController;
import org.libreplan.web.orders.labels.LabelsAssignmentToOrderElementComponent; import org.libreplan.web.orders.labels.LabelsAssignmentToOrderElementComponent;
import org.libreplan.web.orders.materials.AssignedMaterialsToOrderElementController; import org.libreplan.web.orders.materials.AssignedMaterialsToOrderElementController;
@ -278,17 +279,17 @@ public class OrderCRUDController extends GenericForwardComposer {
List<FilterPair> sessionFilters = FilterUtils List<FilterPair> sessionFilters = FilterUtils
.readProjectsParameters(); .readProjectsParameters();
// Allow labels when list is empty // Allow labels when list is empty
if (sessionFilters != null) { if ( sessionFilters != null ) {
bdFilters.addSelectedElements(toOrderFilterEnum(sessionFilters)); bdFilters.addSelectedElements(toOrderFilterEnum(sessionFilters));
return; return;
} }
User user = orderModel.getUser(); User user = orderModel.getUser();
// Calculate filter based on user preferences // Calculate filter based on user preferences
if ((user != null) && (user.getProjectsFilterLabel() != null)) { if ( (user != null) && (user.getProjectsFilterLabel() != null) ) {
bdFilters.addSelectedElement(new FilterPair(OrderFilterEnum.Label, bdFilters.addSelectedElement(new FilterPair(OrderFilterEnum.Label,
user.getProjectsFilterLabel().getFinderPattern(), user user.getProjectsFilterLabel().getFinderPattern(),
.getProjectsFilterLabel())); user.getProjectsFilterLabel()));
} }
} }
@ -298,23 +299,23 @@ public class OrderCRUDController extends GenericForwardComposer {
TaskGroupFilterEnum type = (TaskGroupFilterEnum) filterPair TaskGroupFilterEnum type = (TaskGroupFilterEnum) filterPair
.getType(); .getType();
switch (type) { switch (type) {
case Label: case Label:
result.add(new FilterPair(OrderFilterEnum.Label, filterPair result.add(new FilterPair(OrderFilterEnum.Label, filterPair
.getPattern(), filterPair.getValue())); .getPattern(), filterPair.getValue()));
break; break;
case Criterion: case Criterion:
result.add(new FilterPair(OrderFilterEnum.Criterion, filterPair result.add(new FilterPair(OrderFilterEnum.Criterion, filterPair
.getPattern(), filterPair.getValue())); .getPattern(), filterPair.getValue()));
break; break;
case ExternalCompany: case ExternalCompany:
result.add(new FilterPair(OrderFilterEnum.ExternalCompany, result.add(new FilterPair(OrderFilterEnum.ExternalCompany,
filterPair.getPattern(), filterPair.getValue())); filterPair.getPattern(), filterPair.getValue()));
break; break;
case State: case State:
result.add(new FilterPair(OrderFilterEnum.State, filterPair result.add(new FilterPair(OrderFilterEnum.State, filterPair
.getPattern(), filterPair.getValue())); .getPattern(), filterPair.getValue()));
break; break;
default: default:
} }
} }
return result; return result;
@ -452,8 +453,7 @@ public class OrderCRUDController extends GenericForwardComposer {
}); });
} }
private Comboitem createCombo(Object value, String label, private Comboitem createCombo(Object value, String label, String description) {
String description) {
Comboitem result = new Comboitem(); Comboitem result = new Comboitem();
result.setValue(value); result.setValue(value);
result.setLabel(label); result.setLabel(label);
@ -646,7 +646,7 @@ public class OrderCRUDController extends GenericForwardComposer {
if (assignedLabelsController == null) { if (assignedLabelsController == null) {
LabelsAssignmentToOrderElementComponent labelsAssignment = (LabelsAssignmentToOrderElementComponent) editWindow LabelsAssignmentToOrderElementComponent labelsAssignment = (LabelsAssignmentToOrderElementComponent) editWindow
.getFellow("orderElementLabels"); .getFellow("orderElementLabels");
assignedLabelsController = labelsAssignment.getController(); assignedLabelsController = labelsAssignment.getController();
final IOrderElementModel orderElementModel = getOrderElementModel(); final IOrderElementModel orderElementModel = getOrderElementModel();
@ -664,9 +664,9 @@ public class OrderCRUDController extends GenericForwardComposer {
if (assignedCriterionRequirementController == null) { if (assignedCriterionRequirementController == null) {
Component orderElementCriterionRequirements = editWindow Component orderElementCriterionRequirements = editWindow
.getFellowIfAny("orderElementCriterionRequirements"); .getFellowIfAny("orderElementCriterionRequirements");
assignedCriterionRequirementController = (AssignedCriterionRequirementToOrderElementController) orderElementCriterionRequirements assignedCriterionRequirementController = (AssignedCriterionRequirementToOrderElementController) orderElementCriterionRequirements
.getVariable("assignedCriterionRequirementController", true); .getVariable("assignedCriterionRequirementController", true);
final IOrderElementModel orderElementModel = getOrderElementModel(); final IOrderElementModel orderElementModel = getOrderElementModel();
assignedCriterionRequirementController assignedCriterionRequirementController
@ -686,7 +686,7 @@ public class OrderCRUDController extends GenericForwardComposer {
if (assignedMaterialsController == null) { if (assignedMaterialsController == null) {
OrderElementMaterialAssignmentsComponent assignmentsComponent = (OrderElementMaterialAssignmentsComponent) editWindow OrderElementMaterialAssignmentsComponent assignmentsComponent = (OrderElementMaterialAssignmentsComponent) editWindow
.getFellowIfAny("orderElementMaterials"); .getFellowIfAny("orderElementMaterials");
assignedMaterialsController = assignmentsComponent.getController(); assignedMaterialsController = assignmentsComponent.getController();
final IOrderElementModel orderElementModel = getOrderElementModel(); final IOrderElementModel orderElementModel = getOrderElementModel();
@ -707,7 +707,7 @@ public class OrderCRUDController extends GenericForwardComposer {
.getFellowIfAny("orderElementTaskQualityForms"); .getFellowIfAny("orderElementTaskQualityForms");
if (assignedTaskQualityFormController == null) { if (assignedTaskQualityFormController == null) {
assignedTaskQualityFormController = (AssignedTaskQualityFormsToOrderElementController) orderElementTaskQualityForms assignedTaskQualityFormController = (AssignedTaskQualityFormsToOrderElementController) orderElementTaskQualityForms
.getVariable("assignedTaskQualityFormsController", true); .getVariable("assignedTaskQualityFormsController", true);
final IOrderElementModel orderElementModel = getOrderElementModel(); final IOrderElementModel orderElementModel = getOrderElementModel();
assignedTaskQualityFormController.openWindow(orderElementModel); assignedTaskQualityFormController.openWindow(orderElementModel);
} else { } 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; private OrderAuthorizationController orderAuthorizationController;
public void setupOrderAuthorizationController() { public void setupOrderAuthorizationController() {
@ -771,29 +794,29 @@ public class OrderCRUDController extends GenericForwardComposer {
.getSelectedElements()) { .getSelectedElements()) {
OrderFilterEnum type = (OrderFilterEnum) filterPair.getType(); OrderFilterEnum type = (OrderFilterEnum) filterPair.getType();
switch (type) { switch (type) {
case Label: case Label:
labels.add((org.libreplan.business.labels.entities.Label) filterPair labels.add((org.libreplan.business.labels.entities.Label) filterPair
.getValue()); .getValue());
break; break;
case Criterion: case Criterion:
criteria.add((Criterion) filterPair.getValue()); criteria.add((Criterion) filterPair.getValue());
break; break;
case ExternalCompany: case ExternalCompany:
if (customer != null) { if (customer != null) {
// It's impossible to have an Order associated to more than // It's impossible to have an Order associated to more than
// 1 customer // 1 customer
return Collections.emptyList(); return Collections.emptyList();
} }
customer = (ExternalCompany) filterPair.getValue(); customer = (ExternalCompany) filterPair.getValue();
break; break;
case State: case State:
if (state != null) { if (state != null) {
// It's impossible to have an Order associated with more // It's impossible to have an Order associated with more
// than 1 state // than 1 state
return Collections.emptyList(); return Collections.emptyList();
} }
state = (OrderStatusEnum) filterPair.getValue(); state = (OrderStatusEnum) filterPair.getValue();
break; break;
} }
} }
@ -862,7 +885,7 @@ public class OrderCRUDController extends GenericForwardComposer {
private void refreshCodeTextboxesOnly() { private void refreshCodeTextboxesOnly() {
if (orderElementTreeController != null) { if (orderElementTreeController != null) {
Map<OrderElement, Textbox> orderElementCodeTextBoxes = Map<OrderElement, Textbox> orderElementCodeTextBoxes =
orderElementTreeController.getOrderElementCodeTextboxes(); orderElementTreeController.getOrderElementCodeTextboxes();
for (OrderElement element : orderElementCodeTextBoxes.keySet()) { for (OrderElement element : orderElementCodeTextBoxes.keySet()) {
if (element.getId() != null) { if (element.getId() != null) {
@ -1423,10 +1446,9 @@ public class OrderCRUDController extends GenericForwardComposer {
public void validate(Component comp, Object value) public void validate(Component comp, Object value)
throws WrongValueException { throws WrongValueException {
Date finishDate = (Date) value; Date finishDate = (Date) value;
if ((finishDate != null) if ( (finishDate != null)
&& (filterStartDate.getRawValue() != null) && (filterStartDate.getRawValue() != null)
&& (finishDate.compareTo((Date) filterStartDate && (finishDate.compareTo((Date) filterStartDate.getRawValue()) < 0) ) {
.getRawValue()) < 0)) {
throw new WrongValueException(comp, throw new WrongValueException(comp,
_("must be after start date")); _("must be after start date"));
} }
@ -1440,11 +1462,9 @@ public class OrderCRUDController extends GenericForwardComposer {
public void validate(Component comp, Object value) public void validate(Component comp, Object value)
throws WrongValueException { throws WrongValueException {
Date startDate = (Date) value; Date startDate = (Date) value;
if ((startDate != null) if ( (startDate != null)
&& (filterFinishDate.getRawValue() != null) && (filterFinishDate.getRawValue() != null)
&& (startDate.compareTo((Date) filterFinishDate && (startDate.compareTo((Date) filterFinishDate.getRawValue()) > 0) ) {
.getRawValue()) > 0)) {
// filterStartDate.setValue(null);
throw new WrongValueException(comp, throw new WrongValueException(comp,
_("must be lower than end date")); _("must be lower than end date"));
} }
@ -1480,26 +1500,26 @@ public class OrderCRUDController extends GenericForwardComposer {
OrderFilterEnum type = (OrderFilterEnum) filterPair OrderFilterEnum type = (OrderFilterEnum) filterPair
.getType(); .getType();
switch (type) { switch (type) {
case Label: case Label:
result.add(new FilterPair(TaskGroupFilterEnum.Label, filterPair result.add(new FilterPair(TaskGroupFilterEnum.Label, filterPair
.getPattern(), filterPair.getValue())); .getPattern(), filterPair.getValue()));
break; break;
case Criterion: case Criterion:
result.add(new FilterPair(TaskGroupFilterEnum.Criterion, result.add(new FilterPair(TaskGroupFilterEnum.Criterion,
filterPair.getPattern(), filterPair.getValue())); filterPair.getPattern(), filterPair.getValue()));
break; break;
case ExternalCompany: case ExternalCompany:
result.add(new FilterPair(TaskGroupFilterEnum.ExternalCompany, result.add(new FilterPair(TaskGroupFilterEnum.ExternalCompany,
filterPair.getPattern(), filterPair.getValue())); filterPair.getPattern(), filterPair.getValue()));
break; break;
case State: case State:
result.add(new FilterPair(TaskGroupFilterEnum.State, filterPair result.add(new FilterPair(TaskGroupFilterEnum.State, filterPair
.getPattern(), filterPair.getValue())); .getPattern(), filterPair.getValue()));
break; break;
default: default:
result.add(new FilterPair(OrderFilterEnum.Label, filterPair result.add(new FilterPair(OrderFilterEnum.Label, filterPair
.getPattern(), filterPair.getValue())); .getPattern(), filterPair.getValue()));
break; break;
} }
} }
return result; return result;
@ -1582,7 +1602,7 @@ public class OrderCRUDController extends GenericForwardComposer {
if (!(orderElement instanceof Order) if (!(orderElement instanceof Order)
&& orderElementTreeController != null) { && orderElementTreeController != null) {
final Treeitem item = orderElementTreeController final Treeitem item = orderElementTreeController
.getTreeitemByOrderElement(orderElement); .getTreeitemByOrderElement(orderElement);
if (item != null) { if (item != null) {
orderElementTreeController orderElementTreeController
@ -1641,7 +1661,7 @@ public class OrderCRUDController extends GenericForwardComposer {
public SortedSet<DeadlineCommunication> getDeliverDates() { public SortedSet<DeadlineCommunication> getDeliverDates() {
if(getOrder() != null){ if(getOrder() != null){
return getOrder().getDeliveringDates(); return getOrder().getDeliveringDates();
} }
return new TreeSet<DeadlineCommunication>(new DeliverDateComparator()); return new TreeSet<DeadlineCommunication>(new DeliverDateComparator());
} }
@ -1870,12 +1890,10 @@ public class OrderCRUDController extends GenericForwardComposer {
public BigDecimal getResourcesBudget() { public BigDecimal getResourcesBudget() {
return Registry.getTransactionService().runOnReadOnlyTransaction( return Registry.getTransactionService().runOnReadOnlyTransaction(
new IOnTransaction<BigDecimal>() { new IOnTransaction<BigDecimal>() {
@Override
@Override public BigDecimal execute() {
public BigDecimal execute() { return getOrderElementModel().getOrderElement().getResourcesBudget();
return getOrderElementModel().getOrderElement()
.getResourcesBudget();
} }
}); });
} }

View file

@ -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 <vova@libreplan-enterprise.com>
* 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<OrderFile> getAll();
void delete(OrderFile file);
List<OrderFile> findByParent(OrderElement parent);
OrderFile getOrderFile();
}

View file

@ -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 <vova@libreplan-enterprise.com>
* 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<OrderFile> getAll() {
return fileDAO.getAll();
}
@Override
@Transactional
public void delete(OrderFile file){
fileDAO.delete(file);
}
@Override
@Transactional
public List<OrderFile> findByParent(OrderElement parent) {
return fileDAO.findByParent(parent);
}
public OrderFile getOrderFile() {
return orderFile;
}
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
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 <vova@libreplan-enterprise.com>
* 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;
}
}

View file

@ -626,7 +626,7 @@ public class MachineCRUDController extends BaseCRUDController<Machine> {
public boolean isCreateButtonDisabled(){ public boolean isCreateButtonDisabled(){
Limits resourcesTypeLimit = limitsModel.getResourcesType(); Limits resourcesTypeLimit = limitsModel.getResourcesType();
Integer resourcesCount = (Integer) resourceDAO.getRowCount(); Integer resourcesCount = resourceDAO.getRowCount().intValue();
if ( resourcesTypeLimit != null ) if ( resourcesTypeLimit != null )
if ( resourcesCount >= resourcesTypeLimit.getValue() ) if ( resourcesCount >= resourcesTypeLimit.getValue() )
@ -637,7 +637,7 @@ public class MachineCRUDController extends BaseCRUDController<Machine> {
public String getShowCreateFormLabel(){ public String getShowCreateFormLabel(){
Limits resourcesTypeLimit = limitsModel.getResourcesType(); Limits resourcesTypeLimit = limitsModel.getResourcesType();
Integer resourcesCount = (Integer) resourceDAO.getRowCount(); Integer resourcesCount = resourceDAO.getRowCount().intValue();
int resourcesLeft = resourcesTypeLimit.getValue() - resourcesCount; int resourcesLeft = resourcesTypeLimit.getValue() - resourcesCount;
if ( resourcesTypeLimit != null ) if ( resourcesTypeLimit != null )

View file

@ -1172,7 +1172,7 @@ public class WorkerCRUDController extends GenericForwardComposer implements
public boolean isCreateButtonDisabled(){ public boolean isCreateButtonDisabled(){
Limits resourcesTypeLimit = limitsModel.getResourcesType(); Limits resourcesTypeLimit = limitsModel.getResourcesType();
Integer resourcesCount = (Integer) resourceDAO.getRowCount(); Integer resourcesCount = resourceDAO.getRowCount().intValue();
if ( resourcesTypeLimit != null ) if ( resourcesTypeLimit != null )
if ( resourcesCount >= resourcesTypeLimit.getValue() ) if ( resourcesCount >= resourcesTypeLimit.getValue() )
@ -1183,7 +1183,7 @@ public class WorkerCRUDController extends GenericForwardComposer implements
public String getShowCreateFormLabel(){ public String getShowCreateFormLabel(){
Limits resourcesTypeLimit = limitsModel.getResourcesType(); Limits resourcesTypeLimit = limitsModel.getResourcesType();
Integer resourcesCount = (Integer) resourceDAO.getRowCount(); Integer resourcesCount = resourceDAO.getRowCount().intValue();
int resourcesLeft = resourcesTypeLimit.getValue() - resourcesCount; int resourcesLeft = resourcesTypeLimit.getValue() - resourcesCount;
if ( resourcesTypeLimit != null ) if ( resourcesTypeLimit != null )

View file

@ -505,7 +505,7 @@ public class UserCRUDController extends BaseCRUDController<User> implements
public boolean isCreateButtonDisabled(){ public boolean isCreateButtonDisabled(){
Limits usersTypeLimit = limitsModel.getUsersType(); Limits usersTypeLimit = limitsModel.getUsersType();
Integer usersCount = (Integer) userModel.getRowCount(); Integer usersCount = userModel.getRowCount().intValue();
if (usersTypeLimit != null) if (usersTypeLimit != null)
if ( usersCount >= usersTypeLimit.getValue() ) if ( usersCount >= usersTypeLimit.getValue() )
return true; return true;
@ -514,7 +514,7 @@ public class UserCRUDController extends BaseCRUDController<User> implements
public String getShowCreateFormLabel(){ public String getShowCreateFormLabel(){
Limits usersTypeLimit = limitsModel.getUsersType(); Limits usersTypeLimit = limitsModel.getUsersType();
Integer usersCount = (Integer) userModel.getRowCount(); Integer usersCount = userModel.getRowCount().intValue();
int usersLeft = usersTypeLimit.getValue() - usersCount; int usersLeft = usersTypeLimit.getValue() - usersCount;
if (usersTypeLimit != null) if (usersTypeLimit != null)
if ( usersCount >= usersTypeLimit.getValue() ) if ( usersCount >= usersTypeLimit.getValue() )

View file

@ -145,6 +145,7 @@ msgstr ""
#: libreplan-webapp/src/main/webapp/qualityforms/_listQualityForm.zul:38 #: libreplan-webapp/src/main/webapp/qualityforms/_listQualityForm.zul:38
#: libreplan-webapp/src/main/webapp/qualityforms/_editQualityForm.zul:87 #: libreplan-webapp/src/main/webapp/qualityforms/_editQualityForm.zul:87
#: libreplan-webapp/src/main/webapp/limitingresources/limitingResourcesLayout.zul:143 #: libreplan-webapp/src/main/webapp/limitingresources/limitingResourcesLayout.zul:143
#: libreplan-webapp/src/main/webapp/orders/_listOrderElementFiles.zul:40
msgid "Operations" msgid "Operations"
msgstr "" msgstr ""
@ -3547,6 +3548,7 @@ msgid "Unschedule"
msgstr "" msgstr ""
#: libreplan-webapp/src/main/webapp/users/_editUser.zul:36 #: libreplan-webapp/src/main/webapp/users/_editUser.zul:36
#: libreplan-webapp/src/main/webapp/email/email_template.zul:42
msgid "General user data" msgid "General user data"
msgstr "" msgstr ""
@ -4648,6 +4650,7 @@ msgstr ""
#: libreplan-webapp/src/main/webapp/qualityforms/_editQualityForm.zul:42 #: libreplan-webapp/src/main/webapp/qualityforms/_editQualityForm.zul:42
#: libreplan-webapp/src/main/webapp/qualityforms/_editQualityForm.zul:83 #: libreplan-webapp/src/main/webapp/qualityforms/_editQualityForm.zul:83
#: libreplan-webapp/src/main/webapp/limitingresources/limitingResourcesLayout.zul:96 #: libreplan-webapp/src/main/webapp/limitingresources/limitingResourcesLayout.zul:96
#: libreplan-webapp/src/main/webapp/orders/_listOrderElementFiles.zul:36
msgid "Name" msgid "Name"
msgstr "" msgstr ""
@ -8129,6 +8132,7 @@ msgstr ""
#: libreplan-webapp/src/main/webapp/orders/_listOrderElementCriterionRequirements.zul:47 #: libreplan-webapp/src/main/webapp/orders/_listOrderElementCriterionRequirements.zul:47
#: libreplan-webapp/src/main/webapp/orders/_listOrderElementCriterionRequirements.zul:153 #: libreplan-webapp/src/main/webapp/orders/_listOrderElementCriterionRequirements.zul:153
#: libreplan-webapp/src/main/webapp/advance/_editAdvanceTypes.zul:62 #: libreplan-webapp/src/main/webapp/advance/_editAdvanceTypes.zul:62
#: libreplan-webapp/src/main/webapp/orders/_listOrderElementFiles.zul:37
msgid "Type" msgid "Type"
msgstr "" msgstr ""
@ -8760,6 +8764,7 @@ msgstr ""
#: libreplan-webapp/src/main/webapp/orders/_listOrderElementCriterionRequirements.zul:212 #: libreplan-webapp/src/main/webapp/orders/_listOrderElementCriterionRequirements.zul:212
#: libreplan-webapp/src/main/webapp/qualityforms/_listQualityForm.zul:52 #: libreplan-webapp/src/main/webapp/qualityforms/_listQualityForm.zul:52
#: libreplan-webapp/src/main/webapp/qualityforms/_editQualityForm.zul:116 #: libreplan-webapp/src/main/webapp/qualityforms/_editQualityForm.zul:116
#: libreplan-webapp/src/main/java/org/libreplan/web/orders/files/OrderFilesController.java:148
msgid "Delete" msgid "Delete"
msgstr "" msgstr ""
@ -9226,6 +9231,7 @@ msgid "Task assigned to resource"
msgstr "" msgstr ""
#: libreplan-webapp/src/main/java/org/libreplan/web/common/CustomMenuController.java:425 #: 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" msgid "Edit E-mail Templates"
msgstr "" msgstr ""
@ -9314,3 +9320,43 @@ msgstr ""
#: libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationController.java:247 #: libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationController.java:247
msgid "Check fields" msgid "Check fields"
msgstr "" 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 ""

View file

@ -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.')}" /> 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.')}" />
</hbox> </hbox>
</row> </row>
<row>
<label value="${i18n:_('Local document repository location')}"/>
<textbox id="repoLocation" width="300px"
tooltiptext="Example: /example/repository/path/"
value="@{configurationController.repositoryLocation}"
constraint="/(\/.*\/$|^$)/:Example: example/repository/path/"
/>
</row>
</rows> </rows>
</grid> </grid>
</tabpanel> </tabpanel>

View file

@ -1,5 +1,6 @@
<window apply="org.libreplan.web.dashboard.DashboardControllerGlobal" contentStyle="overflow:auto;"> <window apply="org.libreplan.web.dashboard.DashboardControllerGlobal" contentStyle="overflow:auto;">
<checkbox id="storedColumnVisible" label="${i18n:_('Show archived column data')}" checked="true" onCheck="dashboardControllerGlobal.showStoredColumn()"/> <checkbox id="storedColumnVisible" label="${i18n:_('Show archived column data')}"
checked="true" onCheck="dashboardControllerGlobal.showStoredColumn()"/>
<grid id="pipelineGrid" sclass="global-dashboard-grid"> <grid id="pipelineGrid" sclass="global-dashboard-grid">
<columns> <columns>

View file

@ -39,7 +39,7 @@
<tabpanels> <tabpanels>
<tabpanel> <tabpanel>
<groupbox> <groupbox>
<caption label="General user data" /> <caption label="${i18n:_('General user data')}" />
<grid> <grid>
<columns> <columns>
<column width="220px"></column> <column width="220px"></column>
@ -47,7 +47,7 @@
</columns> </columns>
<rows> <rows>
<row> <row>
<label value="Select template language"/> <label value="${i18n:_('Select template language')}"/>
<listbox mold="select" <listbox mold="select"
id="templateLanguageListbox" id="templateLanguageListbox"
model="@{emailTemplateController.languages}" model="@{emailTemplateController.languages}"
@ -56,7 +56,7 @@
</listbox> </listbox>
</row> </row>
<row> <row>
<label value="Select template type"/> <label value="${i18n:_('Select template type')}"/>
<listbox id="emailTemplateTypeListbox" <listbox id="emailTemplateTypeListbox"
mold="select" mold="select"
model="@{emailTemplateController.emailTemplateEnum}" model="@{emailTemplateController.emailTemplateEnum}"

View file

@ -32,6 +32,7 @@
macroURI="/orders/components/_listOrderElementMaterials.zul"?> macroURI="/orders/components/_listOrderElementMaterials.zul"?>
<?component name="listOrderElementTaskQualityForms" inline="true" macroURI="_listOrderElementTaskQualityForms.zul"?> <?component name="listOrderElementTaskQualityForms" inline="true" macroURI="_listOrderElementTaskQualityForms.zul"?>
<?component name="listOrderElementAuthorizations" inline="true" macroURI="_listOrderElementAuthorizations.zul"?> <?component name="listOrderElementAuthorizations" inline="true" macroURI="_listOrderElementAuthorizations.zul"?>
<?component name="listOrderElementFiles" inline="true" macroURI="_listOrderElementFiles.zul"?>
<?component name="jiraOrderElementSynchronizer" inline="true" macroURI="components/_jiraOrderElementSync.zul"?> <?component name="jiraOrderElementSynchronizer" inline="true" macroURI="components/_jiraOrderElementSync.zul"?>
<?component name="timOrderTimesheetSynchronizer" inline="true" macroURI="components/_timOrderTimesheetSync.zul"?> <?component name="timOrderTimesheetSynchronizer" inline="true" macroURI="components/_timOrderTimesheetSync.zul"?>
@ -56,6 +57,8 @@
onSelect = "controller.setupAssignedMaterialsToOrderElementController();"/> onSelect = "controller.setupAssignedMaterialsToOrderElementController();"/>
<tab id="tabTaskQualityForm" label="${i18n:_('Task quality forms')}" <tab id="tabTaskQualityForm" label="${i18n:_('Task quality forms')}"
onSelect = "controller.setupAssignedTaskQualityFormsToOrderElementController();"/> onSelect = "controller.setupAssignedTaskQualityFormsToOrderElementController();"/>
<tab id="tabFiles" label="${i18n:_('Files')}"
onSelect="controller.setupOrderFilesController();"/>
<tab id="tabAuthorizations" label="${i18n:_('Authorizations')}" <tab id="tabAuthorizations" label="${i18n:_('Authorizations')}"
onSelect = "controller.setupOrderAuthorizationController();"/> onSelect = "controller.setupOrderAuthorizationController();"/>
</tabs> </tabs>
@ -334,6 +337,9 @@
<tabpanel> <tabpanel>
<listOrderElementTaskQualityForms id="orderElementTaskQualityForms" fulfill="tabTaskQualityForm.onSelect"/> <listOrderElementTaskQualityForms id="orderElementTaskQualityForms" fulfill="tabTaskQualityForm.onSelect"/>
</tabpanel> </tabpanel>
<tabpanel>
<listOrderElementFiles id="orderElementFiles" fulfill="tabFiles.onSelect"/>
</tabpanel>
<tabpanel> <tabpanel>
<listOrderElementAuthorizations id="orderElementAuthorizations" fulfill="tabAuthorizations.onSelect"/> <listOrderElementAuthorizations id="orderElementAuthorizations" fulfill="tabAuthorizations.onSelect"/>
</tabpanel> </tabpanel>

View file

@ -0,0 +1,43 @@
<!--
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 <http://www.gnu.org/licenses/>.
-->
<window id="orderElementFiles" apply="org.libreplan.web.orders.files.OrderFilesController" width="100%">
<vbox id="messagesContainer">
</vbox>
<button label="${i18n:_('Upload')}" disabled="@{orderFilesController.isUploadButtonDisabled}"
onClick="orderFilesController.upload();"/>
<separator spacing="15px"/>
<listbox id="filesList"
width="99%"
visible="@{orderFilesController.isRepositoryExists}"
itemRenderer="@{orderFilesController.filesRenderer}">
<listhead>
<listheader label="${i18n:_('Name')}" width="62%"/>
<listheader label="${i18n:_('Type')}" width="7%"/>
<listheader label="${i18n:_('Upload date')}" width="11%"/>
<listheader label="${i18n:_('Uploaded by')}" width="13%"/>
<listheader label="${i18n:_('Operations')}" width="7%"/>
</listhead>
</listbox>
</window>

View file

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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 <http://www.gnu.org/licenses/>.
-->
<!--
fileuploaddlg.zul
Purpose:
The fileupload modal dialog
Description:
History:
Tue Jul 19 12:06:22 2005, Created by tomyeh
Copyright (C) 2005 Potix Corporation. All Rights Reserved.
{{IS_RIGHT
This program is distributed under LGPL Version 2.1 in the hope that
it will be useful, but WITHOUT ANY WARRANTY.
}}IS_RIGHT
-->
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c" ?>
<?page language="xul/html"?>
<?component name="uploaddlg" extends="window"
class="org.zkoss.zul.impl.FileuploadDlg" widgetClass="zul.fud.FileuploadDlg"?>
<?component name="submit" extends="button" widgetClass="zul.fud.Submit"?>
<?taglib uri="/WEB-INF/tld/i18n.tld" prefix="i18n"?>
<uploaddlg title="${arg.title}" shadow="false" border="normal" width="360px" closable="true"
xmlns:w="http://www.zkoss.org/2005/zk/client"
w:onClose="this.cancel()" w:max="${arg.max}">
<label value="${i18n:_('Please select a file on your system')}"/>
<fileupload id="fileupload" forward="onUpload=" label="${c:l('mesg:org.zkoss.zul.mesg.MZul:UPLOAD_BROWSE')}"
upload="zul.fud.ModalFileViewer,maxsize=${arg.maxsize}${arg.native ? ',native':''}"/>
<separator bar="true"/>
<div id="uploaded" visible="false"></div>
<div id="btns">
<submit id="submit" label="${c:l('mesg:org.zkoss.zul.mesg.MZul:UPLOAD_SUBMIT')}"
w:onClick="this.submit()"/>
<button label="${c:l('mesg:org.zkoss.zul.mesg.MZul:UPLOAD_CANCEL')}" w:onClick="this.$o().cancel(true)"/>
</div>
</uploaddlg>

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
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 <vova@libreplan-enterprise.com>
* 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<OrderFile> 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();
}
}

29
pom.xml
View file

@ -159,6 +159,7 @@
<id>gettext-commons-site</id> <id>gettext-commons-site</id>
<url>http://gettext-commons.googlecode.com/svn/maven-repository</url> <url>http://gettext-commons.googlecode.com/svn/maven-repository</url>
</repository> </repository>
<!-- LibrePlan repository --> <!-- LibrePlan repository -->
<repository> <repository>
<id>thirdparty</id> <id>thirdparty</id>
@ -184,6 +185,7 @@
<!-- Dependency management --> <!-- Dependency management -->
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<!-- Jasper Reports --> <!-- Jasper Reports -->
<dependency> <dependency>
<groupId>net.sf.jasperreports</groupId> <groupId>net.sf.jasperreports</groupId>
@ -195,24 +197,28 @@
<artifactId>jasperreports-fonts</artifactId> <artifactId>jasperreports-fonts</artifactId>
<version>4.0.0</version> <version>4.0.0</version>
</dependency> </dependency>
<!-- GPL Jasperreport Component for ZK --> <!-- GPL Jasperreport Component for ZK -->
<dependency> <dependency>
<groupId>com.igalia.java.zk.components</groupId> <groupId>com.igalia.java.zk.components</groupId>
<artifactId>jasperreportcomponent</artifactId> <artifactId>jasperreportcomponent</artifactId>
<version>1.0</version> <version>1.0</version>
</dependency> </dependency>
<!-- GPL JFreechartEngine for ZK --> <!-- GPL JFreechartEngine for ZK -->
<dependency> <dependency>
<groupId>com.igalia.java.zk.components</groupId> <groupId>com.igalia.java.zk.components</groupId>
<artifactId>jfreechartengine</artifactId> <artifactId>jfreechartengine</artifactId>
<version>1.1</version> <version>1.1</version>
</dependency> </dependency>
<!-- GPL detailrow Component for ZK --> <!-- GPL detailrow Component for ZK -->
<dependency> <dependency>
<groupId>com.igalia.java.zk.components</groupId> <groupId>com.igalia.java.zk.components</groupId>
<artifactId>customdetailrowcomponent</artifactId> <artifactId>customdetailrowcomponent</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<!-- Gettext commons --> <!-- Gettext commons -->
<dependency> <dependency>
<groupId>org.xnap.commons</groupId> <groupId>org.xnap.commons</groupId>
@ -318,6 +324,7 @@
<artifactId>spring-security-acl</artifactId> <artifactId>spring-security-acl</artifactId>
<version>3.2.3.RELEASE</version> <version>3.2.3.RELEASE</version>
</dependency> </dependency>
<!-- Spring Dependency LDAP --> <!-- Spring Dependency LDAP -->
<dependency> <dependency>
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
@ -332,6 +339,7 @@
<version>4.12</version> <version>4.12</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- datasource for testing --> <!-- datasource for testing -->
<dependency> <dependency>
<groupId>com.jolbox</groupId> <groupId>com.jolbox</groupId>
@ -379,18 +387,21 @@
<artifactId>ezmorph</artifactId> <artifactId>ezmorph</artifactId>
<version>1.0.6</version> <version>1.0.6</version>
</dependency> </dependency>
<!-- Commons lang --> <!-- Commons lang -->
<dependency> <dependency>
<groupId>commons-lang</groupId> <groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId> <artifactId>commons-lang</artifactId>
<version>2.4</version> <version>2.4</version>
</dependency> </dependency>
<!-- Commons Math--> <!-- Commons Math-->
<dependency> <dependency>
<groupId>commons-math</groupId> <groupId>commons-math</groupId>
<artifactId>commons-math</artifactId> <artifactId>commons-math</artifactId>
<version>1.2</version> <version>1.2</version>
</dependency> </dependency>
<!-- Commons Logging (required by many frameworks)--> <!-- Commons Logging (required by many frameworks)-->
<dependency> <dependency>
<groupId>commons-logging</groupId> <groupId>commons-logging</groupId>
@ -407,6 +418,7 @@
<artifactId>slf4j-log4j12</artifactId> <artifactId>slf4j-log4j12</artifactId>
<version>1.7.7</version> <version>1.7.7</version>
</dependency> </dependency>
<!-- BeanShell (required by ZK)--> <!-- BeanShell (required by ZK)-->
<dependency> <dependency>
<groupId>org.beanshell</groupId> <groupId>org.beanshell</groupId>
@ -414,6 +426,7 @@
<version>2.0b4</version> <version>2.0b4</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<!-- Apache Commons Fileupload (required by ZK) --> <!-- Apache Commons Fileupload (required by ZK) -->
<dependency> <dependency>
<groupId>commons-fileupload</groupId> <groupId>commons-fileupload</groupId>
@ -421,6 +434,7 @@
<version>1.2.1</version> <version>1.2.1</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<!-- ZK --> <!-- ZK -->
<dependency> <dependency>
<groupId>org.zkoss.zk</groupId> <groupId>org.zkoss.zk</groupId>
@ -443,12 +457,14 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<!-- JGraphT --> <!-- JGraphT -->
<dependency> <dependency>
<groupId>org.jgrapht</groupId> <groupId>org.jgrapht</groupId>
<artifactId>jgrapht-jdk1.5</artifactId> <artifactId>jgrapht-jdk1.5</artifactId>
<version>0.7.3</version> <version>0.7.3</version>
</dependency> </dependency>
<!-- Jfreechart --> <!-- Jfreechart -->
<dependency> <dependency>
<groupId>jfree</groupId> <groupId>jfree</groupId>
@ -460,18 +476,21 @@
<artifactId>jcommon</artifactId> <artifactId>jcommon</artifactId>
<version>1.0.16</version> <version>1.0.16</version>
</dependency> </dependency>
<!-- Joda Time --> <!-- Joda Time -->
<dependency> <dependency>
<groupId>joda-time</groupId> <groupId>joda-time</groupId>
<artifactId>joda-time</artifactId> <artifactId>joda-time</artifactId>
<version>2.3</version> <version>2.3</version>
</dependency> </dependency>
<!-- LibrePlan ZK Components --> <!-- LibrePlan ZK Components -->
<dependency> <dependency>
<groupId>org.libreplan</groupId> <groupId>org.libreplan</groupId>
<artifactId>ganttzk</artifactId> <artifactId>ganttzk</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<!-- LibrePlan Business --> <!-- LibrePlan Business -->
<dependency> <dependency>
<groupId>org.libreplan</groupId> <groupId>org.libreplan</groupId>
@ -490,12 +509,14 @@
<type>jar</type> <type>jar</type>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- JAX-RS API --> <!-- JAX-RS API -->
<dependency> <dependency>
<groupId>javax.ws.rs</groupId> <groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId> <artifactId>jsr311-api</artifactId>
<version>1.0</version> <version>1.0</version>
</dependency> </dependency>
<!-- CXF --> <!-- CXF -->
<dependency> <dependency>
<groupId>org.apache.cxf</groupId> <groupId>org.apache.cxf</groupId>
@ -539,6 +560,7 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<!-- jackson provider --> <!-- jackson provider -->
<dependency> <dependency>
<groupId>org.codehaus.jackson</groupId> <groupId>org.codehaus.jackson</groupId>
@ -550,6 +572,7 @@
<artifactId>jackson-xc</artifactId> <artifactId>jackson-xc</artifactId>
<version>1.9.9</version> <version>1.9.9</version>
</dependency> </dependency>
<!-- ZK Timeplot --> <!-- ZK Timeplot -->
<dependency> <dependency>
<groupId>org.zkoss.zkforge</groupId> <groupId>org.zkoss.zkforge</groupId>
@ -579,24 +602,28 @@
<artifactId>liquibase-maven-plugin</artifactId> <artifactId>liquibase-maven-plugin</artifactId>
<version>2.0.5</version> <version>2.0.5</version>
</dependency> </dependency>
<!-- jqPlot --> <!-- jqPlot -->
<dependency> <dependency>
<groupId>br.com.digilabs.jqplot</groupId> <groupId>br.com.digilabs.jqplot</groupId>
<artifactId>jqplot4java</artifactId> <artifactId>jqplot4java</artifactId>
<version>1.2.3-javascript</version> <version>1.2.3-javascript</version>
</dependency> </dependency>
<!-- MPXJ Library --> <!-- MPXJ Library -->
<dependency> <dependency>
<groupId>net.sourceforge</groupId> <groupId>net.sourceforge</groupId>
<artifactId>mpxj</artifactId> <artifactId>mpxj</artifactId>
<version>4.3.0</version> <version>4.3.0</version>
</dependency> </dependency>
<!-- ZK fileupload --> <!-- ZK fileupload -->
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<version>1.4</version> <version>1.4</version>
</dependency> </dependency>
<!-- Quartz framework --> <!-- Quartz framework -->
<dependency> <dependency>
<groupId>org.quartz-scheduler</groupId> <groupId>org.quartz-scheduler</groupId>
@ -811,12 +838,14 @@
<artifactId>${jdbcDriver.artifactId}</artifactId> <artifactId>${jdbcDriver.artifactId}</artifactId>
<version>${jdbcDriver.version}</version> <version>${jdbcDriver.version}</version>
</dependency> </dependency>
<!-- connection pooling --> <!-- connection pooling -->
<dependency> <dependency>
<groupId>com.jolbox</groupId> <groupId>com.jolbox</groupId>
<artifactId>bonecp</artifactId> <artifactId>bonecp</artifactId>
<version>0.7.1.RELEASE</version> <version>0.7.1.RELEASE</version>
</dependency> </dependency>
<!-- connection pooling dependencies --> <!-- connection pooling dependencies -->
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>