Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added some features and annotations #42

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
319 changes: 228 additions & 91 deletions src/main/java/com/seg83/childbank/dao/DepositAccountBillsDao.java

Large diffs are not rendered by default.

56 changes: 50 additions & 6 deletions src/main/java/com/seg83/childbank/dao/DepositAccountDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,32 @@

import java.util.List;


/**
* Data Access Object (DAO) for managing deposit account data.
* Extends {@link AbstractDao} to handle deposit account data in JSON format.
*/
@Repository
@Slf4j
public class DepositAccountDao extends AbstractDao {

private final AccountDao accountDao;

/**
* Constructor for DepositAccountDao.
*
* @param accountDao AccountDao instance for managing account data.
*/
@Autowired
public DepositAccountDao(AccountDao accountDao) {
this.accountDao = accountDao;
}

/**
* Load deposit account data in JSON format.
*
* @return JSONObject containing deposit account data.
*/
@Override
public JSONObject load() {
log.info("Request DepositAccountDao in JSON format");
Expand All @@ -27,6 +43,12 @@ public JSONObject load() {
return depositAccount;
}

/**
* Set an attribute of a deposit account.
*
* @param attrname Name of the attribute to set.
* @param value Value to set for the attribute.
*/
@Override
void setAttribute(String attrname, Object value) {
DepositAccount modifiedDepositAccount;
Expand All @@ -40,12 +62,24 @@ void setAttribute(String attrname, Object value) {
this.accountDao.setAttribute("depositAccount", modifiedDepositAccount);
}

/**
* Set the deposit account bills.
*
* @param value List of DepositAccountBills objects to set for the deposit account.
* @return DepositAccount object with the updated deposit account bills.
*/
private DepositAccount setDepositAccountBills(List<DepositAccountBills> value) {
DepositAccount depositAccount = this.load().toJavaObject(DepositAccount.class);
depositAccount.setDepositAccountBills(value);
return depositAccount;
}

/**
* Get an attribute of a deposit account.
*
* @param attrname Name of the attribute to get.
* @return Object containing the attribute value.
*/
@Override
public Object getAttribute(String attrname) {
return switch (attrname) {
Expand All @@ -54,16 +88,26 @@ public Object getAttribute(String attrname) {
};
}

private List<DepositAccountBills> getDepositAccount() {
log.info("Getting historyActions");
List<DepositAccountBills> depositAccountBills = this.load().getJSONArray("depositAccountBills").toJavaList(DepositAccountBills.class);
log.debug("Get depositAccountBills {}", depositAccountBills);
return depositAccountBills;
/**
* Get the deposit account.
*
* @return DepositAccount object containing the deposit account data.
*/
private DepositAccount getDepositAccount() {
log.info("Getting depositAccount");
JSONObject depositAccountData = accountDao.load().getJSONObject("depositAccount");
log.debug("Get depositAccount data {}", depositAccountData);
return depositAccountData.toJavaObject(DepositAccount.class);
}

// TODO implement
/**
* Get all attributes of a deposit account.
*
* @return List of Objects containing all attributes of a deposit account.
*/
@Override
List<Object> getAllAttributes() {
// TODO implement
return null;
}
}
47 changes: 45 additions & 2 deletions src/main/java/com/seg83/childbank/dao/GoalDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,45 @@

import java.util.List;

/**
* Data Access Object (DAO) for managing goal data.
* Extends {@link AbstractDao} to handle goal data in JSON format.
*/
@Repository
@Slf4j
public class GoalDao extends AbstractDao {

private DataWrapperDao dataWrapperDao;

/**
* Constructor for GoalDao.
*
* @param dataWrapperDao DataWrapperDao instance for managing data wrapper data.
*/
@Autowired
public GoalDao(DataWrapperDao dataWrapperDao) {
this.dataWrapperDao = dataWrapperDao;
}

/**
* Load goal data in JSON format.
*
* @return JSONObject containing goal data.
*/
@Override
JSONObject load() {
public JSONObject load() {
log.info("Request goal data in JSON format");
JSONObject goal = dataWrapperDao.load().getJSONObject("goal");
log.debug("Get goal data {}", goal);
return goal;
}

/**
* Set an attribute of a goal.
*
* @param attrname Name of the attribute to set.
* @param value Value to set for the attribute.
*/
@Override
public void setAttribute(String attrname, Object value) {
Goal modifiedGoal;
Expand All @@ -39,12 +60,24 @@ public void setAttribute(String attrname, Object value) {
dataWrapperDao.setAttribute("goal", modifiedGoal);
}

/**
* Set the goal amount.
*
* @param value Value to set for the goal amount.
* @return Goal object with the updated goal amount.
*/
private Goal setGoalAmount(double value) {
Goal goal = this.load().toJavaObject(Goal.class);
goal.setGoalAmount(value);
return goal;
}

/**
* Get an attribute of a goal.
*
* @param attrname Name of the attribute to get.
* @return Object containing the attribute value.
*/
@Override
public Object getAttribute(String attrname) {
return switch (attrname) {
Expand All @@ -53,15 +86,25 @@ public Object getAttribute(String attrname) {
};
}

/**
* Get the goal amount.
*
* @return Double containing the goal amount.
*/
private Double getGoalAmount() {
log.info("Get goal amount");
double goalAmount = this.load().getDouble("goalAmount");
log.debug("Goal amount is {}", goalAmount);
return goalAmount;
}

/**
* Get all attributes of a goal.
*
* @return List of Objects containing all attributes of a goal.
*/
@Override
List<Object> getAllAttributes() {
public List<Object> getAllAttributes() {
return List.of();
}
}
Expand Down
50 changes: 48 additions & 2 deletions src/main/java/com/seg83/childbank/dao/TaskDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,44 @@

import java.util.List;

/**
* Data Access Object (DAO) for managing task data.
*/
@Component
@Slf4j
public class TaskDao extends AbstractDao {
@Autowired

private DataWrapperDao dataWrapperDao;

/**
* Constructor for TaskDao.
*
* @param dataWrapperDao DataWrapperDao instance for managing data wrapper data.
*/
@Autowired
public TaskDao(DataWrapperDao dataWrapperDao) {
this.dataWrapperDao = dataWrapperDao;
}

/**
* Load task data in JSON format.
*
* @return JSONObject containing task data.
*/
@Override
JSONObject load() {
public JSONObject load() {
log.info("Request task data in JSON format");
JSONObject task = dataWrapperDao.load().getJSONObject("task");
log.debug("Get task data {}", task);
return task;
}

/**
* Set an attribute of a task.
*
* @param attrname Name of the attribute to set.
* @param value Value to set for the attribute.
*/
@Override
void setAttribute(String attrname, Object value) {
Task modifiedTask;
Expand All @@ -36,12 +60,24 @@ void setAttribute(String attrname, Object value) {
this.dataWrapperDao.setAttribute("task", modifiedTask);
}

/**
* Set the task list.
*
* @param value List of TaskList objects to set for the task.
* @return Task object with the updated task list.
*/
private Task setTaskList(List<TaskList> value) {
Task task = this.load().toJavaObject(Task.class);
task.setTaskList(value);
return task;
}

/**
* Get an attribute of a task.
*
* @param attrname Name of the attribute to get.
* @return Object containing the attribute value.
*/
@Override
public Object getAttribute(String attrname) {
return switch (attrname) {
Expand All @@ -50,10 +86,20 @@ public Object getAttribute(String attrname) {
};
}

/**
* Get the task list.
*
* @return List of TaskList objects containing the task list.
*/
private List<TaskList> getTaskList() {
return this.load().toJavaObject(Task.class).getTaskList();
}

/**
* Get all attributes of a task.
*
* @return List of Objects containing all attributes of a task.
*/
@Override
List<Object> getAllAttributes() {
return List.of();
Expand Down
Loading
Loading