BrightSide Workbench Full Report + Source Code
FinancialsPU.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.financials.db;
19 
20 import javax.persistence.EntityManager;
21 import javax.persistence.EntityManagerFactory;
22 import org.turro.financials.entity.*;
23 import org.turro.jpa.Dao;
24 import org.turro.jpa.DaoFactory;
25 import org.turro.version.Module;
26 import org.turro.version.Version;
27 
32 public class FinancialsPU extends Dao {
33 
34  private static final DaoFactory factory = new DaoFactory();
35 
36  @Override
37  protected EntityManagerFactory getFactory() {
38  return factory.getEmf();
39  }
40 
41  @Override
42  protected EntityManager createEntityManager() {
43  return factory.createEntityManager("financialsPU", "Financials");
44  }
45 
46  @Override
47  public EntityManager createCachedEntityManager() {
48  return factory.createCachedEntityManager("financialsPU", "Financials");
49  }
50 
51  @Override
52  public String getPath(Object object) {
53  return getObjectPath(object);
54  }
55 
56  public static String getObjectPath(Object object) {
57  if(object instanceof Contract) {
58  return "/contract/" + ((Contract) object).getId();
59  } else if(object instanceof Document) {
60  return "/document/" + ((Document) object).getId();
61  } else if(object instanceof BatchOf) {
62  return "/batchof/" + ((BatchOf) object).getId();
63  } else if(object instanceof DocumentLine) {
64  return "/docline/" + ((DocumentLine) object).getId();
65  } else if(object instanceof Product) {
66  return "/product/" + ((Product) object).getId();
67  } else if(object instanceof FixedAsset) {
68  return "/fixed-asset/" + ((FixedAsset) object).getId();
69  } else if(object instanceof Register) {
70  return "/register/" + ((Register) object).getId();
71  } else if(object instanceof Company) {
72  return "/company/" + ((Company) object).getId();
73  } else if(object instanceof Department) {
74  return "/department/" + ((Department) object).getId();
75  } else if(object instanceof Service) {
76  return "/service/" + ((Service) object).getId();
77  } else if(object instanceof Account) {
78  return "/account/" + ((Account) object).getId();
79  } else if(object instanceof MajorAccount) {
80  return "/major-account/" + ((MajorAccount) object).getId();
81  }
82  return null;
83  }
84 
85  public static String getObjectExtendedPath(Object object) {
86  return "";
87  }
88 
89  public static Module getModule() {
90  return new Module(new Version("1.3.9"), "BrightSide Financials");
91  }
92 
93 }
static String getObjectPath(Object object)
static String getObjectExtendedPath(Object object)
EntityManagerFactory getFactory()
EntityManagerFactory getEmf()
Definition: DaoFactory.java:89
EntityManager createEntityManager(String pu, String conf)
Definition: DaoFactory.java:54
synchronized EntityManager createCachedEntityManager(String pu, String conf)
Definition: DaoFactory.java:64