--- /dev/null
+package org.argeo.entity;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+/** JCR utilities around the entity concepts. */
+public class EntityJcrUtils {
+ /**
+ * The name of a node which will be serialized as XML text, as per section 7.3.1
+ * of the JCR 2.0 specifications.
+ */
+ public final static String JCR_XMLTEXT = "jcr:xmltext";
+
+ /**
+ * The name of a property which will be serialized as XML text, as per section
+ * 7.3.1 of the JCR 2.0 specifications.
+ */
+ public final static String JCR_XMLCHARACTERS = "jcr:xmlcharacters";
+
+ /*
+ * XML
+ */
+ /**
+ * Set both as a property and as a subnode which will be exported as an XML
+ * element.
+ */
+
+// public static void setAttrAndElem(Node node, String name, String value) {
+// Jcr.set(node, name, value);
+// setElem(node, name, value);
+// }
+ /**
+ * Set as a subnode which will be exported as an XML element.
+ */
+ public static String getXmlValue(Node node, String name) {
+ try {
+ if (!node.hasNode(name))
+ throw new IllegalArgumentException("No XML text named " + name);
+ return node.getNode(name).getNode(JCR_XMLTEXT).getProperty(JCR_XMLCHARACTERS).getString();
+ } catch (RepositoryException e) {
+ throw new IllegalStateException("Cannot get " + name + " as XML text", e);
+ }
+ }
+
+ /**
+ * Set as a subnode which will be exported as an XML element.
+ */
+ public static void setXmlValue(Node node, String name, String value) {
+ try {
+ if (node.hasNode(name))
+ node.getNode(name).getNode(JCR_XMLTEXT).setProperty(JCR_XMLCHARACTERS, value);
+ else
+ node.addNode(name, EntityType.xmlvalue.qualified()).addNode(JCR_XMLTEXT, EntityType.xmltext.qualified())
+ .setProperty(JCR_XMLCHARACTERS, value);
+ } catch (RepositoryException e) {
+ throw new IllegalStateException("Cannot set " + name + " as XML text", e);
+ }
+ }
+
+}
/** Constants used to name entity structures. */
public interface EntityNames {
- final String ENTITY_DEFINITIONS_PATH = "/entity:entityDefinitions";
+ final String ENTITY_DEFINITIONS_PATH = "/entity";
+ final String TYPOLOGIES_PATH = "/class";
+
+ /** Administrative units. */
+ final String ADM = "adm";
final String ENTITY_TYPE = "entity:type";
final String ENTITY_UID = "entity:uid";
+ final String ENTITY_NAME = "entity:name";
// GENERIC CONCEPTS
- /** The date which is clearly relevant for this entity. */
+ /** The language which is relevant. */
+ final String XML_LANG = "xml:lang";
+ /** The date which is relevant. */
final String ENTITY_DATE = "entity:date";
final String ENTITY_RELATED_TO = "entity:relatedTo";
final String SURNAME = LdapAttrs.sn.property();
final String EMAIL = LdapAttrs.mail.property();
+ final String OU = LdapAttrs.ou.property();
+
+ // WGS84
+ final String GEO_LAT = "geo:lat";
+ final String GEO_LONG = "geo:long";
+ final String GEO_ALT = "geo:alt";
}
--- /dev/null
+package org.argeo.entity;
+
+import org.argeo.naming.QualifiedName;
+
+/** Types related to entities. */
+public enum EntityType implements QualifiedName {
+ // entity
+ entity, definition,
+ // xml
+ xmlvalue,xmltext,
+ // typology
+ typology, term
+ // ldap
+ , person;
+
+ @Override
+ public String getPrefix() {
+ return prefix();
+ }
+
+ public static String prefix() {
+ return "entity";
+ }
+
+ @Override
+ public String getNamespace() {
+ return namespace();
+ }
+
+ public static String namespace() {
+ return "http://www.argeo.org/ns/entity";
+ }
+
+}
package org.argeo.entity;
/** Types related to entities. */
+@Deprecated
public interface EntityTypes {
final static String ENTITY_ENTITY = "entity:entity";
final static String ENTITY_DEFINITION = "entity:definition";
<ldap = 'http://www.argeo.org/ns/ldap'>
<entity = 'http://www.argeo.org/ns/entity'>
-[entity:entity] > mix:title, mix:created, mix:lastModified, mix:referenceable
+// standard namespaces
+<xsd = "http://www.w3.org/2001/XMLSchema">
+<h = "http://www.w3.org/1999/xhtml">
+<xforms = "http://www.w3.org/2002/xforms">
+
+// see https://www.w3.org/2003/01/geo/
+<geo = 'http://www.w3.org/2003/01/geo/wgs84_pos#'>
+
+
+[entity:entity] > mix:created, mix:referenceable
mixin
//- entity:uid (String) m // an implementation dependent UID for each entity
//- entity:type (String) // the type of this entity
-[entity:definition] > entity:composite, mix:title, mix:created, mix:lastModified, mix:referenceable
-mixin
+//
+// ENTITY DEFINITION
+//
+[entity:definition] > entity:composite, mix:created, mix:referenceable
+//- entity:type (String) multiple
[entity:part]
-mixin
[entity:reference]
-mixin
[entity:composite]
-mixin
orderable
-+ * (entity:part)
-+ * (entity:reference)
-+ * (entity:composite)
+//+ * (entity:part)
+//+ * (entity:reference)
+//+ * (entity:composite)
+
+//
+// TYPOLOGY
+//
+[entity:term]
+orderable
++ * (entity:term) *
+
+[entity:typology] > mix:referenceable, mix:created
+orderable
++ * (entity:term) *
+
+//
+// XML
+//
+[entity:xmlvalue] > mix:language
+- *
++ jcr:xmltext (entity:xmltext)
+
+[entity:xmltext]
+ - jcr:xmlcharacters (String) mandatory
+
+//
+// HTML
+//
+[h:head]
++ h:title (entity:xmlvalue)
++ h:base (entity:xmlvalue)
++ h:style (entity:xmlvalue) multiple
++ h:meta (entity:xmlvalue) multiple
++ h:link (entity:xmlvalue) multiple
++ h:script (entity:xmlvalue) multiple
+
+[h:html]
++ h:head (h:head)
++ h:body (nt:unstructured)
// LDAP-LIKE ENTITIES
// A real person
[entity:person] > entity:entity
mixin
+- ldap:sn (String)
+- ldap:givenName (String)
defaultEditoryId = properties.get(EntityConstants.DEFAULT_EDITORY_ID);
String definitionPath = EntityNames.ENTITY_DEFINITIONS_PATH + '/' + type;
if (!adminSession.itemExists(definitionPath)) {
- Node entityDefinition = JcrUtils.mkdirs(adminSession, definitionPath);
- entityDefinition.addMixin(EntityTypes.ENTITY_DEFINITION);
+ Node entityDefinition = JcrUtils.mkdirs(adminSession, definitionPath, EntityTypes.ENTITY_DEFINITION);
+// entityDefinition.addMixin(EntityTypes.ENTITY_DEFINITION);
adminSession.save();
}
initJcr(adminSession);