Search in sources :

Example 1 with Functionality

use of org.asqatasun.webapp.entity.functionality.Functionality in project Asqatasun by Asqatasun.

the class CreateContractCommandFactory method addFunctionalityToCommand.

/**
     * 
     */
private void addFunctionalityToCommand(CreateContractCommand ccc, Contract contract) {
    Map<String, Boolean> functMap = new LinkedHashMap<String, Boolean>();
    for (Functionality funct : this.functionalityList) {
        if (contract.getFunctionalitySet().contains(funct)) {
            functMap.put(funct.getCode(), Boolean.TRUE);
        } else {
            functMap.put(funct.getCode(), Boolean.FALSE);
        }
    }
    ccc.setFunctionalityMap(functMap);
}
Also used : Functionality(org.asqatasun.webapp.entity.functionality.Functionality)

Example 2 with Functionality

use of org.asqatasun.webapp.entity.functionality.Functionality in project Asqatasun by Asqatasun.

the class ContractActionHandlerImpl method getActionList.

@Override
public synchronized List<Action> getActionList(Object object) {
    if (!(object instanceof Contract)) {
        return null;
    }
    List<Action> userContractActionList = getActionList();
    Collection<Functionality> functionalitySet = ((Contract) object).getFunctionalitySet();
    for (Action action : userContractActionList) {
        activateAction(action, functionalitySet);
    }
    return userContractActionList;
}
Also used : Action(org.asqatasun.webapp.action.Action) Functionality(org.asqatasun.webapp.entity.functionality.Functionality) Contract(org.asqatasun.webapp.entity.contract.Contract)

Example 3 with Functionality

use of org.asqatasun.webapp.entity.functionality.Functionality in project Asqatasun by Asqatasun.

the class CreateContractCommandFactory method addNewFunctionalityToCommand.

/**
     * 
     * @param ccc 
     */
private void addNewFunctionalityToCommand(CreateContractCommand ccc) {
    Map<String, Boolean> functMap = new LinkedHashMap<String, Boolean>();
    for (Functionality funct : this.functionalityList) {
        functMap.put(funct.getCode(), Boolean.FALSE);
    }
    ccc.setFunctionalityMap(functMap);
}
Also used : Functionality(org.asqatasun.webapp.entity.functionality.Functionality)

Example 4 with Functionality

use of org.asqatasun.webapp.entity.functionality.Functionality in project Asqatasun by Asqatasun.

the class ContractDAOImplTest method testRead.

/**
     * Test of read method, of class ContractDAOImpl.
     */
public void testRead() {
    System.out.println("read");
    Contract contract = contractDAO.read(Long.valueOf(1));
    assertNotNull(contract);
    assertEquals("http://www.contract1.com/", contractDataService.getUrlFromContractOption(contract));
    assertEquals(Long.valueOf("1"), contract.getUser().getId());
    Set<String> functionalityCodeSet = new HashSet<String>();
    for (Functionality functionality : contract.getFunctionalitySet()) {
        functionalityCodeSet.add(functionality.getCode());
    }
    assertTrue(functionalityCodeSet.contains("PAGES_AUDIT"));
    assertTrue(!functionalityCodeSet.contains("SITE_AUDIT"));
    assertEquals(1, contract.getReferentialSet().size());
    assertTrue(contract.getScenarioSet().isEmpty());
    contract = contractDAO.read(Long.valueOf(2));
    assertNotNull(contract);
    assertEquals("http://www.contract2.com/", contractDataService.getUrlFromContractOption(contract));
    assertEquals(Long.valueOf("1"), contract.getUser().getId());
    functionalityCodeSet = new HashSet<String>();
    for (Functionality functionality : contract.getFunctionalitySet()) {
        functionalityCodeSet.add(functionality.getCode());
    }
    assertTrue(functionalityCodeSet.contains("PAGES_AUDIT"));
    assertTrue(functionalityCodeSet.contains("SITE_AUDIT"));
    assertEquals(2, contract.getReferentialSet().size());
    assertEquals(2, contract.getScenarioSet().size());
    contract = contractDAO.read(Long.valueOf(3));
    assertNull(contract);
}
Also used : Functionality(org.asqatasun.webapp.entity.functionality.Functionality) Contract(org.asqatasun.webapp.entity.contract.Contract) HashSet(java.util.HashSet)

Example 5 with Functionality

use of org.asqatasun.webapp.entity.functionality.Functionality 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)

Aggregations

Functionality (org.asqatasun.webapp.entity.functionality.Functionality)6 Contract (org.asqatasun.webapp.entity.contract.Contract)3 HashSet (java.util.HashSet)2 Date (java.util.Date)1 Action (org.asqatasun.webapp.action.Action)1 OptionElement (org.asqatasun.webapp.entity.option.OptionElement)1 Referential (org.asqatasun.webapp.entity.referential.Referential)1 Scenario (org.asqatasun.webapp.entity.scenario.Scenario)1