+/*
+ * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.argeo.slc.jcr.dao;
import java.util.ArrayList;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.BeanNodeMapper;
-import org.argeo.jcr.JcrUtils;
+import org.argeo.jcr.spring.BeanNodeMapper;
import org.argeo.slc.core.attachment.SimpleAttachment;
import org.argeo.slc.core.structure.SimpleSElement;
import org.argeo.slc.core.structure.tree.TreeSPath;
// We add the tags
Map<String, String> tags = elements.get(key).getTags();
for (String tag : tags.keySet()) {
+ NodeIterator tagIt = childNode.getNodes("tag");
+ Node tagNode = null;
+ while (tagIt.hasNext()) {
+ Node n = tagIt.nextNode();
+ if (n.getProperty("name").getString().equals(tag)) {
+ tagNode = n;
+ }
+ }
+
+ if (tagNode == null) {
+ tagNode = childNode.addNode("tag");
+ tagNode.setProperty("name", tag);
+ }
+
+ tagNode.setProperty("value", tags.get(tag));
+
// remove forbidden characters
- String cleanTag = JcrUtils.removeForbiddenCharacters(tag);
- if (!cleanTag.equals(tag))
- log.warn("Tag '" + tag + "' persisted as '" + cleanTag
- + "'");
- childNode.setProperty(cleanTag, tags.get(tag));
+ // String cleanTag = JcrUtils.removeForbiddenCharacters(tag);
+ // if (!cleanTag.equals(tag))
+ // log.warn("Tag '" + tag + "' persisted as '" + cleanTag
+ // + "'");
+ // childNode.setProperty(cleanTag, tags.get(tag));
}
// We set the class in order to be able to retrieve
tmpNode = tmpNode.addNode(pathes[i]);
}
childNode = tmpNode;
- log.debug("Node created " + childNode.getPath());
+ //log.debug("Node created " + childNode.getPath());
} else {
childNode = node.getNode(relPath);
- log.debug("Node already existing " + childNode.getPath());
+ //log.debug("Node already existing " + childNode.getPath());
}
List<TestResultPart> list = resultParts.get(key).getParts();
}
// ATTRIBUTES
- Map attributes = new TreeMap<String, String>();
+ SortedMap attributes = new TreeMap<String, String>();
PropertyIterator propIt = node.getProperties();
props: while (propIt.hasNext()) {
Property prop = propIt.nextProperty();
se.setLabel(curNode.getProperty("label").getString());
Map<String, String> tagMap = new TreeMap<String, String>();
- PropertyIterator tagIt = curNode.getProperties();
- tags: while (tagIt.hasNext()) {
- Property prop = tagIt.nextProperty();
- //log.debug("Handling property named : " + prop.getName());
-
- // TODO Define a rule to generalize it
- // Specific case. mainly uuid
- if ("uuid".equals(prop.getName())
- || prop.getName().equals(getClassProperty())
- || prop.getName().startsWith("jcr")) {
- continue tags;
- }
+ NodeIterator tagIt = node.getNodes("tag");
+ while (tagIt.hasNext()) {
+ Node tagNode = tagIt.nextNode();
+ tagMap.put(tagNode.getProperty("name").getString(), tagNode
+ .getProperty("value").getString());
- // else it's an attribute, we retrieve it
- tagMap.put(prop.getName(), prop.getString());
}
+ // PropertyIterator tagIt = curNode.getProperties();
+ // tags: while (tagIt.hasNext()) {
+ // Property prop = tagIt.nextProperty();
+ // //log.debug("Handling property named : " + prop.getName());
+ //
+ // // TODO Define a rule to generalize it
+ // // Specific case. mainly uuid
+ // if ("uuid".equals(prop.getName())
+ // || prop.getName().equals(getClassProperty())
+ // || prop.getName().startsWith("jcr")) {
+ // continue tags;
+ // }
+ //
+ // // else it's an attribute, we retrieve it
+ // tagMap.put(prop.getName(), prop.getString());
+ // }
se.setTags(tagMap);
elements.put(tsp, se);
}
- log.debug("We added " + elements.size() + " elements");
+ //log.debug("We added " + elements.size() + " elements");
ttr.setElements(elements);