Buisness logic docs updated

This commit is contained in:
Filip Izydorczyk
2021-01-15 15:54:17 +01:00
parent 8d007c259f
commit 21983fe4f7
15 changed files with 325 additions and 143 deletions

View File

@ -2,6 +2,9 @@ package com.plannaplan.models;
import java.io.InputStream;
/**
* Config data copntainer to keep tours dates and stream of dasta to import
*/
public class ConfigData {
private TourData firstTour;
private TourData secondTour;

View File

@ -4,6 +4,9 @@ import java.util.HashMap;
import java.util.Iterator;
import org.apache.poi.ss.usermodel.Row;
/**
* Wrapper for data readed from file
*/
public class FileData {
private HashMap<String, Integer> keys;
@ -13,6 +16,7 @@ public class FileData {
* FileData
*
* @param keys this is a hashmap of String and Integer
*
* @param rows this is a iterator of rows.
*/
public FileData(HashMap<String, Integer> keys, Iterator<Row> rows) {
@ -31,6 +35,7 @@ public class FileData {
/*
* setRows
*
* @param rows set the rows to given function
*/
public void setRows(Iterator<Row> rows) {
@ -39,6 +44,7 @@ public class FileData {
/*
* getKeys
*
* @return keys
*/
public HashMap<String, Integer> getKeys() {
@ -47,6 +53,7 @@ public class FileData {
/*
* setKeys
*
* @param keys set the key is being a struck of hashmap (String, Integer)
*/
public void setKeys(HashMap<String, Integer> keys) {
@ -55,6 +62,7 @@ public class FileData {
/*
* getIndexOf
*
* @return index
*/
public int getIndexOf(String key) {

View File

@ -3,64 +3,92 @@ package com.plannaplan.models;
import com.plannaplan.entities.Assignment;
import com.plannaplan.entities.Exchange;
/**
* Match of users Exchange's to be performed
*/
public class MatchData {
private Exchange exchangeOne;
private Exchange exchangeTwo;
private Exchange exchangeOne;
private Exchange exchangeTwo;
public MatchData(Exchange exchangeOne, Exchange exchangeTwo) {
this.exchangeOne = exchangeOne;
this.exchangeTwo = exchangeTwo;
}
public Exchange getExchangeOne() {
return this.exchangeOne;
}
public Exchange getExchangeTwo() {
return this.exchangeTwo;
}
public Assignment getAssignmentTwo() {
return this.exchangeTwo.getOwnedAssignment();
}
public Assignment getAssignmentOne() {
return this.exchangeOne.getOwnedAssignment();
}
@Override
public int hashCode() {
return this.getAssignmentOne().hashCode() + this.getAssignmentTwo().hashCode();
}
@Override
public boolean equals(Object o) {
// If the object is compared with itself then return true
if (o == this) {
return true;
}
/*
* Check if o is an instance of Complex or not "null instanceof [type]" also
* returns false
/**
* create MatchData
*
* @param exchangeOne first Exchange of found match
* @param exchangeTwo second Exchange of found match
*/
if (!(o instanceof MatchData)) {
return false;
public MatchData(Exchange exchangeOne, Exchange exchangeTwo) {
this.exchangeOne = exchangeOne;
this.exchangeTwo = exchangeTwo;
}
// typecast o to Complex so that we can compare data members
MatchData c = (MatchData) o;
/**
* @return first Exchange
*/
public Exchange getExchangeOne() {
return this.exchangeOne;
}
// Compare the data members and return accordingly
return (this.getAssignmentOne().equals(c.getAssignmentOne()) && this.getAssignmentTwo().equals(c.getAssignmentTwo())) || (this.getAssignmentOne().equals(c.getAssignmentTwo()) && this.getAssignmentTwo().equals(c.getAssignmentOne()));
}
/**
* @return second Exchange
*/
public Exchange getExchangeTwo() {
return this.exchangeTwo;
}
public int compare(MatchData m1) {
return Long.compare(m1.getExchangesMsValue(), this.getExchangesMsValue());
}
/**
* @return second Exchange's owned assignmetn
*/
public Assignment getAssignmentTwo() {
return this.exchangeTwo.getOwnedAssignment();
}
public long getExchangesMsValue(){
return this.exchangeOne.getDataExchange().getTime() + this.exchangeTwo.getDataExchange().getTime();
}
/**
* @return first Exchange's owned assignmetn
*/
public Assignment getAssignmentOne() {
return this.exchangeOne.getOwnedAssignment();
}
@Override
public int hashCode() {
return this.getAssignmentOne().hashCode() + this.getAssignmentTwo().hashCode();
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof MatchData)) {
return false;
}
MatchData c = (MatchData) o;
return (this.getAssignmentOne().equals(c.getAssignmentOne())
&& this.getAssignmentTwo().equals(c.getAssignmentTwo()))
|| (this.getAssignmentOne().equals(c.getAssignmentTwo())
&& this.getAssignmentTwo().equals(c.getAssignmentOne()));
}
/**
* comparator for MatchData. It compare it by sum of both exchange's times. For
* example MatchData with Exchanges 11:00 and 12:00 will be less than with
* Exchanges 12:00 and 12:00
*
* @param m1 MatchData instance to compare to
* @return int <0 if m1 is "less than", 0 if it's equal and >0 otherwise
*/
public int compare(MatchData m1) {
return Long.compare(m1.getExchangesMsValue(), this.getExchangesMsValue());
}
/**
* @return sum of both exchanges java.sql.Timestanp::getTime"
*/
public long getExchangesMsValue() {
return this.exchangeOne.getDataExchange().getTime() + this.exchangeTwo.getDataExchange().getTime();
}
}

View File

@ -2,6 +2,9 @@ package com.plannaplan.models;
import java.sql.Date;
/**
* Container for Tours dates
*/
public class TourData {
private Date start;

View File

@ -11,18 +11,36 @@ public class UserApiResponse {
public UserApiResponse() {
}
/**
* @return user's Surname
*/
public String getSurname() {
return surname;
}
/**
* setter for name. Reson to have setters for this class is for case if there
* would be name and no surname or otherwise
*
* @param surname name to set that was obtained by api request
*/
public void setSurname(String surname) {
this.surname = surname;
}
/**
* @return user's Name
*/
public String getName() {
return name;
}
/**
* setter for surname. Reson to have setters for this class is for case if there
* would be name and no surname or otherwise
*
* @param surname name to set that was obtained by api request
*/
public void setName(String name) {
this.name = name;
}