Search in sources :

Example 1 with Reference

use of org.asqatasun.entity.reference.Reference in project Asqatasun by Asqatasun.

the class ReferenceDAOImpl method retrieveByCode.

@Override
public Reference retrieveByCode(String code) {
    Query query = entityManager.createQuery("SELECT r FROM " + getEntityClass().getName() + " r WHERE r.code = :code");
    query.setParameter("code", code);
    return (Reference) query.getSingleResult();
}
Also used : Query(javax.persistence.Query) Reference(org.asqatasun.entity.reference.Reference)

Example 2 with Reference

use of org.asqatasun.entity.reference.Reference in project Asqatasun by Asqatasun.

the class TestDAOImplTest method testRetrieveAllByReferenceAndLevel.

public void testRetrieveAllByReferenceAndLevel() {
    Reference ref = referenceDAO.read(Long.valueOf(1));
    // bronze level ref 1
    Level level = levelDAO.read(Long.valueOf(1));
    assertEquals(7, testDAO.retrieveAllByReferenceAndLevel(ref, level).size());
    // silver level ref 1
    level = levelDAO.read(Long.valueOf(2));
    assertEquals(10, testDAO.retrieveAllByReferenceAndLevel(ref, level).size());
    // gold level ref 1
    level = levelDAO.read(Long.valueOf(3));
    assertEquals(10, testDAO.retrieveAllByReferenceAndLevel(ref, level).size());
    // gold level ref 2
    ref = referenceDAO.read(Long.valueOf(2));
    assertEquals(5, testDAO.retrieveAllByReferenceAndLevel(ref, level).size());
    // silver level ref 2
    level = levelDAO.read(Long.valueOf(2));
    assertEquals(5, testDAO.retrieveAllByReferenceAndLevel(ref, level).size());
    // bronze level ref 2
    level = levelDAO.read(Long.valueOf(1));
    assertEquals(3, testDAO.retrieveAllByReferenceAndLevel(ref, level).size());
}
Also used : Reference(org.asqatasun.entity.reference.Reference) Level(org.asqatasun.entity.reference.Level)

Example 3 with Reference

use of org.asqatasun.entity.reference.Reference in project Asqatasun by Asqatasun.

the class TestDAOImplTest method testRetrieveAll_Reference.

public void testRetrieveAll_Reference() {
    Reference ref = referenceDAO.read(Long.valueOf(1));
    assertEquals(10, testDAO.retrieveAll(ref).size());
    ref = referenceDAO.read(Long.valueOf(2));
    assertEquals(5, testDAO.retrieveAll(ref).size());
}
Also used : Reference(org.asqatasun.entity.reference.Reference)

Example 4 with Reference

use of org.asqatasun.entity.reference.Reference in project Asqatasun by Asqatasun.

the class ReferenceDataServiceImpl method getByCode.

@Override
public Reference getByCode(String code) {
    if (referenceMap.containsKey(code)) {
        return referenceMap.get(code);
    }
    Reference reference = ((ReferenceDAO) entityDao).retrieveByCode(code);
    referenceMap.put(code, reference);
    return reference;
}
Also used : ReferenceDAO(org.asqatasun.entity.dao.reference.ReferenceDAO) Reference(org.asqatasun.entity.reference.Reference)

Example 5 with Reference

use of org.asqatasun.entity.reference.Reference in project Asqatasun by Asqatasun.

the class TestDataServiceImpl method getTestListFromParamSet.

/**
     * The parameter set contains a unique parameter that combines the referential
     * and the level parameters.
     * This method extracts these parameters to retrieve the appropriate tests.
     *
     * @param paramSet
     * @return
     */
@Override
public List<Test> getTestListFromParamSet(Set<Parameter> paramSet) {
    Reference reference = null;
    Level level = null;
    for (Parameter param : paramSet) {
        String paramElemcode = param.getParameterElement().getParameterElementCode();
        if (paramElemcode.equals(levelParameterCode)) {
            String[] referentialAndLevel = param.getValue().split(";");
            reference = referenceDataService.getByCode(referentialAndLevel[0]);
            level = levelDataService.getByCode(referentialAndLevel[1]);
            break;
        }
    }
    List<Test> testList = getAllByReferenceAndLevel(reference, level);
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Retrieved " + testList.size() + " test for the referential " + reference.getLabel() + " and the level " + level.getLabel());
    }
    return testList;
}
Also used : Test(org.asqatasun.entity.reference.Test) Reference(org.asqatasun.entity.reference.Reference) Parameter(org.asqatasun.entity.parameterization.Parameter) Level(org.asqatasun.entity.reference.Level)

Aggregations

Reference (org.asqatasun.entity.reference.Reference)8 Level (org.asqatasun.entity.reference.Level)2 Test (org.asqatasun.entity.reference.Test)2 Secured (org.springframework.security.access.annotation.Secured)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Query (javax.persistence.Query)1 ReferenceDAO (org.asqatasun.entity.dao.reference.ReferenceDAO)1 Parameter (org.asqatasun.entity.parameterization.Parameter)1 Criterion (org.asqatasun.entity.reference.Criterion)1 Theme (org.asqatasun.entity.reference.Theme)1 ThemeDataService (org.asqatasun.entity.service.reference.ThemeDataService)1 ForbiddenPageException (org.asqatasun.webapp.exception.ForbiddenPageException)1