- Author
- Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g
Definition at line 36 of file RelationUtil.java.
◆ addRelation() [1/2]
static void org.turro.contacts.util.RelationUtil.addRelation |
( |
Contact |
business, |
|
|
Contact |
contact, |
|
|
String |
relation |
|
) |
| |
|
static |
Definition at line 38 of file RelationUtil.java.
39 if(business !=
null && contact !=
null && !Strings.isBlank(relation)) {
40 Dao dao =
new ContactsPU();
41 WhereClause wc =
new WhereClause();
42 wc.addClause(
"select r from BusinessRelation as r");
43 wc.addClause(
"where r.contact = :c1");
44 wc.addNamedValue(
"c1", contact);
45 wc.addClause(
"and r.business = :c2");
46 wc.addNamedValue(
"c2", business);
47 wc.addClause(
"and r.relationType = :pr");
48 wc.addNamedValue(
"pr", relation);
49 List<BusinessRelation> relations = dao.getResultList(wc);
50 if(relations.isEmpty()) {
51 BusinessRelation r =
new BusinessRelation();
52 r.setContact(contact);
53 r.setBusiness(business);
54 r.setRelationType(relation);
◆ addRelation() [2/2]
static void org.turro.contacts.util.RelationUtil.addRelation |
( |
String |
business, |
|
|
String |
contact, |
|
|
String |
relation |
|
) |
| |
|
static |
Definition at line 60 of file RelationUtil.java.
61 if(business !=
null && contact !=
null && !Strings.isBlank(relation)) {
62 Dao dao =
new ContactsPU();
63 WhereClause wc =
new WhereClause();
64 wc.addClause(
"select r from BusinessRelation as r");
65 wc.addClause(
"where r.contact.id = :c1");
66 wc.addNamedValue(
"c1", contact);
67 wc.addClause(
"and r.business.id = :c2");
68 wc.addNamedValue(
"c2", business);
69 wc.addClause(
"and r.relationType = :pr");
70 wc.addNamedValue(
"pr", relation);
71 List<BusinessRelation> relations = dao.getResultList(wc);
72 if(relations.isEmpty()) {
73 BusinessRelation r =
new BusinessRelation();
74 r.setContact(dao.find(Contact.class, contact));
75 r.setBusiness(dao.find(Contact.class, business));
76 r.setRelationType(relation);
77 if(r.getContact() !=
null && r.getBusiness()!=
null) {
◆ addRelations()
static void org.turro.contacts.util.RelationUtil.addRelations |
( |
Collection< BusinessRelation > |
relations | ) |
|
|
static |
Definition at line 84 of file RelationUtil.java.
85 Dao dao =
new ContactsPU();
86 dao.saveCollection(relations);
◆ killRelation() [1/2]
static void org.turro.contacts.util.RelationUtil.killRelation |
( |
Contact |
business, |
|
|
Contact |
contact, |
|
|
String |
relation |
|
) |
| |
|
static |
Definition at line 89 of file RelationUtil.java.
90 if(business !=
null && contact !=
null && !Strings.isBlank(relation)) {
91 Dao dao =
new ContactsPU();
92 WhereClause wc =
new WhereClause();
93 wc.addClause(
"delete from BusinessRelation as r");
94 wc.addClause(
"where r.contact = :c1");
95 wc.addNamedValue(
"c1", contact);
96 wc.addClause(
"and r.business = :c2");
97 wc.addNamedValue(
"c2", business);
98 wc.addClause(
"and r.relationType = :pr");
99 wc.addNamedValue(
"pr", relation);
100 dao.executeUpdate(wc);
◆ killRelation() [2/2]
static void org.turro.contacts.util.RelationUtil.killRelation |
( |
String |
business, |
|
|
String |
contact, |
|
|
String |
relation |
|
) |
| |
|
static |
Definition at line 104 of file RelationUtil.java.
105 if(business !=
null && contact !=
null && !Strings.isBlank(relation)) {
106 Dao dao =
new ContactsPU();
107 WhereClause wc =
new WhereClause();
108 wc.addClause(
"delete from BusinessRelation as r");
109 wc.addClause(
"where r.contact.id = :c1");
110 wc.addNamedValue(
"c1", contact);
111 wc.addClause(
"and r.business.id = :c2");
112 wc.addNamedValue(
"c2", business);
113 wc.addClause(
"and r.relationType = :pr");
114 wc.addNamedValue(
"pr", relation);
115 dao.executeUpdate(wc);
◆ killRelations()
static void org.turro.contacts.util.RelationUtil.killRelations |
( |
String |
like | ) |
|
|
static |
Definition at line 119 of file RelationUtil.java.
120 if(!Strings.isBlank(like)) {
121 Dao dao =
new ContactsPU();
122 WhereClause wc =
new WhereClause();
123 wc.addClause(
"delete from BusinessRelation as r");
124 wc.addClause(
"where r.relationType like :pr");
125 wc.addNamedValue(
"pr", like);
126 dao.executeUpdate(wc);
◆ setPreferentialRelation()
static void org.turro.contacts.util.RelationUtil.setPreferentialRelation |
( |
| ) |
|
|
static |
Definition at line 130 of file RelationUtil.java.
131 try(Stream<Contact> contacts =
new ContactsPU().stream(Contact.class,
"select c from Contact c")) {
132 contacts.forEach((contact) -> {
133 if(contact.getBusiness() ==
null) {
134 for(BusinessRelation relation : contact.getBusinessRelations()) {
135 if(!Strings.isBlank(relation.getRelationType()) && relation.getRelationType().startsWith(
"$REL_")) {
136 new ContactsPU().executeUpdate(
137 "update BusinessRelation set preferential = TRUE where identifier = ?",
138 new Object[] { relation.getId() }
The documentation for this class was generated from the following file: