Replaced the limitingResource attribute in Resource entity with resourceType.
This replacement has implications in higher layers and makes the application crash, but changes are separated in several patches to improve their legibility. In this patch, we modify the DB, the DB update system and the entities in the bussiness layer. FEA: ItEr65OTS07XestionRecursosEstratexicos
This commit is contained in:
parent
b511dff794
commit
6d48769a46
4 changed files with 86 additions and 5 deletions
|
|
@ -124,7 +124,7 @@ public abstract class Resource extends IntegrationEntity {
|
|||
private Set<ResourcesCostCategoryAssignment> resourcesCostCategoryAssignments =
|
||||
new HashSet<ResourcesCostCategoryAssignment>();
|
||||
|
||||
private Boolean limitingResource = Boolean.FALSE;
|
||||
private ResourceType resourceType = ResourceType.NON_LIMITING_RESOURCE;
|
||||
|
||||
private LimitingResourceQueue limitingResourceQueue;
|
||||
|
||||
|
|
@ -1139,11 +1139,15 @@ public abstract class Resource extends IntegrationEntity {
|
|||
}
|
||||
|
||||
public Boolean isLimitingResource() {
|
||||
return limitingResource;
|
||||
return (resourceType == ResourceType.LIMITING_RESOURCE);
|
||||
}
|
||||
|
||||
public void setLimitingResource(Boolean limitingResource) {
|
||||
this.limitingResource = limitingResource;
|
||||
public ResourceType getResourceType() {
|
||||
return resourceType;
|
||||
}
|
||||
|
||||
public void setResourceType(ResourceType resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
public LimitingResourceQueue getLimitingResourceQueue() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* This file is part of NavalPlan
|
||||
*
|
||||
* Copyright (C) 2010 Igalia S.L.
|
||||
*
|
||||
* 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.navalplanner.business.resources.entities;
|
||||
|
||||
import static org.navalplanner.business.i18n.I18nHelper._;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Enumerate with the three basic types of resource: non-limiting, limiting and strategic.
|
||||
* @author Jacobo Aragunde Perez <jaragunde@igalia.com>
|
||||
*/
|
||||
public enum ResourceType {
|
||||
|
||||
NON_LIMITING_RESOURCE(_("NON LIMITING RESOURCE")),
|
||||
LIMITING_RESOURCE(_("LIMITING RESOURCE")),
|
||||
STRATEGIC_RESOURCE(_("STRATEGIC RESOURCE"));
|
||||
|
||||
private String option;
|
||||
|
||||
private ResourceType(String option) {
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return option;
|
||||
}
|
||||
|
||||
public static Set<ResourceType> getResourceTypeList() {
|
||||
return EnumSet.of(
|
||||
ResourceType.NON_LIMITING_RESOURCE,
|
||||
ResourceType.LIMITING_RESOURCE,
|
||||
ResourceType.STRATEGIC_RESOURCE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -63,4 +63,22 @@
|
|||
where day_id IN (5, 6) AND allowed_extra_effort IS NULL
|
||||
</sql>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="replace-column-limited_resource-with-resource_type" author="jaragunde">
|
||||
<comment>Replace column limited_resource with resource_type in resource table</comment>
|
||||
<addColumn tableName="resource">
|
||||
<column name="resource_type" type="VARCHAR(64)"/>
|
||||
</addColumn>
|
||||
<update tableName="resource">
|
||||
<column name="resource_type" value="NON_LIMITING_RESOURCE"/>
|
||||
<where>limited_resource = false</where>
|
||||
</update>
|
||||
<update tableName="resource">
|
||||
<column name="resource_type" value="LIMITING_RESOURCE"/>
|
||||
<where>limited_resource = true</where>
|
||||
</update>
|
||||
<addNotNullConstraint tableName="resource" columnName="resource_type" />
|
||||
<dropColumn tableName="resource" columnName="limited_resource"/>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,12 @@
|
|||
|
||||
<property name="codeAutogenerated" not-null="true" column="code_autogenerated" />
|
||||
|
||||
<property name="limitingResource" column="limited_resource" not-null="true"/>
|
||||
<property name="resourceType" column="resource_type" not-null="true">
|
||||
<type name="org.hibernate.type.EnumType">
|
||||
<param name="enumClass">org.navalplanner.business.resources.entities.ResourceType</param>
|
||||
<param name="type">12</param>
|
||||
</type>
|
||||
</property>
|
||||
|
||||
<!-- It is appropiate the index by the foreign key in the many-to-one side -->
|
||||
<set access="field" cascade="all-delete-orphan" inverse="true" name="criterionSatisfactions">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue