Add relationship between and Worker and User
FEA: ItEr76S27ResourceBinding
This commit is contained in:
parent
00378d039a
commit
24bb2f50e2
5 changed files with 46 additions and 3 deletions
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
* Copyright (C) 2010-2011 Igalia, S.L.
|
||||
* Copyright (C) 2010-2012 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
|
||||
|
|
@ -27,6 +27,7 @@ import org.hibernate.validator.AssertTrue;
|
|||
import org.hibernate.validator.NotEmpty;
|
||||
import org.libreplan.business.common.Registry;
|
||||
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.libreplan.business.users.entities.User;
|
||||
|
||||
/**
|
||||
* This class models a worker.
|
||||
|
|
@ -35,6 +36,7 @@ import org.libreplan.business.common.exceptions.InstanceNotFoundException;
|
|||
*
|
||||
* @author Fernando Bellas Permuy <fbellas@udc.es>
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
public class Worker extends Resource {
|
||||
|
||||
|
|
@ -90,6 +92,8 @@ public class Worker extends Resource {
|
|||
|
||||
private String nif;
|
||||
|
||||
private User user;
|
||||
|
||||
/**
|
||||
* Constructor for hibernate. Do not use!
|
||||
*/
|
||||
|
|
@ -202,4 +206,12 @@ public class Worker extends Resource {
|
|||
return firstName + " " + surname;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
* Copyright (C) 2010-2011 Igalia, S.L.
|
||||
* Copyright (C) 2010-2012 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
|
||||
|
|
@ -30,6 +30,7 @@ import org.libreplan.business.common.BaseEntity;
|
|||
import org.libreplan.business.common.IHumanIdentifiable;
|
||||
import org.libreplan.business.common.Registry;
|
||||
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.libreplan.business.resources.entities.Worker;
|
||||
import org.libreplan.business.scenarios.entities.Scenario;
|
||||
import org.libreplan.business.settings.entities.Language;
|
||||
import org.libreplan.business.users.daos.IUserDAO;
|
||||
|
|
@ -41,7 +42,7 @@ import org.libreplan.business.users.daos.IUserDAO;
|
|||
* @author Jacobo Aragunde Perez <jaragunde@igalia.com>
|
||||
* @author Cristina Alvarino Perez <cristina.alvarino@comtecsf.es>
|
||||
* @author Ignacio Diaz Teijido <ignacio.diaz@comtecsf.es>
|
||||
*
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
public class User extends BaseEntity implements IHumanIdentifiable{
|
||||
|
||||
|
|
@ -74,6 +75,8 @@ public class User extends BaseEntity implements IHumanIdentifiable{
|
|||
|
||||
private String lastName = "";
|
||||
|
||||
private Worker worker;
|
||||
|
||||
/**
|
||||
* Necessary for Hibernate. Please, do not call it.
|
||||
*/
|
||||
|
|
@ -292,4 +295,12 @@ public class User extends BaseEntity implements IHumanIdentifiable{
|
|||
return "LDAP";
|
||||
}
|
||||
|
||||
public Worker getWorker() {
|
||||
return worker;
|
||||
}
|
||||
|
||||
public void setWorker(Worker worker) {
|
||||
this.worker = worker;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -451,4 +451,16 @@
|
|||
<dropColumn tableName="order_element_template" columnName="code" />
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="add-relationship-between-worker-and-user" author="mrego">
|
||||
<comment>Add column and constraints needed for relationship between worker and user</comment>
|
||||
<addColumn tableName="worker">
|
||||
<column name="user_id" type="BIGINT" />
|
||||
</addColumn>
|
||||
<addUniqueConstraint tableName="worker" columnNames="user_id"
|
||||
constraintName="worker_user_id_key" />
|
||||
<addForeignKeyConstraint constraintName="worker_user_fkey"
|
||||
baseTableName="worker" baseColumnNames="user_id"
|
||||
referencedTableName="user_table" referencedColumnNames="id" />
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
|
|
|
|||
|
|
@ -59,6 +59,10 @@
|
|||
<property name="surname"/>
|
||||
<property name="nif"/>
|
||||
|
||||
<many-to-one name="user" cascade="save-update"
|
||||
class="org.libreplan.business.users.entities.User"
|
||||
column="user_id" unique="true" />
|
||||
|
||||
<joined-subclass name="org.libreplan.business.resources.entities.VirtualWorker" table="virtual_worker">
|
||||
<key column="virtual_worker_id"/>
|
||||
<property name="observations"/>
|
||||
|
|
|
|||
|
|
@ -59,6 +59,10 @@
|
|||
</set>
|
||||
<many-to-one name="lastConnectedScenario"
|
||||
class="org.libreplan.business.scenarios.entities.Scenario" />
|
||||
|
||||
<one-to-one name="worker" property-ref="user"
|
||||
class="org.libreplan.business.resources.entities.Worker" />
|
||||
|
||||
</class>
|
||||
|
||||
<class name="Profile" table="profile_table">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue