-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'aiccra-tip-integration' into aiccra-dev
- Loading branch information
Showing
14 changed files
with
739 additions
and
3 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/TipParametersDAO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
84 changes: 84 additions & 0 deletions
84
marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/TipParametersMySQLDAO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
|
||
} |
74 changes: 74 additions & 0 deletions
74
marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/TipParametersManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
|
||
} |
77 changes: 77 additions & 0 deletions
77
...-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/TipParametersManagerImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.