BrightSide Workbench Full Report + Source Code
org.turro.financials.handshake.HandshakeContract Class Reference

Public Member Functions

int hashCode ()
 
boolean equals (Object obj)
 

Static Public Member Functions

static String createJsonFromContract (Contract contract)
 
static HandshakeContract createHandshakeFromContract (Contract contract)
 
static HandshakeContract createHandshakeFromJson (String value)
 
static HandshakeContract createHandshakeFromFile (File file)
 
static void saveHandshakeToFile (File file, HandshakeContract hc)
 
static Contract getContractFromRemoteContract (String value)
 
static Contract getContractFromHandshake (HandshakeContract hc)
 
static ContractHandshake getContractHandshakeFromHandshake (HandshakeContract hc)
 
static void saveHandshakePetition (HandshakeContract hc)
 
static boolean existsHandshake (HandshakeContract hc)
 
static boolean updateRemoteId (String remoteServer, String remoteId, long contractId)
 

Public Attributes

String petitioner
 
long remoteId
 
String remoteName
 
String remoteServer
 

Static Public Attributes

static final String HANDSHAKE_FOLDER = "/WEB-INF/handshake/contract"
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 41 of file HandshakeContract.java.

Member Function Documentation

◆ createHandshakeFromContract()

static HandshakeContract org.turro.financials.handshake.HandshakeContract.createHandshakeFromContract ( Contract  contract)
static

Definition at line 59 of file HandshakeContract.java.

