Skip to content

Commit

Permalink
Create deliverable crp outcome table (#2415)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjitm committed May 10, 2022
1 parent 253bcb7 commit aed7ef5
Show file tree
Hide file tree
Showing 11 changed files with 518 additions and 26 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.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);
}
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;
}


}
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);


}
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);
}


}
Loading

0 comments on commit aed7ef5

Please sign in to comment.