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());
}
}
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);
}
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;
}
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);
}
}
Aggregations