Search in sources :

Example 1 with PreProcessResult

use of org.asqatasun.entity.audit.PreProcessResult in project Asqatasun by Asqatasun.

the class PreProcessResultDAOImpl method deleteAllPreProcessResultByAudit.

@Override
public void deleteAllPreProcessResultByAudit(Audit audit) {
    Query query = entityManager.createQuery("SELECT ppr FROM " + getEntityClass().getName() + " ppr " + " WHERE " + " ppr.audit = :audit");
    query.setParameter("audit", audit);
    Set<PreProcessResult> pprToDelete = new HashSet<PreProcessResult>();
    pprToDelete.addAll(query.getResultList());
    for (PreProcessResult ppr : pprToDelete) {
        this.delete(ppr.getId());
    }
}
Also used : Query(javax.persistence.Query) PreProcessResult(org.asqatasun.entity.audit.PreProcessResult) HashSet(java.util.HashSet)

Example 2 with PreProcessResult

use of org.asqatasun.entity.audit.PreProcessResult in project Asqatasun by Asqatasun.

the class PreProcessResultDAOImpl method deleteAllPreProcessResultByWebResource.

@Override
public void deleteAllPreProcessResultByWebResource(WebResource webResource) {
    Query query = entityManager.createQuery("SELECT ppr FROM " + getEntityClass().getName() + " ppr " + " WHERE " + " ppr.subject = :webResource");
    query.setParameter("webResource", webResource);
    Set<PreProcessResult> pprToDelete = new HashSet<PreProcessResult>();
    pprToDelete.addAll(query.getResultList());
    this.delete(pprToDelete);
}
Also used : Query(javax.persistence.Query) PreProcessResult(org.asqatasun.entity.audit.PreProcessResult) HashSet(java.util.HashSet)

Example 3 with PreProcessResult

use of org.asqatasun.entity.audit.PreProcessResult in project Asqatasun by Asqatasun.

the class PreProcessResultFactoryImpl method create.

@Override
public PreProcessResult create(String key, String value, Audit audit, WebResource webResource) {
    PreProcessResult ppr = this.create();
    ppr.setKey(key);
    ppr.setValue(value);
    ppr.setAudit(audit);
    if (webResource != null) {
        ppr.setSubject(webResource);
    }
    return ppr;
}
Also used : PreProcessResult(org.asqatasun.entity.audit.PreProcessResult)

Example 4 with PreProcessResult

use of org.asqatasun.entity.audit.PreProcessResult in project Asqatasun by Asqatasun.

the class ScenarioLoaderImpl method fireNewSSP.

/**
     * 
     * @param url
     * @param sourceCode 
     */
private void fireNewSSP(String url, String sourceCode, byte[] snapshotContent, Map<String, String> jsScriptMap) {
    LOGGER.debug("fire New SSP " + url);
    if (StringUtils.isEmpty(sourceCode)) {
        LOGGER.debug("Emtpy SSP " + url + " not saved");
        return;
    }
    String charset = UFT8;
    try {
        charset = CrawlUtils.extractCharset(IOUtils.toInputStream(sourceCode));
    } catch (IOException ex) {
        Logger.getLogger(this.getClass()).warn(ex);
    }
    Page page = getWebResource(url);
    SSP ssp = contentDataService.getSSP(dateFactory.createDate(), url, sourceCode, page, HttpStatus.SC_OK);
    ssp.setCharset(charset);
    contentDataService.saveOrUpdate(ssp);
    result.add(ssp);
    //        if (snapshotContent != null) {
    //            Snapshot snapshot = snapshotFactory.create(
    //                    page, 
    //                    snapshotContent);
    //            snapshotDataService.saveOrUpdate(snapshot);
    //        }
    Audit audit = null;
    if (page.getAudit() != null) {
        audit = page.getAudit();
    } else if (page.getParent().getAudit() != null) {
        audit = page.getParent().getAudit();
    }
    for (Map.Entry<String, String> entry : jsScriptMap.entrySet()) {
        PreProcessResult ppr = preProcessResultDataService.getPreProcessResult(entry.getKey(), entry.getValue(), audit, page);
        preProcessResultDataService.saveOrUpdate(ppr);
    }
}
Also used : SSP(org.asqatasun.entity.audit.SSP) Audit(org.asqatasun.entity.audit.Audit) PreProcessResult(org.asqatasun.entity.audit.PreProcessResult) Page(org.asqatasun.entity.subject.Page) IOException(java.io.IOException) Map(java.util.Map)

Aggregations

PreProcessResult (org.asqatasun.entity.audit.PreProcessResult)4 HashSet (java.util.HashSet)2 Query (javax.persistence.Query)2 IOException (java.io.IOException)1 Map (java.util.Map)1 Audit (org.asqatasun.entity.audit.Audit)1 SSP (org.asqatasun.entity.audit.SSP)1 Page (org.asqatasun.entity.subject.Page)1