Search in sources :

Example 41 with Contract

use of org.asqatasun.webapp.entity.contract.Contract in project Asqatasun by Asqatasun.

the class ContractDAOImplTest method testSaveOrUpdate.

/**
     * Test of saveOrUpdate method, of class ContractDAOImpl.
     */
public void testSaveOrUpdate() {
    System.out.println("saveOrUpdate");
    Date beginDate = new Date();
    Date endDate = new Date();
    Date renewalDate = new Date();
    int nbOfContract = contractDAO.findAll().size();
    Set<Functionality> functionalitySet = new HashSet<Functionality>();
    Set<OptionElement> optionElementSet = new HashSet<OptionElement>();
    Set<Referential> referenceSet = new HashSet<Referential>();
    Set<Scenario> scenarioSet = new HashSet<Scenario>();
    Contract contract = contractFactory.createContract("Contract-test", beginDate, endDate, renewalDate, Float.valueOf(200), functionalitySet, optionElementSet, referenceSet, scenarioSet, null);
    contractDAO.saveOrUpdate(contract);
    assertEquals(nbOfContract + 1, contractDAO.findAll().size());
}
Also used : Referential(org.asqatasun.webapp.entity.referential.Referential) Functionality(org.asqatasun.webapp.entity.functionality.Functionality) OptionElement(org.asqatasun.webapp.entity.option.OptionElement) Contract(org.asqatasun.webapp.entity.contract.Contract) Date(java.util.Date) HashSet(java.util.HashSet) Scenario(org.asqatasun.webapp.entity.scenario.Scenario)

Example 42 with Contract

use of org.asqatasun.webapp.entity.contract.Contract in project Asqatasun by Asqatasun.

the class ActDAOImplTest method testFindRunningActsByContract.

/**
     * Test of findRunningActsByContract method, of class ContractDAOImpl.
     */
public void testFindRunningActsByContract() {
    System.out.println("findRunningActsByContract");
    Contract contract = contractDAO.read((Long.valueOf(1)));
    assertEquals(1, actDAO.findRunningActsByContract(contract).size());
    assertEquals(Long.valueOf(3), actDAO.findRunningActsByContract(contract).iterator().next().getId());
    contract = contractDAO.read((Long.valueOf(2)));
    assertEquals(3, actDAO.findRunningActsByContract(contract).size());
}
Also used : Contract(org.asqatasun.webapp.entity.contract.Contract)

Example 43 with Contract

use of org.asqatasun.webapp.entity.contract.Contract in project Asqatasun by Asqatasun.

the class ContractDAOImpl method read.

@Override
public Contract read(Long id) {
    try {
        Query query = entityManager.createQuery("SELECT c FROM " + getEntityClass().getName() + " c" + " LEFT JOIN FETCH c.optionElementSet o" + " LEFT JOIN FETCH c.functionalitySet f" + " LEFT JOIN FETCH c.referentialSet f" + " LEFT JOIN FETCH c.scenarioSet f" + " WHERE c.id = :id");
        query.setParameter("id", id);
        Contract contract = (Contract) query.getSingleResult();
        // to ensure the options associated with the contract is 
        // retrieved
        contract.getOptionElementSet().size();
        contract.getFunctionalitySet().size();
        contract.getScenarioSet().size();
        contract.getReferentialSet().size();
        return contract;
    } catch (NoResultException nre) {
        return null;
    }
}
Also used : Query(javax.persistence.Query) NoResultException(javax.persistence.NoResultException) Contract(org.asqatasun.webapp.entity.contract.Contract)

Aggregations

Contract (org.asqatasun.webapp.entity.contract.Contract)43 Secured (org.springframework.security.access.annotation.Secured)17 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)17 ForbiddenUserException (org.asqatasun.webapp.exception.ForbiddenUserException)15 ForbiddenPageException (org.asqatasun.webapp.exception.ForbiddenPageException)12 Audit (org.asqatasun.entity.audit.Audit)5 User (org.asqatasun.webapp.entity.user.User)5 List (java.util.List)4 Scenario (org.asqatasun.webapp.entity.scenario.Scenario)4 Date (java.util.Date)3 HashSet (java.util.HashSet)3 Site (org.asqatasun.entity.subject.Site)3 WebResource (org.asqatasun.entity.subject.WebResource)3 Functionality (org.asqatasun.webapp.entity.functionality.Functionality)3 AuditResultSortCommand (org.asqatasun.webapp.command.AuditResultSortCommand)2 AuditSetUpFormValidator (org.asqatasun.webapp.validator.AuditSetUpFormValidator)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 DateFormat (java.text.DateFormat)1 ParseException (java.text.ParseException)1