public long getPublishedCount(String docType) { String statement = String.format(STATEMENT_GET_PUBLISHED_COUNT, docType); return (Long) query(statement).get(0).get("count"); }
private DocumentStatus findDocumentStatus(String docType, String uri, String sha1) { DocumentList match = db.getDocumentStatus(docType, uri); if (!match.isEmpty()) { Map entries = match.get(0); String oldHash = (String) entries.get(String.valueOf(DocumentAttributes.SHA1)); if (!(oldHash.equals(sha1)) || Boolean.FALSE.equals(entries.get(String.valueOf(DocumentAttributes.RENDERED)))) { return DocumentStatus.UPDATED; } else { return DocumentStatus.IDENTICAL; } } else { return DocumentStatus.NEW; } }
private boolean updateTemplateSignatureIfChanged(File templateFolder) { boolean templateSignatureChanged = false; DocumentList docs = this.getSignaturesForTemplates(); String currentTemplatesSignature; try { currentTemplatesSignature = FileUtil.sha1(templateFolder); } catch (Exception e) { currentTemplatesSignature = ""; } if (!docs.isEmpty()) { String sha1 = (String) docs.get(0).get(String.valueOf(DocumentAttributes.SHA1)); if (!sha1.equals(currentTemplatesSignature)) { this.updateSignatures(currentTemplatesSignature); templateSignatureChanged = true; } } else { // first computation of templates signature this.insertTemplatesSignature(currentTemplatesSignature); templateSignatureChanged = true; } return templateSignatureChanged; }
@Test public void testMergeDocument() { final String uri = "test/testMergeDocument"; ODocument doc = new ODocument(DOC_TYPE_POST); Map<String, String> values = new HashMap(); values.put(Crawler.Attributes.TYPE, DOC_TYPE_POST); values.put(DocumentAttributes.SOURCE_URI.toString(), uri); values.put("foo", "originalValue"); doc.fromMap(values); doc.save(); // 1st values.put("foo", "newValue"); db.mergeDocument(values); DocumentList docs = db.getDocumentByUri(DOC_TYPE_POST, uri); assertEquals(1, docs.size()); assertEquals("newValue", docs.get(0).get("foo")); // 2nd values.put("foo", "anotherValue"); db.mergeDocument(values); docs = db.getDocumentByUri(DOC_TYPE_POST, uri); assertEquals(1, docs.size()); assertEquals("anotherValue", docs.get(0).get("foo")); db.deleteContent(DOC_TYPE_POST, uri); docs = db.getDocumentByUri(DOC_TYPE_POST, uri); assertEquals(0, docs.size()); }
public long getPublishedCount(String docType) { String statement = String.format(STATEMENT_GET_PUBLISHED_COUNT, docType); return (Long) query(statement).get(0).get("count"); }
private DocumentStatus findDocumentStatus(String docType, String uri, String sha1) { DocumentList match = db.getDocumentStatus(docType, uri); if (!match.isEmpty()) { Map entries = match.get(0); String oldHash = (String) entries.get(String.valueOf(DocumentAttributes.SHA1)); if (!(oldHash.equals(sha1)) || Boolean.FALSE.equals(entries.get(String.valueOf(DocumentAttributes.RENDERED)))) { return DocumentStatus.UPDATED; } else { return DocumentStatus.IDENTICAL; } } else { return DocumentStatus.NEW; } }
private boolean updateTemplateSignatureIfChanged(File templateFolder) { boolean templateSignatureChanged = false; DocumentList docs = this.getSignaturesForTemplates(); String currentTemplatesSignature; try { currentTemplatesSignature = FileUtil.sha1(templateFolder); } catch (Exception e) { currentTemplatesSignature = ""; } if (!docs.isEmpty()) { String sha1 = (String) docs.get(0).get(String.valueOf(DocumentAttributes.SHA1)); if (!sha1.equals(currentTemplatesSignature)) { this.updateSignatures(currentTemplatesSignature); templateSignatureChanged = true; } } else { // first computation of templates signature this.insertTemplatesSignature(currentTemplatesSignature); templateSignatureChanged = true; } return templateSignatureChanged; }