Author: apevec
Date: 2006-06-13 21:30:12 +0200 (Tue, 13 Jun 2006)
New Revision: 1159
Modified:
trunk/ccm-ldn-aplaws/src/com/arsdigita/aplaws/AutoCategorisation.java
Log:
fix DublinCoreItem NPE
ignore case in findTerm
Modified: trunk/ccm-ldn-aplaws/src/com/arsdigita/aplaws/AutoCategorisation.java
===================================================================
--- trunk/ccm-ldn-aplaws/src/com/arsdigita/aplaws/AutoCategorisation.java 2006-06-13 16:42:30 UTC (rev 1158)
+++ trunk/ccm-ldn-aplaws/src/com/arsdigita/aplaws/AutoCategorisation.java 2006-06-13 19:30:12 UTC (rev 1159)
@@ -450,17 +450,17 @@
}
private void assignKeywords() {
- if (item != null) {
+ if (item != null && !keywords.isEmpty()) {
DublinCoreItem dcItem = DublinCoreItem.findByOwner(item);
- // append into dcItem.getKeywords()
- // NOTE: "DC keywords" metadata is stored as a string, cannot tell which keywords are auto.
- // To support that, datamodel change to 1:N mapping table would be required.
- String dcKeywords = dcItem.getKeywords();
- if (dcKeywords != null) {
- StringTokenizer tok = new StringTokenizer(dcKeywords, ";");
- // merge old "DC keywords" into set of new ones
- while (tok.hasMoreTokens()) {
- keywords.add(tok.nextToken().trim());
+ if (dcItem != null) {
+ // preserve existing dcItem.getKeywords()
+ // NOTE: "DC keywords" metadata is stored as a string, cannot tell which keywords are auto.
+ String dcKeywords = dcItem.getKeywords();
+ if (dcKeywords != null) {
+ StringTokenizer tok = new StringTokenizer(dcKeywords, ";");
+ while (tok.hasMoreTokens()) {
+ keywords.add(tok.nextToken().trim());
+ }
}
}
StringBuffer buf = new StringBuffer();
@@ -470,13 +470,16 @@
buf.append(i.next());
}
for (; i.hasNext();) {
- buf.append(' ').append(';').append(i.next());
+ buf.append(';').append(' ').append(i.next());
}
- dcKeywords = buf.toString();
+ String dcKeywords = buf.toString();
if (isVerbose) {
out("ASSIGN DC keywords \""+dcKeywords+"\"");
}
if (persistChanges) {
+ if (dcItem == null) {
+ dcItem = DublinCoreItem.create(item);
+ }
dcItem.setKeywords(dcKeywords);
}
}
@@ -487,7 +490,8 @@
Domain domain = Domain.retrieve(domainKey);
if (domain != null) {
DomainCollection terms = domain.getTerms();
- terms.addEqualsFilter(Term.NAME, name);
+ Filter f = terms.addFilter("upper(Term.NAME) = :name");
+ f.set("name", name.toUpperCase());
if (terms.next()) {
Term term = (Term) terms.getDomainObject();
terms.close();
|