Skip to content

Commit

Permalink
Merge branch 'aiccra-tip-integration' into aiccra-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjitm committed Nov 28, 2023
2 parents 839471b + ad47703 commit 17bf953
Show file tree
Hide file tree
Showing 14 changed files with 739 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*****************************************************************
* This file is part of Managing Agricultural Research for Learning &
* Outcomes Platform (MARLO).
* MARLO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
* MARLO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with MARLO. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************/


package org.cgiar.ccafs.marlo.data.dao;

import org.cgiar.ccafs.marlo.data.model.TipParameters;

import java.util.List;


public interface TipParametersDAO {

/**
* This method removes a specific tipParameters value from the database.
*
* @param tipParametersId is the tipParameters identifier.
* @return true if the tipParameters was successfully deleted, false otherwise.
*/
public void deleteTipParameters(long tipParametersId);

/**
* This method validate if the tipParameters identify with the given id exists in the system.
*
* @param tipParametersID is a tipParameters identifier.
* @return true if the tipParameters exists, false otherwise.
*/
public boolean existTipParameters(long tipParametersID);

/**
* This method gets a tipParameters object by a given tipParameters identifier.
*
* @param tipParametersID is the tipParameters identifier.
* @return a TipParameters object.
*/
public TipParameters find(long id);

/**
* This method gets a list of tipParameters that are active
*
* @return a list from TipParameters null if no exist records
*/
public List<TipParameters> findAll();


/**
* This method saves the information of the given tipParameters
*
* @param tipParameters - is the tipParameters object with the new information to be added/updated.
* @return a number greater than 0 representing the new ID assigned by the database, 0 if the tipParameters was
* updated
* or -1 is some error occurred.
*/
public TipParameters save(TipParameters tipParameters);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*****************************************************************
* This file is part of Managing Agricultural Research for Learning &
* Outcomes Platform (MARLO).
* MARLO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
* MARLO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with MARLO. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************/


package org.cgiar.ccafs.marlo.data.dao.mysql;

import org.cgiar.ccafs.marlo.data.dao.TipParametersDAO;
import org.cgiar.ccafs.marlo.data.model.TipParameters;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

import org.hibernate.SessionFactory;

@Named
public class TipParametersMySQLDAO extends AbstractMarloDAO<TipParameters, Long> implements TipParametersDAO {


@Inject
public TipParametersMySQLDAO(SessionFactory sessionFactory) {
super(sessionFactory);
}

@Override
public void deleteTipParameters(long tipParametersId) {
TipParameters tipParameters = this.find(tipParametersId);
this.delete(tipParameters);
}

@Override
public boolean existTipParameters(long tipParametersID) {
TipParameters tipParameters = this.find(tipParametersID);
if (tipParameters == null) {
return false;
}
return true;

}

@Override
public TipParameters find(long id) {
return super.find(TipParameters.class, id);

}

@Override
public List<TipParameters> findAll() {
String query = "from " + TipParameters.class.getName();
List<TipParameters> list = super.findAll(query);
if (!list.isEmpty()) {
return list;
}
return null;

}

@Override
public TipParameters save(TipParameters tipParameters) {
if (tipParameters.getId() == null) {
super.saveEntity(tipParameters);
} else {
tipParameters = super.update(tipParameters);
}


return tipParameters;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*****************************************************************
* This file is part of Managing Agricultural Research for Learning &
* Outcomes Platform (MARLO).
* MARLO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
* MARLO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with MARLO. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************/
package org.cgiar.ccafs.marlo.data.manager;

import org.cgiar.ccafs.marlo.data.model.TipParameters;

import java.util.List;


/**
* @author CCAFS
*/

public interface TipParametersManager {


/**
* This method removes a specific tipParameters value from the database.
*
* @param tipParametersId is the tipParameters identifier.
* @return true if the tipParameters was successfully deleted, false otherwise.
*/
public void deleteTipParameters(long tipParametersId);


/**
* This method validate if the tipParameters identify with the given id exists in the system.
*
* @param tipParametersID is a tipParameters identifier.
* @return true if the tipParameters exists, false otherwise.
*/
public boolean existTipParameters(long tipParametersID);


/**
* This method gets a list of tipParameters that are active
*
* @return a list from TipParameters null if no exist records
*/
public List<TipParameters> findAll();


/**
* This method gets a tipParameters object by a given tipParameters identifier.
*
* @param tipParametersID is the tipParameters identifier.
* @return a TipParameters object.
*/
public TipParameters getTipParametersById(long tipParametersID);

/**
* This method saves the information of the given tipParameters
*
* @param tipParameters - is the tipParameters object with the new information to be added/updated.
* @return a number greater than 0 representing the new ID assigned by the database, 0 if the tipParameters was
* updated
* or -1 is some error occurred.
*/
public TipParameters saveTipParameters(TipParameters tipParameters);


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*****************************************************************
* This file is part of Managing Agricultural Research for Learning &
* Outcomes Platform (MARLO).
* MARLO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
* MARLO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with MARLO. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************/
package org.cgiar.ccafs.marlo.data.manager.impl;


import org.cgiar.ccafs.marlo.data.dao.TipParametersDAO;
import org.cgiar.ccafs.marlo.data.manager.TipParametersManager;
import org.cgiar.ccafs.marlo.data.model.TipParameters;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

/**
* @author CCAFS
*/
@Named
public class TipParametersManagerImpl implements TipParametersManager {


private TipParametersDAO tipParametersDAO;
// Managers


@Inject
public TipParametersManagerImpl(TipParametersDAO tipParametersDAO) {
this.tipParametersDAO = tipParametersDAO;


}

@Override
public void deleteTipParameters(long tipParametersId) {

tipParametersDAO.deleteTipParameters(tipParametersId);
}

@Override
public boolean existTipParameters(long tipParametersID) {

return tipParametersDAO.existTipParameters(tipParametersID);
}

@Override
public List<TipParameters> findAll() {

return tipParametersDAO.findAll();

}

@Override
public TipParameters getTipParametersById(long tipParametersID) {

return tipParametersDAO.find(tipParametersID);
}

@Override
public TipParameters saveTipParameters(TipParameters tipParameters) {

return tipParametersDAO.save(tipParameters);
}


}
Loading

0 comments on commit 17bf953

Please sign in to comment.