BrightSide Workbench Full Report + Source Code
CrmPU.java
Go to the documentation of this file.
1 package org.turro.crm.db;
2 
3 import javax.persistence.EntityManager;
4 import javax.persistence.EntityManagerFactory;
5 import org.turro.crm.entity.Campaign;
6 import org.turro.crm.entity.Customer;
7 import org.turro.crm.entity.SaleAction;
8 import org.turro.crm.entity.SaleProspect;
9 import org.turro.crm.entity.Vendor;
10 import org.turro.crm.entity.VendorProspect;
11 import org.turro.jpa.DaoFactory;
12 import org.turro.version.Module;
13 import org.turro.version.Version;
14 
19 public class CrmPU extends org.turro.jpa.Dao {
20 
21  private static final DaoFactory factory = new DaoFactory();
22 
23  @Override
24  protected EntityManagerFactory getFactory() {
25  return factory.getEmf();
26  }
27 
28  @Override
29  protected EntityManager createEntityManager() {
30  return factory.createEntityManager("crmPU", "Crm");
31  }
32 
33  @Override
34  public EntityManager createCachedEntityManager() {
35  return factory.createCachedEntityManager("crmPU", "Crm");
36  }
37 
38  @Override
39  public String getPath(Object object) {
40  return getObjectPath(object);
41  }
42 
43  public static String getObjectPath(Object object) {
44  if(object instanceof Vendor) {
45  return "/vendor/" + ((Vendor) object).getId();
46  } else if(object instanceof Customer) {
47  return "/customer/" + ((Customer) object).getId();
48  } else if(object instanceof Campaign) {
49  return "/campaign/" + ((Campaign) object).getId();
50  } else if(object instanceof SaleProspect) {
51  return "/sale-prospect/" + ((SaleProspect) object).getId();
52  } else if(object instanceof VendorProspect) {
53  return "/vendor-prospect/" + ((VendorProspect) object).getId();
54  } else if(object instanceof SaleAction) {
55  return "/sale-action/" + ((SaleAction) object).getId();
56  }
57  return null;
58  }
59 
60  public static String getObjectExtendedPath(Object object) {
61  return "";
62  }
63 
64  public static Module getModule() {
65  return new Module(new Version("0.5.3"), "BrightSide Customer Relationship");
66  }
67 
68 }
69 
String getPath(Object object)
Definition: CrmPU.java:39
static String getObjectPath(Object object)
Definition: CrmPU.java:43
EntityManager createCachedEntityManager()
Definition: CrmPU.java:34
static Module getModule()
Definition: CrmPU.java:64
EntityManager createEntityManager()
Definition: CrmPU.java:29
static String getObjectExtendedPath(Object object)
Definition: CrmPU.java:60
EntityManagerFactory getFactory()
Definition: CrmPU.java:24
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