BrightSide Workbench Full Report + Source Code
AlliancePU.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.alliance.db;
19 
20 import javax.persistence.EntityManager;
21 import javax.persistence.EntityManagerFactory;
22 import org.turro.alliance.db.entities.AxCenter;
23 import org.turro.alliance.db.entities.AxContact;
24 import org.turro.alliance.db.entities.AxProject;
25 import org.turro.alliance.db.entities.AxProjectGrant;
26 import org.turro.alliance.db.entities.AxStudent;
27 import org.turro.jpa.Dao;
28 import org.turro.jpa.DaoFactory;
29 import org.turro.version.Module;
30 import org.turro.version.Version;
31 
36 public class AlliancePU extends Dao {
37 
38  private static final DaoFactory factory = new DaoFactory();
39 
40  @Override
41  protected EntityManagerFactory getFactory() {
42  return factory.getEmf();
43  }
44 
45  @Override
46  protected EntityManager createEntityManager() {
47  return factory.createEntityManager("alliancePU", "Alliance");
48  }
49 
50  @Override
51  protected EntityManager createCachedEntityManager() {
52  return factory.createCachedEntityManager("alliancePU", "Alliance");
53  }
54 
55  @Override
56  public String getPath(Object object) {
57  return getObjectPath(object);
58  }
59 
60  public static String getObjectPath(Object object) {
61  if(object instanceof AxContact) {
62  return "/axcontact/" + ((AxContact) object).getContactId().stringify();
63  } else if(object instanceof AxProject) {
64  return "/axproject/" + ((AxProject) object).getProjectId().stringify();
65  } else if(object instanceof AxProjectGrant) {
66  return "/axproject-grant/" + ((AxProjectGrant) object).getProjectGrantId().stringify();
67  } else if(object instanceof AxStudent) {
68  return "/axstudent/" + ((AxStudent) object).getStudentId().stringify();
69  } else if(object instanceof AxCenter) {
70  return "/axcenter/" + ((AxCenter) object).getCenterId().stringify();
71  }
72  return null;
73  }
74 
75  public static String getObjectExtendedPath(Object object) {
76  return "";
77  }
78 
79  public static Module getModule() {
80  return new Module(new Version("1.0"), "Elephant Alliance");
81  }
82 
83 }
EntityManager createEntityManager()
Definition: AlliancePU.java:46
static String getObjectPath(Object object)
Definition: AlliancePU.java:60
static String getObjectExtendedPath(Object object)
Definition: AlliancePU.java:75
EntityManager createCachedEntityManager()
Definition: AlliancePU.java:51
EntityManagerFactory getFactory()
Definition: AlliancePU.java:41
String getPath(Object object)
Definition: AlliancePU.java:56
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