BrightSide Workbench Full Report + Source Code
bsfinancials-core/src/main/java/org/turro/financials/model/contract/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.financials.model.contract;
20 
21 import java.util.Date;
22 import org.turro.elephant.util.Images;
23 import org.turro.financials.entity.ContractParticipant;
24 import org.turro.i18n.I_;
25 import org.turro.plugin.contacts.AbstractContactRelation;
26 
32 
33  private final boolean asWorker;
34  private final ContractParticipant contractParticipant;
35 
36  public ContactRelationAdapter(boolean asWorker, ContractParticipant contractParticipant) {
37  this.asWorker = asWorker;
38  this.contractParticipant = contractParticipant;
39  }
40 
41  @Override
42  public String getRelatedId() {
43  return asWorker ? contractParticipant.getContract().getContractor() :
44  contractParticipant.getIdContact();
45  }
46 
47  @Override
48  public String getDue() {
49  return I_.byKey(contractParticipant.getInterventionType().toString()) +
50  " (" + contractParticipant.getContract().getContractDefinition().getName() + ")";
51  }
52 
53  @Override
54  public boolean asWorker() {
55  return asWorker;
56  }
57 
58  @Override
59  public boolean getStrong() {
60  return true;
61  }
62 
63  @Override
64  public boolean getValidated() {
65  return true;
66  }
67 
68  @Override
69  public String getImage() {
70  return Images.getImage("contract");
71  }
72 
73  @Override
74  public Date getStartDate() {
75  return contractParticipant.getContract().getStartDate();
76  }
77 
78  @Override
79  public Date getEndDate() {
80  return contractParticipant.getContract().getEndDate();
81  }
82 
83 }
static String getImage(String image)
Definition: Images.java:36
ContractDefinition getContractDefinition()
Definition: Contract.java:125
static String byKey(String key)
Definition: I_.java:83