59  {
60  Company company = CompanyWrapper.getDefaultCompany();
61  if(company != null) {
62  HandshakeContract hc = new HandshakeContract();
63  hc.petitioner = company.getName();
64  hc.remoteServer = ElephantContext.getServerUrl("http");
65  hc.remoteId = contract.getId();
66  hc.remoteName = contract.getName();
67  return hc;
68  }
69  return null;
70  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createHandshakeFromFile()

static HandshakeContract org.turro.financials.handshake.HandshakeContract.createHandshakeFromFile ( File  file)
static

Definition at line 76 of file HandshakeContract.java.

76  {
77  try {
78  return createHandshakeFromJson(FileUtil.getContent(file));
79  } catch (IOException ex) {
80  Logger.getLogger(HandshakeContract.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
81  }
82  return null;
83  }
static HandshakeContract createHandshakeFromJson(String value)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createHandshakeFromJson()

static HandshakeContract org.turro.financials.handshake.HandshakeContract.createHandshakeFromJson ( String  value)
static

Definition at line 72 of file HandshakeContract.java.

72  {
73  return new Gson().fromJson(value, HandshakeContract.class);
74  }
Here is the caller graph for this function:

◆ createJsonFromContract()

static String org.turro.financials.handshake.HandshakeContract.createJsonFromContract ( Contract  contract)
static

Definition at line 51 of file HandshakeContract.java.

51  {
52  HandshakeContract hc = createHandshakeFromContract(contract);
53  if(hc != null) {
54  return new Gson().toJson(hc);
55  }
56  return null;
57  }
static HandshakeContract createHandshakeFromContract(Contract contract)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ equals()

boolean org.turro.financials.handshake.HandshakeContract.equals ( Object  obj)

Definition at line 157 of file HandshakeContract.java.

157  {
158  if (obj == null) {
159  return false;
160  }
161  if (getClass() != obj.getClass()) {
162  return false;
163  }
164  final HandshakeContract other = (HandshakeContract) obj;
165  if (this.remoteId != other.remoteId) {
166  return false;
167  }
168  if (!Objects.equals(this.remoteServer, other.remoteServer)) {
169  return false;
170  }
171  return true;
172  }
Here is the caller graph for this function:

◆ existsHandshake()

static boolean org.turro.financials.handshake.HandshakeContract.existsHandshake ( HandshakeContract  hc)
static

Definition at line 122 of file HandshakeContract.java.

122  {
123  File folder = new File(ElephantContext.getRealPath(HANDSHAKE_FOLDER));
124  if(!folder.exists()) { folder.mkdirs(); }
125  for(File file : folder.listFiles()) {
126  HandshakeContract fhc = createHandshakeFromFile(file);
127  if(hc.equals(fhc)) {
128  return true;
129  }
130  }
131  return false;
132  }
static HandshakeContract createHandshakeFromFile(File file)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getContractFromHandshake()

static Contract org.turro.financials.handshake.HandshakeContract.getContractFromHandshake ( HandshakeContract  hc)
static

Definition at line 98 of file HandshakeContract.java.

98  {
99  ContractHandshake ch = getContractHandshakeFromHandshake(hc);
100  return ch != null ? ch.getContract() : null;
101  }
static ContractHandshake getContractHandshakeFromHandshake(HandshakeContract hc)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getContractFromRemoteContract()

static Contract org.turro.financials.handshake.HandshakeContract.getContractFromRemoteContract ( String  value)
static

Definition at line 93 of file HandshakeContract.java.

93  {
94  HandshakeContract hc = createHandshakeFromJson(value);
95  return getContractFromHandshake(hc);
96  }
static Contract getContractFromHandshake(HandshakeContract hc)
Here is the call graph for this function:

◆ getContractHandshakeFromHandshake()

static ContractHandshake org.turro.financials.handshake.HandshakeContract.getContractHandshakeFromHandshake ( HandshakeContract  hc)
static

Definition at line 103 of file HandshakeContract.java.

103  {
104  Dao dao = new FinancialsPU();
105  return (ContractHandshake) dao.getSingleResultOrNull(
106  "select ch from ContractHandshake ch " +
107  "where ch.remoteServer = ? " +
108  "and ch.remoteId = ?",
109  new Object[] {
110  hc.remoteServer,
111  hc.remoteId
112  });
113  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hashCode()

int org.turro.financials.handshake.HandshakeContract.hashCode ( )

Definition at line 149 of file HandshakeContract.java.

149  {
150  int hash = 7;
151  hash = 89 * hash + (int) (this.remoteId ^ (this.remoteId >>> 32));
152  hash = 89 * hash + Objects.hashCode(this.remoteServer);
153  return hash;
154  }

◆ saveHandshakePetition()

static void org.turro.financials.handshake.HandshakeContract.saveHandshakePetition ( HandshakeContract  hc)
static

Definition at line 115 of file HandshakeContract.java.

115  {
116  if(!existsHandshake(hc)) {
117  File file = new File(ElephantContext.getRealPath(HANDSHAKE_FOLDER) + "/contract" + IdGenerator.generate() + ".handshake");
118  saveHandshakeToFile(file, hc);
119  }
120  }
static void saveHandshakeToFile(File file, HandshakeContract hc)
static boolean existsHandshake(HandshakeContract hc)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveHandshakeToFile()

static void org.turro.financials.handshake.HandshakeContract.saveHandshakeToFile ( File  file,
HandshakeContract  hc 
)
static

Definition at line 85 of file HandshakeContract.java.

85  {
86  try {
87  FileUtil.setContent(file, new Gson().toJson(hc));
88  } catch (IOException ex) {
89  Logger.getLogger(HandshakeContract.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
90  }
91  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateRemoteId()

static boolean org.turro.financials.handshake.HandshakeContract.updateRemoteId ( String  remoteServer,
String  remoteId,
long  contractId 
)
static

Definition at line 134 of file HandshakeContract.java.

134  {
135  Dao dao = new FinancialsPU();
136  return dao.executeUpdate(
137  "update ContractHandshake " +
138  "set remoteId = ? " +
139  "where remoteServer = ? " +
140  "and contract.id = ?",
141  new Object[] {
142  contractId,
143  remoteServer,
144  Long.valueOf(remoteId)
145  }) > 0;
146  }
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ HANDSHAKE_FOLDER

final String org.turro.financials.handshake.HandshakeContract.HANDSHAKE_FOLDER = "/WEB-INF/handshake/contract"
static

Definition at line 44 of file HandshakeContract.java.

◆ petitioner

String org.turro.financials.handshake.HandshakeContract.petitioner

Definition at line 46 of file HandshakeContract.java.

◆ remoteId

long org.turro.financials.handshake.HandshakeContract.remoteId

Definition at line 47 of file HandshakeContract.java.

◆ remoteName

String org.turro.financials.handshake.HandshakeContract.remoteName

Definition at line 48 of file HandshakeContract.java.

◆ remoteServer

String org.turro.financials.handshake.HandshakeContract.remoteServer

Definition at line 49 of file HandshakeContract.java.


The documentation for this class was generated from the following file: