BrightSide Workbench Full Report + Source Code
BrightSide/contacts/src/main/java/org/turro/contacts/relation/ContactRelationAdapter.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2020 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 
19 package org.turro.contacts.relation;
20 
21 import java.util.Date;
22 import org.turro.string.Strings;
23 import org.turro.action.Contacts;
24 import org.turro.contacts.BusinessRelation;
25 import org.turro.contacts.organigram.RelationType;
26 import org.turro.elephant.util.Images;
27 import org.turro.plugin.contacts.AbstractContactRelation;
28 
34 
35  private final boolean asWorker;
36  private final BusinessRelation relation;
37 
38  public ContactRelationAdapter(boolean asWorker, BusinessRelation relation) {
39  super(asWorker ? Contacts.getContact(relation.getBusiness()) : Contacts.getContact(relation.getContact()));
40  this.asWorker = asWorker;
41  this.relation = relation;
42  }
43 
44  @Override
45  public String getDue() {
46  return relation.getFormattedDescription();
47  }
48 
49  @Override
50  public boolean isWorker() {
51  return relation.isWorker();
52  }
53 
54  @Override
55  public boolean isHHRR() {
56  return relation.isHHRR();
57  }
58 
59  @Override
60  public boolean asWorker() {
61  return asWorker;
62  }
63 
64  @Override
65  public boolean getStrong() {
66  return relation.isPreferential();
67  }
68 
69  @Override
70  public boolean getValidated() {
71  return relation.isValidated();
72  }
73 
74  @Override
75  public String getImage() {
76  if(!Strings.isBlank(relation.getRelationType())) {
78  if(rt != null) {
79  return rt.getImage();
80  }
81  }
82  return Images.getBlankImage();
83  }
84 
85  @Override
86  public Date getStartDate() {
87  return relation.getStartDate();
88  }
89 
90  @Override
91  public Date getEndDate() {
92  return relation.getEndDate();
93  }
94 
95  @Override
96  public Object getRelation() {
97  return relation;
98  }
99 
100 }
static IContact getContact(Object object)
Definition: Contacts.java:109
static String getBlankImage()
Definition: Images.java:48
static RelationType getFromString(String relation)