BrightSide Workbench Full Report + Source Code
ErpPU.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.erp.db;
19 
20 import javax.persistence.EntityManager;
21 import org.turro.erp.entity.*;
22 import org.turro.jpa.Dao;
23 import org.turro.jpa.DaoFactory;
24 import org.turro.version.Module;
25 import org.turro.version.Version;
26 
31 public class ErpPU extends Dao {
32 
33  private static DaoFactory factory = new DaoFactory();
34 
35  @Override
36  protected EntityManager createEntityManager() {
37  return factory.createEntityManager("erpPU", "Erp");
38  }
39 
40  @Override
41  public EntityManager createCachedEntityManager() {
42  return factory.createCachedEntityManager("erpPU", "Erp");
43  }
44 
45  @Override
46  public String getPath(Object object) {
47  return getObjectPath(object);
48  }
49 
50  public static String getObjectPath(Object object) {
51  if(object instanceof HumanResource) {
52  return "/humanres/" + ((HumanResource) object).getId();
53  } else if(object instanceof Aptitude) {
54  return "/aptitude/" + ((Aptitude) object).getId();
55  } else if(object instanceof Resource) {
56  return "/resource/" + ((Resource) object).getId();
57  } else if(object instanceof CategorizedTask) {
58  return "/cattask/" + ((CategorizedTask) object).getId();
59  } else if(object instanceof WorkOrder) {
60  return "/workorder/" + ((WorkOrder) object).getId();
61  } else if(object instanceof CustomerOrder) {
62  return "/custorder/" + ((CustomerOrder) object).getId();
63  } else if(object instanceof OrderReference) {
64  return "/orderref/" + ((OrderReference) object).getId();
65  } else if(object instanceof Task) {
66  return "/task/" + ((Task) object).getId();
67  } else if(object instanceof RequiredUsage) {
68  return "/requsage/" + ((RequiredUsage) object).getId();
69  }
70  return null;
71  }
72 
73  public static String getObjectExtendedPath(Object object) {
74  return "";
75  }
76 
77  public static Module getModule() {
78  return new Module(new Version("0.3.1"), "BrightSide Enterprise Resource Planning");
79  }
80 
81 }
EntityManager createEntityManager()
Definition: ErpPU.java:36
String getPath(Object object)
Definition: ErpPU.java:46
static Module getModule()
Definition: ErpPU.java:77
static String getObjectExtendedPath(Object object)
Definition: ErpPU.java:73
EntityManager createCachedEntityManager()
Definition: ErpPU.java:41
static String getObjectPath(Object object)
Definition: ErpPU.java:50
EntityManager createEntityManager(String pu, String conf)
Definition: DaoFactory.java:54
synchronized EntityManager createCachedEntityManager(String pu, String conf)
Definition: DaoFactory.java:64