Search in sources :

Example 46 with Parameter

use of org.asqatasun.entity.parameterization.Parameter in project Asqatasun by Asqatasun.

the class ParameterFactoryImpl method createParameter.

@Override
public Parameter createParameter(ParameterElement parameterElement, String value, Audit audit) {
    Parameter parameter = createParameter(parameterElement, value);
    audit.addParameter(parameter);
    return parameter;
}
Also used : Parameter(org.asqatasun.entity.parameterization.Parameter)

Example 47 with Parameter

use of org.asqatasun.entity.parameterization.Parameter in project Asqatasun by Asqatasun.

the class ParameterDAOImplTest method testFindDefaultParameter.

@Test
public void testFindDefaultParameter() {
    ParameterElement paramElement = parameterElementDAO.read(Long.valueOf(1));
    Parameter param = parameterDAO.findDefaultParameter(paramElement);
    assertEquals(Long.valueOf(1), param.getId());
    paramElement = parameterElementDAO.read(Long.valueOf(2));
    param = parameterDAO.findDefaultParameter(paramElement);
    assertEquals(Long.valueOf(5), param.getId());
}
Also used : Parameter(org.asqatasun.entity.parameterization.Parameter) ParameterElement(org.asqatasun.entity.parameterization.ParameterElement) Test(org.junit.Test)

Example 48 with Parameter

use of org.asqatasun.entity.parameterization.Parameter in project Asqatasun by Asqatasun.

the class ParameterDAOImplTest method testFindParameterSetFromAudit.

@Test
public void testFindParameterSetFromAudit() {
    Audit audit = auditDAO.read(Long.valueOf(1));
    Set<Parameter> paramSet = parameterDAO.findParameterSetFromAudit(audit);
    assertEquals(Integer.valueOf(2), Integer.valueOf(paramSet.size()));
    audit = auditDAO.read(Long.valueOf(2));
    paramSet = parameterDAO.findParameterSetFromAudit(audit);
    assertEquals(Integer.valueOf(2), Integer.valueOf(paramSet.size()));
    audit = auditDAO.read(Long.valueOf(3));
    paramSet = parameterDAO.findParameterSetFromAudit(audit);
    assertEquals(Integer.valueOf(2), Integer.valueOf(paramSet.size()));
    audit = auditDAO.read(Long.valueOf(4));
    paramSet = parameterDAO.findParameterSetFromAudit(audit);
    assertEquals(Integer.valueOf(2), Integer.valueOf(paramSet.size()));
    audit = auditDAO.read(Long.valueOf(5));
    paramSet = parameterDAO.findParameterSetFromAudit(audit);
    assertEquals(Integer.valueOf(0), Integer.valueOf(paramSet.size()));
}
Also used : Audit(org.asqatasun.entity.audit.Audit) Parameter(org.asqatasun.entity.parameterization.Parameter) Test(org.junit.Test)

Example 49 with Parameter

use of org.asqatasun.entity.parameterization.Parameter in project Asqatasun by Asqatasun.

the class ParameterDAOImplTest method testFindParameter.

@Test
public void testFindParameter() {
    ParameterElement paramElement = parameterElementDAO.read(Long.valueOf(1));
    Parameter param = parameterDAO.findParameter(paramElement, "0");
    assertNull(param);
    for (int i = 1; i < 5; i++) {
        param = parameterDAO.findParameter(paramElement, "Value" + i);
        assertEquals(i, param.getId().intValue());
    }
    paramElement = parameterElementDAO.read(Long.valueOf(2));
    param = parameterDAO.findParameter(paramElement, "4");
    assertNull(param);
    for (int i = 5; i < 9; i++) {
        param = parameterDAO.findParameter(paramElement, "Value" + i);
        assertEquals(i, param.getId().intValue());
    }
}
Also used : Parameter(org.asqatasun.entity.parameterization.Parameter) ParameterElement(org.asqatasun.entity.parameterization.ParameterElement) Test(org.junit.Test)

Example 50 with Parameter

use of org.asqatasun.entity.parameterization.Parameter in project Asqatasun by Asqatasun.

the class ParameterDAOImpl method findParameter.

@Override
public Parameter findParameter(ParameterElement parameterElement, String parameterValue) {
    Query query = entityManager.createQuery("SELECT p FROM " + getEntityClass().getName() + " p" + " WHERE p.parameterElement = :parameterElement" + " AND p.parameterValue = :parameterValue");
    query.setParameter("parameterElement", parameterElement);
    query.setParameter("parameterValue", parameterValue);
    try {
        return (Parameter) (query.getSingleResult());
    } catch (NoResultException nre) {
        return null;
    }
}
Also used : Query(javax.persistence.Query) Parameter(org.asqatasun.entity.parameterization.Parameter) NoResultException(javax.persistence.NoResultException)

Aggregations

Parameter (org.asqatasun.entity.parameterization.Parameter)59 ParameterElement (org.asqatasun.entity.parameterization.ParameterElement)13 Audit (org.asqatasun.entity.audit.Audit)8 ParameterImpl (org.asqatasun.entity.parameterization.ParameterImpl)6 NoResultException (javax.persistence.NoResultException)5 Query (javax.persistence.Query)5 HashSet (java.util.HashSet)4 AuditCommand (org.asqatasun.service.command.AuditCommand)4 AuditCommandFactory (org.asqatasun.service.command.factory.AuditCommandFactory)4 Test (org.junit.Test)4 File (java.io.File)3 IOException (java.io.IOException)3 Crawler (org.asqatasun.crawler.Crawler)3 ParameterElementImpl (org.asqatasun.entity.parameterization.ParameterElementImpl)3 LinkedHashSet (java.util.LinkedHashSet)2 ParameterFamily (org.asqatasun.entity.parameterization.ParameterFamily)2 WebResourceStatisticsDataService (org.asqatasun.entity.service.statistics.WebResourceStatisticsDataService)2 WebResourceStatisticsDataServiceImpl (org.asqatasun.entity.service.statistics.WebResourceStatisticsDataServiceImpl)2 WebResourceStatistics (org.asqatasun.entity.statistics.WebResourceStatistics)2 WebResourceStatisticsFactory (org.asqatasun.entity.statistics.factory.WebResourceStatisticsFactory)2