-
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.
Create deliverable crp outcome table (#2415)
- Loading branch information
Showing
11 changed files
with
518 additions
and
26 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/DeliverableCrpOutcomeDAO.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.DeliverableCrpOutcome; | ||
|
||
import java.util.List; | ||
|
||
|
||
public interface DeliverableCrpOutcomeDAO { | ||
|
||
/** | ||
* This method removes a specific deliverableCrpOutcome value from the database. | ||
* | ||
* @param deliverableCrpOutcomeId is the deliverableCrpOutcome identifier. | ||
* @return true if the deliverableCrpOutcome was successfully deleted, false otherwise. | ||
*/ | ||
public void deleteDeliverableCrpOutcome(long deliverableCrpOutcomeId); | ||
|
||
/** | ||
* This method validate if the deliverableCrpOutcome identify with the given id exists in the system. | ||
* | ||
* @param deliverableCrpOutcomeID is a deliverableCrpOutcome identifier. | ||
* @return true if the deliverableCrpOutcome exists, false otherwise. | ||
*/ | ||
public boolean existDeliverableCrpOutcome(long deliverableCrpOutcomeID); | ||
|
||
/** | ||
* This method gets a deliverableCrpOutcome object by a given deliverableCrpOutcome identifier. | ||
* | ||
* @param deliverableCrpOutcomeID is the deliverableCrpOutcome identifier. | ||
* @return a DeliverableCrpOutcome object. | ||
*/ | ||
public DeliverableCrpOutcome find(long id); | ||
|
||
/** | ||
* This method gets a list of deliverableCrpOutcome that are active | ||
* | ||
* @return a list from DeliverableCrpOutcome null if no exist records | ||
*/ | ||
public List<DeliverableCrpOutcome> findAll(); | ||
|
||
|
||
/** | ||
* This method saves the information of the given deliverableCrpOutcome | ||
* | ||
* @param deliverableCrpOutcome - is the deliverableCrpOutcome 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 deliverableCrpOutcome was | ||
* updated | ||
* or -1 is some error occurred. | ||
*/ | ||
public DeliverableCrpOutcome save(DeliverableCrpOutcome deliverableCrpOutcome); | ||
} |
85 changes: 85 additions & 0 deletions
85
...ata/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableCrpOutcomeMySQLDAO.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,85 @@ | ||
/***************************************************************** | ||
* 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.DeliverableCrpOutcomeDAO; | ||
import org.cgiar.ccafs.marlo.data.model.DeliverableCrpOutcome; | ||
|
||
import java.util.List; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
|
||
import org.hibernate.SessionFactory; | ||
|
||
@Named | ||
public class DeliverableCrpOutcomeMySQLDAO extends AbstractMarloDAO<DeliverableCrpOutcome, Long> | ||
implements DeliverableCrpOutcomeDAO { | ||
|
||
|
||
@Inject | ||
public DeliverableCrpOutcomeMySQLDAO(SessionFactory sessionFactory) { | ||
super(sessionFactory); | ||
} | ||
|
||
@Override | ||
public void deleteDeliverableCrpOutcome(long deliverableCrpOutcomeId) { | ||
DeliverableCrpOutcome deliverableCrpOutcome = this.find(deliverableCrpOutcomeId); | ||
this.delete(deliverableCrpOutcome); | ||
} | ||
|
||
@Override | ||
public boolean existDeliverableCrpOutcome(long deliverableCrpOutcomeID) { | ||
DeliverableCrpOutcome deliverableCrpOutcome = this.find(deliverableCrpOutcomeID); | ||
if (deliverableCrpOutcome == null) { | ||
return false; | ||
} | ||
return true; | ||
|
||
} | ||
|
||
@Override | ||
public DeliverableCrpOutcome find(long id) { | ||
return super.find(DeliverableCrpOutcome.class, id); | ||
|
||
} | ||
|
||
@Override | ||
public List<DeliverableCrpOutcome> findAll() { | ||
String query = "from " + DeliverableCrpOutcome.class.getName(); | ||
List<DeliverableCrpOutcome> list = super.findAll(query); | ||
if (list.size() > 0) { | ||
return list; | ||
} | ||
return null; | ||
|
||
} | ||
|
||
@Override | ||
public DeliverableCrpOutcome save(DeliverableCrpOutcome deliverableCrpOutcome) { | ||
if (deliverableCrpOutcome.getId() == null) { | ||
super.saveEntity(deliverableCrpOutcome); | ||
} else { | ||
deliverableCrpOutcome = super.update(deliverableCrpOutcome); | ||
} | ||
|
||
|
||
return deliverableCrpOutcome; | ||
} | ||
|
||
|
||
} |
74 changes: 74 additions & 0 deletions
74
...o-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableCrpOutcomeManager.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.DeliverableCrpOutcome; | ||
|
||
import java.util.List; | ||
|
||
|
||
/** | ||
* @author CCAFS | ||
*/ | ||
|
||
public interface DeliverableCrpOutcomeManager { | ||
|
||
|
||
/** | ||
* This method removes a specific deliverableCrpOutcome value from the database. | ||
* | ||
* @param deliverableCrpOutcomeId is the deliverableCrpOutcome identifier. | ||
* @return true if the deliverableCrpOutcome was successfully deleted, false otherwise. | ||
*/ | ||
public void deleteDeliverableCrpOutcome(long deliverableCrpOutcomeId); | ||
|
||
|
||
/** | ||
* This method validate if the deliverableCrpOutcome identify with the given id exists in the system. | ||
* | ||
* @param deliverableCrpOutcomeID is a deliverableCrpOutcome identifier. | ||
* @return true if the deliverableCrpOutcome exists, false otherwise. | ||
*/ | ||
public boolean existDeliverableCrpOutcome(long deliverableCrpOutcomeID); | ||
|
||
|
||
/** | ||
* This method gets a list of deliverableCrpOutcome that are active | ||
* | ||
* @return a list from DeliverableCrpOutcome null if no exist records | ||
*/ | ||
public List<DeliverableCrpOutcome> findAll(); | ||
|
||
|
||
/** | ||
* This method gets a deliverableCrpOutcome object by a given deliverableCrpOutcome identifier. | ||
* | ||
* @param deliverableCrpOutcomeID is the deliverableCrpOutcome identifier. | ||
* @return a DeliverableCrpOutcome object. | ||
*/ | ||
public DeliverableCrpOutcome getDeliverableCrpOutcomeById(long deliverableCrpOutcomeID); | ||
|
||
/** | ||
* This method saves the information of the given deliverableCrpOutcome | ||
* | ||
* @param deliverableCrpOutcome - is the deliverableCrpOutcome 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 deliverableCrpOutcome was | ||
* updated | ||
* or -1 is some error occurred. | ||
*/ | ||
public DeliverableCrpOutcome saveDeliverableCrpOutcome(DeliverableCrpOutcome deliverableCrpOutcome); | ||
|
||
|
||
} |
77 changes: 77 additions & 0 deletions
77
...c/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableCrpOutcomeManagerImpl.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.DeliverableCrpOutcomeDAO; | ||
import org.cgiar.ccafs.marlo.data.manager.DeliverableCrpOutcomeManager; | ||
import org.cgiar.ccafs.marlo.data.model.DeliverableCrpOutcome; | ||
|
||
import java.util.List; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
|
||
/** | ||
* @author CCAFS | ||
*/ | ||
@Named | ||
public class DeliverableCrpOutcomeManagerImpl implements DeliverableCrpOutcomeManager { | ||
|
||
|
||
private DeliverableCrpOutcomeDAO deliverableCrpOutcomeDAO; | ||
// Managers | ||
|
||
|
||
@Inject | ||
public DeliverableCrpOutcomeManagerImpl(DeliverableCrpOutcomeDAO deliverableCrpOutcomeDAO) { | ||
this.deliverableCrpOutcomeDAO = deliverableCrpOutcomeDAO; | ||
|
||
|
||
} | ||
|
||
@Override | ||
public void deleteDeliverableCrpOutcome(long deliverableCrpOutcomeId) { | ||
|
||
deliverableCrpOutcomeDAO.deleteDeliverableCrpOutcome(deliverableCrpOutcomeId); | ||
} | ||
|
||
@Override | ||
public boolean existDeliverableCrpOutcome(long deliverableCrpOutcomeID) { | ||
|
||
return deliverableCrpOutcomeDAO.existDeliverableCrpOutcome(deliverableCrpOutcomeID); | ||
} | ||
|
||
@Override | ||
public List<DeliverableCrpOutcome> findAll() { | ||
|
||
return deliverableCrpOutcomeDAO.findAll(); | ||
|
||
} | ||
|
||
@Override | ||
public DeliverableCrpOutcome getDeliverableCrpOutcomeById(long deliverableCrpOutcomeID) { | ||
|
||
return deliverableCrpOutcomeDAO.find(deliverableCrpOutcomeID); | ||
} | ||
|
||
@Override | ||
public DeliverableCrpOutcome saveDeliverableCrpOutcome(DeliverableCrpOutcome deliverableCrpOutcome) { | ||
|
||
return deliverableCrpOutcomeDAO.save(deliverableCrpOutcome); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.