ItEr35S14CUAdministracionMateriaisItEr34S14: Created skeleton for entities Material and MaterialCategory

This commit is contained in:
Diego Pino Garcia 2009-11-23 10:46:52 +01:00 committed by Javier Moran Rua
parent f831947185
commit 8a1af57cfb
5 changed files with 161 additions and 1 deletions

View file

@ -0,0 +1,51 @@
/*
* This file is part of ###PROJECT_NAME###
*
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
*
* 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.materials.entities;
import java.math.BigDecimal;
import org.hibernate.validator.NotEmpty;
import org.navalplanner.business.common.BaseEntity;
/**
* Material entity
*
* @author Jacobo Aragunde Perez <jaragunde@igalia.com>
*
*/
public class Material extends BaseEntity {
private String description;
private BigDecimal defaultUnitPrice;
@NotEmpty
private String materialCode;
private boolean disabled;
private MaterialCategory category;
// Default constructor, needed by Hibernate
protected Material() {
}
}

View file

@ -0,0 +1,51 @@
/*
* This file is part of ###PROJECT_NAME###
*
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
*
* 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.materials.entities;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.hibernate.validator.NotEmpty;
import org.navalplanner.business.common.BaseEntity;
/**
* MaterialCategory entity
*
* @author Jacobo Aragunde Perez <jaragunde@igalia.com>
*
*/
public class MaterialCategory extends BaseEntity {
@NotEmpty
private String name;
private MaterialCategory parent;
private Set<MaterialCategory> subcategories = new HashSet<MaterialCategory>();
private Set<Material> materials = new HashSet<Material>();
// Default constructor, needed by Hibernate
protected MaterialCategory() {
}
}

View file

@ -52,6 +52,9 @@
<value>
org/navalplanner/business/common/entities/Configuration.hbm.xml
</value>
<value>
org/navalplanner/business/materials/entities/Materials.hbm.xml
</value>
</list>
</property>
</bean>

View file

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.navalplanner.business.materials.entities" default-access="field">
<!-- Material -->
<class name="Material" table="MATERIAL">
<id name="id" type="long" access="property">
<generator class="hilo">
<param name="max_lo">100</param>
</generator>
</id>
<version name="version" access="property" type="long" />
<property name="description"/>
<property name="defaultUnitPrice"/>
<property name="materialCode" unique="true"/>
<property name="disabled"/>
<many-to-one name="category" class="MaterialCategory" column="CATEGORY_ID" />
</class>
<!-- MaterialCategory -->
<class name="MaterialCategory" table="MATERIAL_CATEGORY">
<id name="id" type="long" access="property">
<generator class="hilo">
<param name="max_lo">100</param>
</generator>
</id>
<version name="version" access="property" type="long" />
<property name="name" />
<set name="subcategories" inverse="false" cascade="all">
<key column="PARENT_ID"/>
<one-to-many class="MaterialCategory"/>
</set>
<many-to-one name="parent" class="MaterialCategory" column="PARENT_ID" />
<set name="materials" inverse="false" cascade="all">
<key column="ID"/>
<one-to-many class="Material"/>
</set>
</class>
</hibernate-mapping>

View file

@ -60,7 +60,10 @@
<value>
org/navalplanner/business/common/entities/Configuration.hbm.xml
</value>
<value>
<value>
org/navalplanner/business/materials/entities/Materials.hbm.xml
</value>
<value>
TestEntities.hbm.xml
</value>
</list>