http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/profile/pom.xml ---------------------------------------------------------------------- diff --git a/profile/pom.xml b/profile/pom.xml deleted file mode 100644 index 3d67496..0000000 --- a/profile/pom.xml +++ /dev/null @@ -1,156 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You 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. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.oodt</groupId> - <artifactId>oodt-core</artifactId> - <version>1.1-SNAPSHOT</version> - <relativePath>../core/pom.xml</relativePath> - </parent> - <artifactId>oodt-profile</artifactId> - <name>Profile Service</name> - <description>The Profile Service describes and locates resources using metadata - descriptions. These descriptions, called profiles, tell of a - resource's inception, composition, and location using a mix of - Dublin Core and ISO-11179 metadata as well as URIs for locations. - The Profile Service catalogs metadata descriptions and provides - creating, updating, and querying capabilities.</description> - <!-- All dependencies should be listed in core/pom.xml and be ordered alphabetically by package and artifact. - Once the dependency is in the core pom, it can then be used in other modules without the version tags. - For example, within core/pom.xml: - - <dependency> - <groupId>com.amazonaws</groupId> - <artifactId>aws-java-sdk</artifactId> - <version>1.7.4</version> - </dependency> - - Elsewhere in the platform: - <dependency> - <groupId>com.amazonaws</groupId> - <artifactId>aws-java-sdk</artifactId> - </dependency> - - Where possible the same dependency version should be used across the whole platform but if required the version - can be overridden in a specific pom and should have a comment explaing why the version has been overridden - --> - <dependencies> - <dependency> - <groupId>com.ibm.icu</groupId> - <artifactId>icu4j</artifactId> - <version>3.4.4</version> - </dependency> - <dependency> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - <version>1.3</version> - </dependency> - <dependency> - <groupId>commons-httpclient</groupId> - <artifactId>commons-httpclient</artifactId> - <version>3.0-alpha1</version> - </dependency> - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - <version>1.0.4</version> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>3.8.2</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.jena</groupId> - <artifactId>apache-jena-libs</artifactId> - <version>${jena.version}</version> - <type>pom</type> - </dependency> - <dependency> - <groupId>org.apache.oodt</groupId> - <artifactId>cas-filemgr</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> - <groupId>org.apache.oodt</groupId> - <artifactId>oodt-commons</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> - <groupId>org.apache.oodt</groupId> - <artifactId>oodt-xmlquery</artifactId> - <version>${project.parent.version}</version> - </dependency> - </dependencies> - <build> - <resources> - <resource> - <directory>${basedir}/src/main/dtd</directory> - </resource> - </resources> - <plugins> - <plugin> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <forkMode>once</forkMode> - <excludes> - <exclude>org/apache/oodt/profile/ProfileElementTestCase.java</exclude> - </excludes> - </configuration> - </plugin> - </plugins> - </build> - <scm> - <!-- <connection>scm:svn:https://svn.apache.org/repos/asf/oodt/trunk/profile</connection> - <developerConnection>scm:svn:https://svn.apache.org/repos/asf/oodt/trunk/profile</developerConnection> - <url>http://svn.apache.org/viewvc/oodt/trunk/profile</url>--> - <tag>0.13-SNAPSHOT</tag> - </scm> - <profiles> - <profile> - <id>audit</id> - <activation> - <activeByDefault>false</activeByDefault> - </activation> - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>rat-maven-plugin</artifactId> - <configuration> - <excludes> - <exclude>**/testdata/*</exclude> - <exclude>**/handlers/lightweight/package.html</exclude> - </excludes> - </configuration> - <executions> - <execution> - <goals> - <goal>check</goal> - </goals> - <phase>verify</phase> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> -</project>
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/profile/src/main/dtd/prof.dtd ---------------------------------------------------------------------- diff --git a/profile/src/main/dtd/prof.dtd b/profile/src/main/dtd/prof.dtd deleted file mode 100644 index ee8af94..0000000 --- a/profile/src/main/dtd/prof.dtd +++ /dev/null @@ -1,86 +0,0 @@ -<?xml encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You 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. ---> - -<!ELEMENT profiles - (profile*)> - -<!ELEMENT profile - (profAttributes, - resAttributes, - profElement*)> - - <!ELEMENT profAttributes - (profId, profVersion?, profType, - profStatusId, profSecurityType?, profParentId?, profChildId*, - profRegAuthority?, profRevisionNote*)> - - <!ELEMENT resAttributes - (Identifier, Title?, Format*, Description?, Creator*, Subject*, - Publisher*, Contributor*, Date*, Type*, Source*, - Language*, Relation*, Coverage*, Rights*, - resContext+, resAggregation?, resClass, resLocation*)> - - <!ELEMENT profElement - (elemId?, elemName, elemDesc?, elemType?, elemUnit?, - elemEnumFlag, (elemValue* | (elemMinValue, elemMaxValue)), - elemSynonym*, - elemObligation?, elemMaxOccurrence?, elemComment?)> - - <!ELEMENT profId (#PCDATA)> - <!ELEMENT profVersion (#PCDATA)> - <!ELEMENT profType (#PCDATA)> - <!ELEMENT profParentId (#PCDATA)> - <!ELEMENT profChildId (#PCDATA)> - <!ELEMENT profStatusId (#PCDATA)> - <!ELEMENT profSecurityType (#PCDATA)> - <!ELEMENT profRegAuthority (#PCDATA)> - <!ELEMENT profRevisionNote (#PCDATA)> - - <!ELEMENT Identifier (#PCDATA)> - <!ELEMENT Title (#PCDATA)> - <!ELEMENT Format (#PCDATA)> - <!ELEMENT Description (#PCDATA)> - <!ELEMENT Creator (#PCDATA)> - <!ELEMENT Subject (#PCDATA)> - <!ELEMENT Publisher (#PCDATA)> - <!ELEMENT Contributor (#PCDATA)> - <!ELEMENT Date (#PCDATA)> - <!ELEMENT Type (#PCDATA)> - <!ELEMENT Source (#PCDATA)> - <!ELEMENT Language (#PCDATA)> - <!ELEMENT Relation (#PCDATA)> - <!ELEMENT Coverage (#PCDATA)> - <!ELEMENT Rights (#PCDATA)> - <!ELEMENT resContext (#PCDATA)> - <!ELEMENT resAggregation (#PCDATA)> - <!ELEMENT resClass (#PCDATA)> - <!ELEMENT resLocation (#PCDATA)> - - <!ELEMENT elemId (#PCDATA)> - <!ELEMENT elemName (#PCDATA)> - <!ELEMENT elemType (#PCDATA)> - <!ELEMENT elemEnumFlag (#PCDATA)> - <!ELEMENT elemDesc (#PCDATA)> - <!ELEMENT elemSynonym (#PCDATA)> - <!ELEMENT elemUnit (#PCDATA)> - <!ELEMENT elemValue (#PCDATA)> - <!ELEMENT elemMinValue (#PCDATA)> - <!ELEMENT elemMaxValue (#PCDATA)> - <!ELEMENT elemObligation (#PCDATA)> - <!ELEMENT elemMaxOccurrence (#PCDATA)> - <!ELEMENT elemComment (#PCDATA)> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/profile/src/main/java/org/apache/oodt/profile/DefaultFactory.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/DefaultFactory.java b/profile/src/main/java/org/apache/oodt/profile/DefaultFactory.java deleted file mode 100644 index 33bbe3e..0000000 --- a/profile/src/main/java/org/apache/oodt/profile/DefaultFactory.java +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one or more contributor -// license agreements. See the NOTICE.txt file distributed with this work for -// additional information regarding copyright ownership. The ASF licenses this -// file to you 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.apache.oodt.profile; - -import java.util.List; -import org.w3c.dom.Element; - -/** - * Default factory for profile objects. - * - * This factory creates the typical profile objects {@link RangedProfileElement}, {@link - * UnspecifiedProfileElement}, {@link EnumeratedProfileElement}, {@link Profile}, {@link - * ProfileAttributes}, and {@link ResourceAttributes}. - * - * @author Kelly - * @version $Revision: 1.1.1.1 $ - */ -class DefaultFactory implements ObjectFactory { - public RangedProfileElement createRangedProfileElement(Profile profile, String name, String id, String desc, String type, - String unit, List synonyms, boolean obligation, int maxOccurrence, String comments, String min, String max) { - return new RangedProfileElement(profile, name, id, desc, type, unit, synonyms, obligation, maxOccurrence, - comments, min, max); - } - public UnspecifiedProfileElement createUnspecifiedProfileElement(Profile profile, String name, String id, String desc, - String type, String unit, List synonyms, boolean obligation, int maxOccurrence, String comments) { - return new UnspecifiedProfileElement(profile, name, id, desc, type, unit, synonyms, obligation, maxOccurrence, - comments); - } - public EnumeratedProfileElement createEnumeratedProfileElement(Profile profile, String name, String id, String desc, - String type, String unit, List synonyms, boolean obligation, int maxOccurrence, String comments, List values) { - return new EnumeratedProfileElement(profile, name, id, desc, type, unit, synonyms, obligation, maxOccurrence, - comments, values); - } - public Profile createProfile(Element node) { - return new Profile(node, this); - } - public ProfileAttributes createProfileAttributes(Element node) { - return new ProfileAttributes(node); - } - public ResourceAttributes createResourceAttributes(Profile profile, Element node) { - return new ResourceAttributes(profile, node); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/profile/src/main/java/org/apache/oodt/profile/EnumeratedProfileElement.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/EnumeratedProfileElement.java b/profile/src/main/java/org/apache/oodt/profile/EnumeratedProfileElement.java deleted file mode 100644 index 42304a6..0000000 --- a/profile/src/main/java/org/apache/oodt/profile/EnumeratedProfileElement.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.oodt.profile; - -import java.util.ArrayList; -import java.util.List; - -import org.w3c.dom.DOMException; -import org.w3c.dom.Node; -import org.apache.jena.rdf.model.Model; -import org.apache.jena.rdf.model.Resource; - -import java.net.URI; - -import org.w3c.dom.Element; - -/** - * Enumerated profile element. - * - * Objects of this class are elements of a profile that have several enumerated values. - * - * @author Kelly - */ -public class EnumeratedProfileElement extends ProfileElement { - /** - * Create blank profile element belonging to the given profile. - */ - public EnumeratedProfileElement(Profile profile) { - super(profile); - values = new ArrayList<Object>(); - } - - /** - * Create a profile element from constituent attributes. - * - * @param profile Profile to which this element belongs. - * @param name Required name of the element. - * @param id ID of the element. - * @param desc Long description of the element. - * @param type Data type of the element. - * @param unit Units. - * @param synonyms Collection of element IDs ({@link String}) that are synonyms for this element. - * @param obligation True if this is a required element - * @param maxOccurrence Maximum number of occurrences of this element. - * @param comment Any comments about this element. - * @param values Valid values. - */ - public EnumeratedProfileElement(Profile profile, String name, String id, String desc, String type, String unit, - List<?> synonyms, boolean obligation, int maxOccurrence, String comment, List<?> values) { - super(profile, name, id, desc, type, unit, synonyms, obligation, maxOccurrence, comment); - if (values.contains(null)) { - throw new IllegalArgumentException("Null item in 'values' not allowed for enumerated profile elements"); - } - this.values = values; - } - - protected boolean isEnumerated() { - return true; - } - - protected void addValues(Node node) throws DOMException { - if (values == null) { - return; - } - for (Object value : values) { - Element e = node.getOwnerDocument().createElement("elemValue"); - e.appendChild(node.getOwnerDocument().createCDATASection((String) value)); - node.appendChild(e); - } - } - - public String getMinValue() { - return ""; - } - - public String getMaxValue() { - return ""; - } - - public List getValues() { - return values; - } - - protected void addElementSpecificProperties(Model model, Resource element, ProfileAttributes profAttr, URI uri) { - Utility.addProperty(model, element, Utility.edmValue, values, profAttr, uri); - } - - /** Valid values. */ - protected List<?> values; -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/profile/src/main/java/org/apache/oodt/profile/ObjectFactory.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/ObjectFactory.java b/profile/src/main/java/org/apache/oodt/profile/ObjectFactory.java deleted file mode 100755 index e2b7a4d..0000000 --- a/profile/src/main/java/org/apache/oodt/profile/ObjectFactory.java +++ /dev/null @@ -1,109 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one or more contributor -// license agreements. See the NOTICE.txt file distributed with this work for -// additional information regarding copyright ownership. The ASF licenses this -// file to you 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.apache.oodt.profile; - -import java.util.List; -import org.w3c.dom.Element; - -/** - * Factory to create profile-related objects. - * - * @author Kelly - * @version $Revision: 1.1.1.1 $ - */ -public interface ObjectFactory { - /** - * Create a ranged profile element. - * - * @param profile a <code>Profile</code> value. - * @param name a <code>String</code> value. - * @param id a <code>String</code> value. - * @param desc a <code>String</code> value. - * @param type a <code>String</code> value. - * @param unit a <code>String</code> value. - * @param synonyms a <code>List</code> value. - * @param obligation a <code>boolean</code> value. - * @param maxOccurrence an <code>int</code> value. - * @param comments a <code>String</code> value. - * @param min a <code>double</code> value. - * @param max a <code>double</code> value. - * @return a <code>RangedProfileElement</code> value. - */ - RangedProfileElement createRangedProfileElement(Profile profile, String name, String id, String desc, String type, - String unit, List synonyms, boolean obligation, int maxOccurrence, String comments, String min, String max); - - /** - * Create a profile element with unspecified values. - * - * @param profile a <code>Profile</code> value. - * @param name a <code>String</code> value. - * @param id a <code>String</code> value. - * @param desc a <code>String</code> value. - * @param type a <code>String</code> value. - * @param unit a <code>String</code> value. - * @param synonyms a <code>List</code> value. - * @param obligation a <code>boolean</code> value. - * @param maxOccurrence an <code>int</code> value. - * @param comments a <code>String</code> value. - * @return an <code>UnspecifiedProfileElement</code> value. - */ - UnspecifiedProfileElement createUnspecifiedProfileElement(Profile profile, String name, String id, String desc, String type, - String unit, List synonyms, boolean obligation, int maxOccurrence, String comments); - - /** - * Create a profile element with enumerated values. - * - * @param profile a <code>Profile</code> value. - * @param name a <code>String</code> value. - * @param id a <code>String</code> value. - * @param desc a <code>String</code> value. - * @param type a <code>String</code> value. - * @param unit a <code>String</code> value. - * @param synonyms a <code>List</code> value. - * @param obligation a <code>boolean</code> value. - * @param maxOccurrence an <code>int</code> value. - * @param comments a <code>String</code> value. - * @param values a <code>List</code> value. - * @return an <code>Enumerated</code> value. - */ - EnumeratedProfileElement createEnumeratedProfileElement(Profile profile, String name, String id, String desc, String type, - String unit, List synonyms, boolean obligation, int maxOccurrence, String comments, List values); - - /** - * Create a profile from a DOM node. - * - * @param node an <code>Element</code> value. - * @return a <code>Profile</code> value. - */ - Profile createProfile(Element node); - - /** - * Create profile attributes from a DOM node. - * - * @param node an <code>Element</code> value. - * @return a <code>ProfileAttributes</code> value. - */ - ProfileAttributes createProfileAttributes(Element node); - - /** - * Create resource attributes from a DOM node. - * - * @param profile Owning profile. - * @param node an <code>Element</code> value. - * @return a <code>ResourceAttributes</code> value. - */ - ResourceAttributes createResourceAttributes(Profile profile, Element node); -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/profile/src/main/java/org/apache/oodt/profile/Profile.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/Profile.java b/profile/src/main/java/org/apache/oodt/profile/Profile.java deleted file mode 100644 index 8f9cc6e..0000000 --- a/profile/src/main/java/org/apache/oodt/profile/Profile.java +++ /dev/null @@ -1,401 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.oodt.profile; - -import org.apache.jena.rdf.model.Model; -import org.apache.jena.rdf.model.ModelFactory; -import org.apache.jena.rdf.model.Resource; -import org.apache.oodt.commons.util.Documentable; -import org.apache.oodt.commons.util.XML; - -import org.w3c.dom.DOMException; -import org.w3c.dom.Document; -import org.w3c.dom.DocumentType; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.OutputStreamWriter; -import java.io.Serializable; -import java.net.URI; -import java.util.ArrayList; -import java.util.concurrent.ConcurrentHashMap; -import java.util.List; -import java.util.Map; - -/** - * A profile. - * - * Objects of this class are profiles. Profiles are metadata descriptions of resources. - * - * @author Kelly - */ -public class Profile implements Serializable, Cloneable, Comparable<Object>, Documentable { - /** Serial version unique ID. */ - static final long serialVersionUID = -3936851809184360591L; - - /** The formal public identifier of the profiles DTD. */ - public static final String PROFILES_DTD_FPI = "-//JPL//DTD Profile 1.1//EN"; - public static final int INT = 512; - - /** The system identifier of the profiles DTD. */ - public static String PROFILES_DTD_URL = "http://oodt.jpl.nasa.gov/grid-profile/dtd/prof.dtd"; - - /** - * Create a list of profiles by deserializing data from the given XML element. - * - * @param root Either a <profiles> or a <profile> element. - * @param factory Factory for creation of profile-related objects. - * @return A list of profiles. - */ - public static List<Profile> createProfiles(Element root, ObjectFactory factory) { - List<Profile> profiles = new ArrayList<Profile>(); - if ("profile".equals(root.getNodeName())) - // The root is a <profile>, so add the single profile to the list. - { - profiles.add(factory.createProfile((Element) root)); - } else if ("profiles".equals(root.getNodeName())) { - // The root is a <profiles>, so add each <profile> to the list. - NodeList children = root.getChildNodes(); - for (int i = 0; i < children.getLength(); ++i) { - Node node = children.item(i); - if ("profile".equals(node.getNodeName())) { - profiles.add(factory.createProfile((Element) node)); - } - } - } else { - throw new IllegalArgumentException("Expected a <profiles> or <profile> top level element but got " - + root.getNodeName()); - } - return profiles; - } - - - /** - * Create a list of profiles by deserializing data from the given XML element. - * - * This method uses the default factory that yields objects of this package, - * namely {@link Profile}, {@link ProfileAttributes}, {@link ResourceAttributes}, - * and {@link ProfileElement} and its subclasses. - * - * @param root Either a <profiles> or a <profile> element. - * @return A list of profiles. - */ - public static List<Profile> createProfiles(Element root) { - return createProfiles(root, new DefaultFactory()); - } - - /** - * Create a blank profile. - */ - public Profile() { - profAttr = new ProfileAttributes(); - resAttr = new ResourceAttributes(this); - } - - /** - * Create a profile from an XML document. - * - * @param string The XML document (as a string). - * @throws SAXException If the <var>string</var> can't be parsed. - */ - public Profile(String string) throws SAXException { - this(XML.parse(string).getDocumentElement(), new DefaultFactory()); - } - - /** - * Create a profile from an XML document. - * - * @param string The XML document (as a string). - * @param factory Object factory to use. - * @throws SAXException If the <var>string</var> can't be parsed. - */ - public Profile(String string, ObjectFactory factory) throws SAXException { - this(XML.parse(string).getDocumentElement(), factory); - } - - /** - * Creates a new <code>Profile</code> instance. - * - * @param root a <code>Node</code> value. - */ - public Profile(Node root) { - this(root, new DefaultFactory()); - } - - /** - * Create a profile from an XML document. - * - * @param root The <profile> element. - */ - public Profile(Node root, ObjectFactory factory) { - if (!root.getNodeName().equals("profile")) { - throw new IllegalArgumentException("Construct a Profile from a <profile> element, not a <" - + root.getNodeName() + ">"); - } - NodeList children = root.getChildNodes(); - for (int i = 0; i < children.getLength(); ++i) { - Node node = children.item(i); - if ("profAttributes".equals(node.getNodeName())) { - profAttr = factory.createProfileAttributes((Element) node); - } else if ("resAttributes".equals(node.getNodeName())) { - resAttr = factory.createResourceAttributes(this, (Element) node); - } else if ("profElement".equals(node.getNodeName())) { - ProfileElement element = ProfileElement.createProfileElement((Element) node, this, factory); - elements.put(element.getName(), element); - } - } - } - - /** - * Create a profile from its attributes. - * - * @param profAttr Profile attributes. - * @param resAttr Resource attributes. - */ - public Profile(ProfileAttributes profAttr, ResourceAttributes resAttr) { - this.profAttr = profAttr; - this.resAttr = resAttr; - if (this.resAttr != null) { - this.resAttr.profile = this; - } - } - - public int hashCode() { - return profAttr.hashCode(); - } - - public boolean equals(Object rhs) { - if (rhs == this) { - return true; - } - if (rhs == null || !(rhs instanceof Profile)) { - return false; - } - Profile obj = (Profile) rhs; - return profAttr.equals(obj.profAttr); - } - - public int compareTo(Object rhs) { - Profile obj = (Profile) rhs; - return profAttr.compareTo(obj.profAttr); - } - - public String toString() { - Document doc = createProfileDocument(); - doc.removeChild(doc.getDocumentElement()); - doc.appendChild(toXML(doc)); - return XML.serialize(doc); - } - - public Object clone() { - Object clone = null; - try { - clone = super.clone(); - } catch (CloneNotSupportedException ignored) {} - return clone; - } - - /** - * Get the profile attributes. - * - * @return The profile attributes. - */ - public ProfileAttributes getProfileAttributes() { - return profAttr; - } - - /** - * Get the resource attributes. - * - * @return The resource attributes. - */ - public ResourceAttributes getResourceAttributes() { - return resAttr; - } - - /** - * Set this profile's profile attributes. - * - * @param profAttr a <code>ProfileAttributes</code> value. - */ - public void setProfileAttributes(ProfileAttributes profAttr) { - this.profAttr = profAttr; - } - - /** - * Set this profile's resource attributes. - * - * @param resAttr a <code>ResourceAttributes</code> value. - */ - public void setResourceAttributes(ResourceAttributes resAttr) { - this.resAttr = resAttr; - } - - /** - * Get the profile elements. - * - * The profile elements are a mapping from the element name ({@link - * java.lang.String}) to {@link ProfileElement}. - * - * @return The profile elements. - */ - public Map<String, ProfileElement> getProfileElements() { - return elements; - } - - public URI getURI() { - return resAttr.getURI(); - } - - /** - * Add this profile as an RDF resource description to an RDF model. - * - * This creates a description of the resource that this profile describes, as well - * as additional resources for the reified statements about the profile itself, - * and adds them all to the given model. - * - * @param model Model to which to add the profile and its related descriptions. - */ - public void addToModel(Model model) { - Resource resource = model.createResource(getURI().toString()); - resAttr.addToModel(model, resource, profAttr); - for (ProfileElement e : elements.values()) { - e.addToModel(model, resource, profAttr); - } - } - - /** - * Serialize this profile as an XML node. - * - * @param doc The document that will own this node. - * @return The XML element <profile> representing these attributes. - * @throws DOMException If an error occurs creating the XML nodes. - */ - public Node toXML(Document doc) throws DOMException { - return toXML(doc, /*withElements*/true); - } - - /** - * Serialize this profile as an XML node but without any elements. - * - * @param doc The document that will own this node. - * @return The XML element <profile> representing these attributes. - * @throws DOMException If an error occurs creating the XML nodes. - */ - public Node toXMLWithoutElements(Document doc) throws DOMException { - return toXML(doc, /*withElements*/false); - } - - /** - * Serialize this profile as an XML node. - * - * @param doc The document that will own this node. - * @param withElements Include the profile elements? - * @return The XML element <profile> representing these attributes. - * @throws DOMException If an error occurs creating the XML nodes. - */ - private Node toXML(Document doc, boolean withElements) throws DOMException { - Element profile = doc.createElement("profile"); - profile.appendChild(profAttr.toXML(doc)); - profile.appendChild(resAttr.toXML(doc)); - if (withElements) { - for (ProfileElement profileElement : elements.values()) { - profile.appendChild((profileElement).toXML(doc)); - } - } - return profile; - } - - /** - * Create a <profiles> document using the profiles DTD. - * - * @return A <profiles> document with the profiles DTD. - */ - public static Document createProfilesDocument() { - return createDocument("profiles"); - } - - /** - * Create a <profile> document using the profiles DTD. - * - * @return A <profile> document with the profiles DTD. - */ - public static Document createProfileDocument() { - return createDocument("profile"); - } - - /** - * Create a document using the profiles DTD with the given root element. - * - * @param root Name of the root element. - * @return The document with the appropriate document type declaration. - */ - static Document createDocument(String root) { - DocumentType docType = XML.getDOMImplementation().createDocumentType(root, PROFILES_DTD_FPI, PROFILES_DTD_URL); - return XML.getDOMImplementation().createDocument(/*namespaceURI*/null, root, docType); - } - - /** My profile attributes. */ - protected ProfileAttributes profAttr; - - /** My resource attributes. */ - protected ResourceAttributes resAttr; - - /** My elements. - * - * This mapping is from element name (a {@link String}) to {@link ProfileElement}. - */ - protected Map<String, ProfileElement> elements = new ConcurrentHashMap<String, ProfileElement>(); - - /** - * Try to parse an XML profile in a file in its XML vocabulary. If successful, - * you get the profile as RDF document (in XML format) to the standard output - * after it's been digested by the profile class. If not, then you get an - * exception. - * - * @param argv Command-line arguments, of which there should be one, the name of XML file containing the profile to parse - * @throws Throwable if an error occurs. - */ - public static void main(String[] argv) throws Throwable { - if (argv.length != 1) { - System.err.println("Usage: <profile.xml>"); - System.exit(1); - } - StringBuilder b = new StringBuilder(); - BufferedReader reader = new BufferedReader(new FileReader(argv[0])); - char[] buf = new char[INT]; - int num; - while ((num = reader.read(buf)) != -1) { - b.append(buf, 0, num); - } - reader.close(); - Profile p = new Profile(b.toString()); - - Model model = ModelFactory.createDefaultModel(); - p.addToModel(model); - OutputStreamWriter writer = new OutputStreamWriter(System.out); - model.write(writer); - writer.close(); - System.exit(0); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/profile/src/main/java/org/apache/oodt/profile/ProfileAttributes.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/ProfileAttributes.java b/profile/src/main/java/org/apache/oodt/profile/ProfileAttributes.java deleted file mode 100644 index c79e5f6..0000000 --- a/profile/src/main/java/org/apache/oodt/profile/ProfileAttributes.java +++ /dev/null @@ -1,344 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.oodt.profile; - -import org.apache.oodt.commons.util.Documentable; -import org.apache.oodt.commons.util.XML; -import org.w3c.dom.*; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -/** - * Profile attributes. - * - * Objects of this class are attributes of profiles. - * - * @author Kelly - */ -public class ProfileAttributes implements Serializable, Cloneable, Comparable, Documentable { - /** - * Create blank profile attributes. - */ - public ProfileAttributes() { - id = "UNKNOWN"; - type = "UNKNOWN"; - statusID = "UNKNOWN"; - children = new ArrayList(); - revisionNotes = new ArrayList(); - } - - /** - * Create profile attributes from an XML document. - * - * @param root The <profAttributes> element. - */ - public ProfileAttributes(Node root) { - children = new ArrayList(); - revisionNotes = new ArrayList(); - NodeList childNodes = root.getChildNodes(); - for (int i = 0; i < childNodes.getLength(); ++i) { - Node node = childNodes.item(i); - if ("profId".equals(node.getNodeName())) { - id = XML.unwrappedText(node); - } else if ("profVersion".equals(node.getNodeName())) { - version = XML.unwrappedText(node); - } else if ("profType".equals(node.getNodeName())) { - type = XML.unwrappedText(node); - } else if ("profStatusId".equals(node.getNodeName())) { - statusID = XML.unwrappedText(node); - } else if ("profSecurityType".equals(node.getNodeName())) { - securityType = XML.unwrappedText(node); - } else if ("profParentId".equals(node.getNodeName())) { - parent = XML.unwrappedText(node); - } else if ("profChildId".equals(node.getNodeName())) { - children.add(XML.unwrappedText(node)); - } else if ("profRegAuthority".equals(node.getNodeName())) { - regAuthority = XML.unwrappedText(node); - } else if ("profRevisionNote".equals(node.getNodeName())) { - revisionNotes.add(XML.unwrappedText(node)); - } - } - } - - /** - * Create profile attributes from constituent attributes. - * - * @param id The profile ID. - * @param version Version. - * @param type Type of the profile. - * @param statusID Status ID. - * @param securityType Security type. - * @param parent Parent profile IDs. - * @param children Zero or more {@link String} child profile IDs. - * @param regAuthority Registration authority. - * @param revisionNotes Zero or more {@link String} revision notes. - */ - public ProfileAttributes(String id, String version, String type, String statusID, String securityType, String parent, - List children, String regAuthority, List revisionNotes) { - this.id = id; - this.version = version; - this.type = type; - this.statusID = statusID; - this.securityType = securityType; - this.parent = parent; - this.children = children; - this.regAuthority = regAuthority; - this.revisionNotes = revisionNotes; - } - - public int hashCode() { - return id.hashCode(); - } - - public boolean equals(Object rhs) { - if (rhs == this) { - return true; - } - if (rhs == null || !(rhs instanceof ProfileAttributes)) { - return false; - } - return ((ProfileAttributes) rhs).id.equals(id); - } - - public int compareTo(Object rhs) { - ProfileAttributes obj = (ProfileAttributes) rhs; - return id.compareTo(obj.id); - } - - public String toString() { - return getClass().getName() + "[id=" + id + "]"; - } - - public Object clone() { - Object clone = null; - try { - clone = super.clone(); - } catch (CloneNotSupportedException ignored) {} - return clone; - } - - /** - * Get the ID. - * - * @return The ID. - */ - public String getID() { - return id; - } - - /** - * Get the version. - * - * @return The version. - */ - public String getVersion() { - return version; - } - - /** - * Get the type. - * - * @return The type of the profile. - */ - public String getType() { - return type; - } - - /** - * Get the status ID. - * - * @return The status ID. - */ - public String getStatusID() { - return statusID; - } - - /** - * Get the security type. - * - * @return The security type. - */ - public String getSecurityType() { - return securityType; - } - - /** - * Get the parent of this profile. - * - * @return The parent profile's ID. - */ - public String getParent() { - return parent; - } - - /** - * Get the children of this profile. - * - * @return A list of {@link String} IDs of its children. - */ - public List getChildren() { - return children; - } - - /** - * Get the registration authority of this profile. - * - * @return Its registration authority. - */ - public String getRegAuthority() { - return regAuthority; - } - - /** - * Get the revision notes of this profile. - * - * @return A list of {@link String} revision notes. - */ - public List getRevisionNotes() { - return revisionNotes; - } - - /** - * - * Set the Parent - * - * @param theParent The Parent String. - */ - public void setParent(String theParent){ - parent = theParent; - } - - /** - * Set the ID. - * - * @param id The ID. - */ - public void setID(String id) { - this.id = id; - } - - /** - * Set the version. - * - * @param version The version. - */ - public void setVersion(String version) { - this.version = version; - } - - /** - * Set the type. - * - * @param type The type of the profile. - */ - public void setType(String type) { - this.type = type; - } - - /** - * Set the status ID. - * - * @param statusID The status ID. - */ - public void setStatusID(String statusID) { - this.statusID = statusID; - } - - /** - * Set the security type. - * - * @param securityType The security type. - */ - public void setSecurityType(String securityType) { - this.securityType = securityType; - } - - /** - * Set the registration authority of this profile. - * - * @param regAuthority Its registration authority. - */ - public void setRegAuthority(String regAuthority) { - this.regAuthority = regAuthority; - } - - /** - * Serialize this attributes as an XML node. - * - * @param doc The document that will own this node. - * @return The XML element <profAttributes> representing these attributes. - * @throws DOMException If an error occurs creating the XML nodes. - */ - public Node toXML(Document doc) throws DOMException { - Element root = doc.createElement("profAttributes"); - XML.add(root, "profId", id); - XML.addNonNull(root, "profVersion", version); - XML.addNonNull(root, "profType", type); - XML.addNonNull(root, "profStatusId", statusID); - XML.addNonNull(root, "profSecurityType", securityType); - XML.addNonNull(root, "profParentId", parent); - XML.add(root, "profChildId", children); - XML.addNonNull(root, "profRegAuthority", regAuthority); - XML.add(root, "profRevisionNote", revisionNotes); - return root; - } - - /** Unique identifier, required. */ - protected String id; - - /** Version, optional. */ - protected String version; - - /** Type, required. */ - protected String type; - - /** Status ID, required. */ - protected String statusID; - - /** Type of security to apply, optional. */ - protected String securityType; - - /** Parent profile ID, optional. */ - protected String parent; - - /** List of zero or more children profile IDs ({@link String}s). */ - protected List children; - - /** Registration authority, optional. */ - protected String regAuthority; - - /** Revision notes, zero or more {@link String}s. */ - protected List revisionNotes; - - /** Serial version unique ID. */ - static final long serialVersionUID = 6140264312462080058L; - - /** - * Create a <profAttributes> document using the profiles DTD. - * - * @return A <profAttributs> document with the profiles DTD. - */ - public static Document createProfAttributesDocument() { - return Profile.createDocument("profAttributes"); - } - - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/profile/src/main/java/org/apache/oodt/profile/ProfileElement.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/ProfileElement.java b/profile/src/main/java/org/apache/oodt/profile/ProfileElement.java deleted file mode 100644 index d7fce0f..0000000 --- a/profile/src/main/java/org/apache/oodt/profile/ProfileElement.java +++ /dev/null @@ -1,586 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.oodt.profile; - -import org.apache.jena.rdf.model.Model; -import org.apache.jena.rdf.model.Resource; - -import java.io.Serializable; -import java.net.URI; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.apache.oodt.commons.util.Documentable; -import org.apache.oodt.commons.util.XML; -import org.w3c.dom.DOMException; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * Profile element. - * - * Objects of this class are elements that describe the composition of a resource. - * - * @author Kelly - */ -public abstract class ProfileElement implements Serializable, Cloneable, Comparable<Object>, Documentable { - /** - * Create a profile element from the given XML node. - * - * @param root The <profElement> node. - * @param profile To what profile the element belongs. - * @return A profile element. - */ - public static ProfileElement createProfileElement(Element root, Profile profile, ObjectFactory factory) { - String name = null; - String id = null; - String desc = null; - String type = null; - String unit = null; - List<String> synonyms = new ArrayList<String>(); - boolean obligation = false; - int maxOccurrence = 0; - String comments = null; - boolean ranged = false; - NodeList children = root.getChildNodes(); - String min = "0.0", max = "0.0"; - boolean gotMin = false; - boolean gotMax = false; - List<String> values = new ArrayList<String>(); - for (int i = 0; i < children.getLength(); ++i) { - Node node = children.item(i); - if ("elemId".equals(node.getNodeName())) { - id = XML.unwrappedText(node); - } else if ("elemName".equals(node.getNodeName())) { - name = XML.unwrappedText(node); - } else if ("elemDesc".equals(node.getNodeName())) { - desc = XML.unwrappedText(node); - } else if ("elemType".equals(node.getNodeName())) { - type = XML.unwrappedText(node); - } else if ("elemUnit".equals(node.getNodeName())) { - unit = XML.unwrappedText(node); - } else if ("elemEnumFlag".equals(node.getNodeName())) { - ranged = "F".equals(XML.unwrappedText(node)); - } else if ("elemSynonym".equals(node.getNodeName())) { - synonyms.add(XML.unwrappedText(node)); - } else if ("elemObligation".equals(node.getNodeName())) { - String value = XML.unwrappedText(node); - obligation = "Required".equals(value) || "T".equals(value); - } else if ("elemMaxOccurrence".equals(node.getNodeName())) { - try { - maxOccurrence = Integer.parseInt(XML.unwrappedText(node)); - } catch (NumberFormatException ignore) { - } - } else if ("elemComment".equals(node.getNodeName())) { - comments = XML.unwrappedText(node); - } else if ("elemValue".equals(node.getNodeName())) { - values.add(text(node)); - } else if ("elemMinValue".equals(node.getNodeName())) { - try { - min = XML.unwrappedText(node); - gotMin = true; - } catch (NumberFormatException ignore) { - } - } else if ("elemMaxValue".equals(node.getNodeName())) { - try { - max = XML.unwrappedText(node); - gotMax = true; - } catch (NumberFormatException ignore) { - } - } - } - if (ranged) { - if (gotMin && gotMax) { - return factory.createRangedProfileElement(profile, name, id, desc, type, unit, synonyms, obligation, - maxOccurrence, comments, min, max); - } - return factory.createUnspecifiedProfileElement(profile, name, id, desc, type, unit, synonyms, obligation, - maxOccurrence, comments); - } else { - return factory.createEnumeratedProfileElement(profile, name, id, desc, type, unit, synonyms, obligation, - maxOccurrence, comments, values); - } - } - - /** - * Create blank profile attributes belonging to the given profile. - */ - protected ProfileElement(Profile profile) { - this.profile = profile; - synonyms = new ArrayList<Object>(); - } - - /** - * Create a profile element from constituent attributes. - * - * @param profile Profile to which this element belongs. - * @param name Required name of the element. - * @param id ID of the element. - * @param desc Long description of the element. - * @param type Data type of the element. - * @param unit Units. - * @param synonyms Collection of element IDs ({@link String}) that are synonyms for this element. - * @param obligation True if this is a required element - * @param maxOccurrence Maximum number of occurrences of this element. - * @param comments Any comments about this element. - */ - protected ProfileElement(Profile profile, String name, String id, String desc, String type, String unit, List<?> synonyms, - boolean obligation, int maxOccurrence, String comments) { - this.profile = profile; - this.name = name; - this.id = id; - this.desc = desc; - this.type = type; - this.unit = unit; - this.synonyms = synonyms; - this.obligation = obligation; - this.maxOccurrence = maxOccurrence; - this.comments = comments; - } - - public int hashCode() { - return name.hashCode(); - } - - public boolean equals(Object rhs) { - if (rhs == this) { - return true; - } - if (rhs == null || !(rhs instanceof ProfileElement)) { - return false; - } - ProfileElement obj = (ProfileElement) rhs; - return profile.equals(obj.profile) && name.equals(obj.name); - } - - public String toString() { - return getClass().getName() + "[profile=" + profile.toString() + ",name=" + name + "]"; - } - - public Object clone() { - Object obj = null; - try { - obj = super.clone(); - } catch (CloneNotSupportedException ignored) {} - return obj; - } - - public int compareTo(Object rhs) { - ProfileElement obj = (ProfileElement) rhs; - if (profile.compareTo(obj.profile) < 0) { - return -1; - } - if (profile.compareTo(obj.profile) == 0) { - return name.compareTo(obj.name); - } - return 1; - } - - /** - * Get the profile to whom I belong. - * - * @return The owning profile. - */ - public Profile getProfile() { - return profile; - } - - /** - * Get my name. - * - * @return My name. - */ - public String getName() { - return name; - } - - /** - * Get my element ID. - * - * @return My ID. - */ - public String getID() { - return id; - } - - /** - * Get my long description. - * - * @return My long description. - */ - public String getDescription() { - return desc; - } - - /** - * Get my type. - * - * @return My type. - */ - public String getType() { - return type; - } - - /** - * Get my unit. - * - * @return My unit. - */ - public String getUnit() { - return unit; - } - - /** - * Get my synonyms. - * - * @return A list of synonyms. - */ - public List getSynonyms() { - return synonyms; - } - - /** - * Am I obligatory? - * - * @return True if I am, false otherwise. - */ - public boolean isObligatory() { - return obligation; - } - - /** - * Get how many times I can occur. - * - * @return How many times I can occur. - */ - public int getMaxOccurrence() { - return maxOccurrence; - } - - /** - * Get any comments about me. - * - * @return Any comments. - */ - public String getComments() { - return comments; - } - - /** - * Set the profile to whom I belong. - * - * @param profile The owning profile. - */ - public void setProfile(Profile profile) { - this.profile = profile; - } - - /** - * Set my name. - * - * @param name My name. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Set my element ID. - * - * @param id My ID. - */ - public void setID(String id) { - this.id = id; - } - - /** - * Set my long description. - * - * @param desc My long description. - */ - public void setDescription(String desc) { - this.desc = desc; - } - - /** - * Set my type. - * - * @param type My type. - */ - public void setType(String type) { - this.type = type; - } - - /** - * Set my unit. - * - * @param unit My unit. - */ - public void setUnit(String unit) { - this.unit = unit; - } - - /** - * Set whether I'm obligatory. - * - * @param obligatory True if I am, false otherwise. - */ - public void setObligation(boolean obligatory) { - this.obligation = obligatory; - } - - /** - * Set how many times I can occur. - * - * @param occurrence How many times I can occur. - */ - public void setMaxOccurrence(int occurrence) { - this.maxOccurrence = occurrence; - } - - /** - * Set any comments about me. - * - * @param comments Any comments. - */ - public void setComments(String comments) { - this.comments = comments; - } - - /** - * Get my minimum value. - * - * @return My minimum value. - */ - public abstract String getMinValue(); - - /** - * Get my maximum value. - * - * @return My maximum value. - */ - public abstract String getMaxValue(); - - /** - * Get legal values. - * - * @return List of legal values (as {@link String}s). - */ - public abstract List getValues(); - - /** - * Serialize this element as an XML node. - * - * @param doc The document that will own this node. - * @return The XML element <resAttributes> representing these attributes. - * @throws DOMException If an error occurs creating the XML nodes. - */ - public Node toXML(Document doc) throws DOMException { - return toXML(doc, /*withValues*/true); - } - - /** - * Serialize this element as an XML node without any values. - * - * @param doc The document that will own this node. - * @return The XML element <resAttributes> representing these attributes. - * @throws DOMException If an error occurs creating the XML nodes. - */ - public Node toXMLWithoutValues(Document doc) throws DOMException { - return toXML(doc, /*withValues*/false); - } - - /** - * Serialize this element. - * - * @param doc The document that will own this node. - * @param withValues If true, serialize the values as well. - * @return The XML element <profElement> representing this element. - * @throws DOMException If an error occurs creating the XML nodes. - */ - private Node toXML(Document doc, boolean withValues) throws DOMException { - Element profElement = doc.createElement("profElement"); - XML.addNonNull(profElement, "elemId", id); - XML.addNonNull(profElement, "elemName", name); - XML.addNonNull(profElement, "elemDesc", desc); - XML.addNonNull(profElement, "elemType", type); - XML.addNonNull(profElement, "elemUnit", unit); - XML.add(profElement, "elemEnumFlag", isEnumerated()? "T" : "F"); - if (withValues) { - addValues(profElement); - } - XML.add(profElement, "elemSynonym", synonyms); - if (isObligatory()) { - XML.add(profElement, "elemObligation", "Required"); - } - if (getMaxOccurrence() >= 0) { - XML.add(profElement, "elemMaxOccurrence", String.valueOf(getMaxOccurrence())); - } - XML.add(profElement, "elemComment", comments); - return profElement; - } - - /** - * Tell if this element is of the enumerated kind. - * - * @return a <code>boolean</code> value. - */ - protected abstract boolean isEnumerated(); - - /** - * Add the values of this element to the given node. - * - * @param node The node to add to. - * @throws DOMException If an error occurs creating the XML nodes. - */ - protected abstract void addValues(Node node) throws DOMException; - - /** - * Add this element to an RDF model including this element's profile. - * - * @param model The model to which we're being added. - * @param resource The profile as an RDF resource description. - * @param profAttr The profile's attributes. - */ - void addToModel(Model model, Resource resource, ProfileAttributes profAttr) { - URI profileURI = profile.getURI(); - URI myURI = URI.create(profileURI.toString() + "#" + name); - - Resource element = model.createResource(myURI.toString()); - Utility.addProperty(model, resource, Utility.edmElement, element, profAttr, myURI); - - String obStr = obligation? "Required" : "Optional"; - String occurStr = String.valueOf(maxOccurrence); - - Utility.addProperty(model, element, Utility.edmElemID, id, profAttr, myURI); - Utility.addProperty(model, element, Utility.edmDescription, desc, profAttr, myURI); - Utility.addProperty(model, element, Utility.edmElemType, type, profAttr, myURI); - Utility.addProperty(model, element, Utility.edmUnit, unit, profAttr, myURI); - Utility.addProperty(model, element, Utility.edmSynonym, synonyms, profAttr, myURI); - Utility.addProperty(model, element, Utility.edmObligation, obStr, profAttr, myURI); - Utility.addProperty(model, element, Utility.edmMaxOccurrence, occurStr, profAttr, myURI); - Utility.addProperty(model, element, Utility.edmComment, comments, profAttr, myURI); - - addElementSpecificProperties(model, element, profAttr, myURI); - } - - /** - * Add the statements specific to this kind of profile element to an RDF model. - * - * @param model The model. - * @param element This element, as an RDF resource. - * @param profAttr The attributes of the element's profile. - */ - protected abstract void addElementSpecificProperties(Model model, Resource element, ProfileAttributes profAttr, URI uri); - - /** My profile. */ - protected Profile profile; - - /** My required name. */ - protected String name; - - /** My optional id. */ - protected String id; - - /** My optional description. */ - protected String desc; - - /** My optional type. */ - protected String type; - - /** My optional unit. */ - protected String unit; - - /** My synonyms. */ - protected List<?> synonyms; - - /** My obligation. */ - protected boolean obligation; - - /** My maxOccurrence. */ - protected int maxOccurrence; - - /** My optional comments. */ - protected String comments; - - /** - * Create a <profElement> document using the profiles DTD. - * - * @return A <profElement> document with the profiles DTD. - */ - public static Document createProfElementDocument() { - return Profile.createDocument("profElement"); - } - - /** - * Given a set of profile elements, return a set of profiles that own those elements. - * - * @param elements Profile elements. - * @return Profiles that own those elements. - */ - public static Set<Profile> profiles(Set<?> elements) { - Set<Profile> rc = new HashSet<Profile>(); - for (Object element1 : elements) { - ProfileElement element = (ProfileElement) element1; - rc.add(element.getProfile()); - } - return rc; - } - - /** - * Given a set of profiles and of profile elements, return those elements that - * are owned by any of the given profiles. - * - * @param profiles Profiles. - * @param elements Profile elements. - * @return Members of <var>elements</var> that are owned by members of <var>profiles</var>. - */ - public static Set<ProfileElement> elements(Set<?> profiles, Set<?> elements) { - Set<ProfileElement> rc = new HashSet<ProfileElement>(); - for (Object element1 : elements) { - ProfileElement element = (ProfileElement) element1; - if (profiles.contains(element.getProfile())) { - rc.add(element); - } - } - return rc; - } - - static String text(Node node) { - StringBuffer b = new StringBuffer(); - text0(b, node); - return b.toString(); - } - - static void text0(StringBuffer b, Node node) { - if (node.getNodeType() == Node.TEXT_NODE || node.getNodeType() == Node.CDATA_SECTION_NODE) { - b.append(node.getNodeValue()); - return; - } - NodeList children = node.getChildNodes(); - for (int i = 0; i < children.getLength(); ++i) { - text0(b, children.item(i)); - } - } -} - http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/profile/src/main/java/org/apache/oodt/profile/ProfileException.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/ProfileException.java b/profile/src/main/java/org/apache/oodt/profile/ProfileException.java deleted file mode 100644 index 8124e6b..0000000 --- a/profile/src/main/java/org/apache/oodt/profile/ProfileException.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.oodt.profile; - -/** - * A profile-related exception. - * - * @author Kelly - */ -public class ProfileException extends Exception { - /** - * Create a profile exception with no detail message. - */ - public ProfileException() {} - - /** - * Create a profile exception with the given detail message. - */ - public ProfileException(String message) { - super(message); - } - - /** - * Create a chained profile exception. - * - * @param cause Causing exception. - */ - public ProfileException(Throwable cause) { - super(cause); - } - - /** - * Creates a chained profile exception with detail message. - * - * @param msg Detail message. - * @param cause Causing exception. - */ - public ProfileException(String msg, Throwable cause) { - super(msg, cause); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/profile/src/main/java/org/apache/oodt/profile/ProfileSAXException.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/ProfileSAXException.java b/profile/src/main/java/org/apache/oodt/profile/ProfileSAXException.java deleted file mode 100644 index 62a40f6..0000000 --- a/profile/src/main/java/org/apache/oodt/profile/ProfileSAXException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.oodt.profile; - -import org.xml.sax.SAXException; - -/** - * An XML-related SAX exception from a profile server. - * - * @author Kelly - */ -public class ProfileSAXException extends ProfileException { - /** - * Create a profile SAX exception. - * - * @param cause The SAX exception that caused this profile exception. - */ - public ProfileSAXException(SAXException cause) { - super(cause); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/profile/src/main/java/org/apache/oodt/profile/ProfileSQLException.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/ProfileSQLException.java b/profile/src/main/java/org/apache/oodt/profile/ProfileSQLException.java deleted file mode 100644 index 0ae7b95..0000000 --- a/profile/src/main/java/org/apache/oodt/profile/ProfileSQLException.java +++ /dev/null @@ -1,34 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one or more contributor -// license agreements. See the NOTICE.txt file distributed with this work for -// additional information regarding copyright ownership. The ASF licenses this -// file to you 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.apache.oodt.profile; - -import java.sql.SQLException; - -/** - * A database-related SQL exception from a profile server. - * - * @author Kelly - */ -public class ProfileSQLException extends ProfileException { - /** - * Create a profile SQL exception. - * - * @param cause The SQL exception that caused this profile exception. - */ - public ProfileSQLException(SQLException cause) { - super(cause); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/profile/src/main/java/org/apache/oodt/profile/RangedProfileElement.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/RangedProfileElement.java b/profile/src/main/java/org/apache/oodt/profile/RangedProfileElement.java deleted file mode 100644 index 5c98743..0000000 --- a/profile/src/main/java/org/apache/oodt/profile/RangedProfileElement.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.oodt.profile; - -import org.apache.jena.rdf.model.Model; -import org.apache.jena.rdf.model.Resource; -import org.apache.oodt.commons.util.XML; -import org.w3c.dom.DOMException; -import org.w3c.dom.Node; - -import java.net.URI; -import java.util.Collections; -import java.util.List; - -/** - * Ranged profile element. - * - * Objects of this class are elements of a profile that represent a range of values. - * - * @author Kelly - */ -public class RangedProfileElement extends ProfileElement { - /** - * Create blank profile attributes belonging to the given profile. - */ - public RangedProfileElement(Profile profile) { - super(profile); - min = ""; - max = ""; - } - - /** - * Create a profile element from constituent attributes. - * - * @param profile Profile to which this element belongs. - * @param name Required name of the element. - * @param id ID of the element. - * @param desc Long description of the element. - * @param type Data type of the element. - * @param unit Units. - * @param synonyms Collection of element IDs ({@link String}) that are synonyms for this element. - * @param obligation True if this is a required element - * @param maxOccurrence Maximum number of occurrences of this element. - * @param comment Any comments about this element. - * @param min Minimum value. - * @param max Maximum value. - */ - public RangedProfileElement(Profile profile, String name, String id, String desc, String type, String unit, List synonyms, - boolean obligation, int maxOccurrence, String comment, String min, String max) { - super(profile, name, id, desc, type, unit, synonyms, obligation, maxOccurrence, comment); - this.min = min; - this.max = max; - } - - protected boolean isEnumerated() { - return false; - } - - public void setMinValue(String min){ - this.min = min; - - } - - public void setMaxValue(String max){ - this.max = max; - - } - - protected void addValues(Node node) throws DOMException { - XML.add(node, "elemMinValue", min); - XML.add(node, "elemMaxValue", max); - } - - public String getMinValue() { - return String.valueOf(min); - } - - public String getMaxValue() { - return String.valueOf(max); - } - - public List getValues() { - return Collections.EMPTY_LIST; - } - - protected void addElementSpecificProperties(Model model, Resource element, ProfileAttributes profAttr, URI uri) { - Utility.addProperty(model, element, Utility.edmMinValue, min, profAttr, uri); - Utility.addProperty(model, element, Utility.edmMaxValue, max, profAttr, uri); - } - - /** Minimum value. */ - protected String min; - - /** Maximum value. */ - protected String max; - - /** Serial version unique ID. */ - static final long serialVersionUID = -5697102597443089753L; -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/profile/src/main/java/org/apache/oodt/profile/ResourceAttributes.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/ResourceAttributes.java b/profile/src/main/java/org/apache/oodt/profile/ResourceAttributes.java deleted file mode 100644 index d0b1e55..0000000 --- a/profile/src/main/java/org/apache/oodt/profile/ResourceAttributes.java +++ /dev/null @@ -1,602 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.oodt.profile; - -import org.apache.jena.rdf.model.Model; -import org.apache.jena.rdf.model.Resource; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import org.apache.oodt.commons.util.Documentable; -import org.apache.oodt.commons.util.XML; -import org.w3c.dom.DOMException; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import java.net.URI; - -/** - * Resource attribuets. - * - * Objects of this class are resource attributes of profiles. - * - * @author Kelly - */ -public class ResourceAttributes implements Serializable, Cloneable, Comparable<Object>, Documentable { - /** - * Create blank profile attributes. - */ - public ResourceAttributes() { - this(/*profile*/null); - } - - /** - * Create blank profile attributes belonging to a certain profile. - * - * @param profile Owning profile. - */ - public ResourceAttributes(Profile profile) { - this.profile = profile; - identifier = "UNKNOWN"; - - // Other attributes are optional according to prof.dtd. - initializeLists(); - } - - /** - * Create resource attributes from an XML document. - * - * @param profile Owning profile. - * @param root The <resAttributes> element. - */ - public ResourceAttributes(Profile profile, Node root) { - this.profile = profile; - initializeLists(); - NodeList children = root.getChildNodes(); - for (int i = 0; i < children.getLength(); ++i) { - Node node = children.item(i); - if ("Identifier".equals(node.getNodeName())) { - identifier = XML.unwrappedText(node); - } else if ("Title".equals(node.getNodeName())) { - title = XML.unwrappedText(node); - } else if ("Format".equals(node.getNodeName())) { - formats.add(XML.unwrappedText(node)); - } else if ("Description".equals(node.getNodeName())) { - description = XML.unwrappedText(node); - } else if ("Creator".equals(node.getNodeName())) { - creators.add(XML.unwrappedText(node)); - } else if ("Subject".equals(node.getNodeName())) { - subjects.add(XML.unwrappedText(node)); - } else if ("Publisher".equals(node.getNodeName())) { - publishers.add(XML.unwrappedText(node)); - } else if ("Contributor".equals(node.getNodeName())) { - contributors.add(XML.unwrappedText(node)); - } else if ("Date".equals(node.getNodeName())) { - dates.add(XML.unwrappedText(node)); - } else if ("Type".equals(node.getNodeName())) { - types.add(XML.unwrappedText(node)); - } else if ("Source".equals(node.getNodeName())) { - sources.add(XML.unwrappedText(node)); - } else if ("Language".equals(node.getNodeName())) { - languages.add(XML.unwrappedText(node)); - } else if ("Relation".equals(node.getNodeName())) { - relations.add(XML.unwrappedText(node)); - } else if ("Coverage".equals(node.getNodeName())) { - coverages.add(XML.unwrappedText(node)); - } else if ("Rights".equals(node.getNodeName())) { - rights.add(XML.unwrappedText(node)); - } else if ("resContext".equals(node.getNodeName())) { - contexts.add(XML.unwrappedText(node)); - } else if ("resAggregation".equals(node.getNodeName())) { - aggregation = XML.unwrappedText(node); - } else if ("resClass".equals(node.getNodeName())) { - clazz = XML.unwrappedText(node); - } else if ("resLocation".equals(node.getNodeName())) { - locations.add(XML.unwrappedText(node)); - } - } - } - - /** - * Create resource attributes from constituent attributes. - * - * According to the Dublin Core, these attributes may be multivalued, but we force - * the identifier, title, and description to be singly values in the DTD, so it is - * here, too. Unless otherwise specified, these are all collections of {@link - * String}. - * - * @param profile Owning profile. - * @param identifier The unique identifier. - * @param title Title of the resource. - * @param formats Format of the resource. - * @param description Description of the resource. - * @param creators Who/what created the resource. - * @param subjects Subject matter covered by the resource. - * @param publishers Who/what published the resrouce. - * @param contributors Who/what contributed to the resource. - * @param dates When the resource was created (collection of {@link java.util.Date}. - * @param types Type of the resource. - * @param sources Source of the resource. - * @param languages Language in which the resource is written. - * @param relations Relationships to the resource. - * @param coverages Coverage of the resource. - * @param rights Rights of the resource. - * @param contexts Context of the resource. - * @param aggregation Aggregation of the resource. - * @param clazz Class of the resource. - * @param locations Location of the resource. - */ - public ResourceAttributes(Profile profile, String identifier, String title, List<String> formats, String description, - List<String> creators, List<String> subjects, List<String> publishers, List<String> contributors, List<String> dates, List<String> types, List<String> sources, - List<String> languages, List<String> relations, List<String> coverages, List<String> rights, List<String> contexts, String aggregation, String clazz, - List<String> locations) { - this.profile = profile; - this.identifier = identifier; - this.title = title; - this.formats = formats; - this.description = description; - this.creators = creators; - this.subjects = subjects; - this.publishers = publishers; - this.contributors = contributors; - this.dates = dates; - this.types = types; - this.sources = sources; - this.languages = languages; - this.relations = relations; - this.coverages = coverages; - this.rights = rights; - this.contexts = contexts; - this.aggregation = aggregation; - this.clazz = clazz; - this.locations = locations; - } - - public int hashCode() { - return identifier.hashCode(); - } - - public boolean equals(Object rhs) { - if (rhs == this) { - return true; - } - if (rhs == null || !(rhs instanceof ResourceAttributes)) { - return false; - } - return ((ResourceAttributes) rhs).identifier.equals(identifier); - } - - public int compareTo(Object rhs) { - ResourceAttributes obj = (ResourceAttributes) rhs; - return identifier.compareTo(obj.identifier); - } - - public String toString() { - return getClass().getName() + "[identifer=" + identifier + "]"; - } - - public Object clone() { - Object clone = null; - try { - clone = super.clone(); - } catch (CloneNotSupportedException ignored) {} - return clone; - } - - /** - * Add resource attribute statements to the profile description in an RDF model. - * - * @param model Model to which the profile belongs. - * @param resource Resource description of the profile. - * @param profAttr Profile's attributes. - */ - void addToModel(Model model, Resource resource, ProfileAttributes profAttr) { - URI myURI = getURI(); - - Utility.addProperty(model, resource, Utility.dcTitle, title, profAttr, myURI); - Utility.addProperty(model, resource, Utility.dcFormat, formats, profAttr, myURI); - Utility.addProperty(model, resource, Utility.dcDescription, description, profAttr, myURI); - Utility.addProperty(model, resource, Utility.dcCreator, creators, profAttr, myURI); - Utility.addProperty(model, resource, Utility.dcSubject, subjects, profAttr, myURI); - Utility.addProperty(model, resource, Utility.dcPublisher, publishers, profAttr, myURI); - Utility.addProperty(model, resource, Utility.dcContributor, contributors, profAttr, myURI); - Utility.addProperty(model, resource, Utility.dcDate, dates, profAttr, myURI); - Utility.addProperty(model, resource, Utility.dcType, types, profAttr, myURI); - Utility.addProperty(model, resource, Utility.dcSource, sources, profAttr, myURI); - Utility.addProperty(model, resource, Utility.dcLanguage, languages, profAttr, myURI); - Utility.addProperty(model, resource, Utility.dcRelation, relations, profAttr, myURI); - Utility.addProperty(model, resource, Utility.dcRights, rights, profAttr, myURI); - Utility.addProperty(model, resource, Utility.edmContext, contexts, profAttr, myURI); - Utility.addProperty(model, resource, Utility.edmAggregation, aggregation, profAttr, myURI); - Utility.addProperty(model, resource, Utility.edmClass, clazz, profAttr, myURI); - Utility.addProperty(model, resource, Utility.edmLocation, locations, profAttr, myURI); - } - - public URI getURI() { - String identification; - if (identifier == null || identifier.length() == 0) { - if (locations.isEmpty()) { - identification = null; - } else { - identification = (String) locations.get(0); - } - } else { - identification = identifier; - } - - return identification == null? UNKNOWN_URI : URI.create(identification); - } - - /** - * Get the identifier. - * - * @return The identifier. - */ - public String getIdentifier() { - return identifier; - } - - /** - * Set the identifier. - * - * @param identifier The identifier. - */ - public void setIdentifier(String identifier) { - this.identifier = identifier; - } - - /** - * Get the title. - * - * @return The title. - */ - public String getTitle() { - return title; - } - - /** - * Set the title. - * - * @param title The title. - */ - public void setTitle(String title) { - this.title = title; - } - - - /** - * Get the formats. - * - * @return The formats. - */ - public List<String> getFormats() { - return formats; - } - - /** - * Set the description. - * - * @param description The new description. - */ - public void setDescription(String description) { - this.description = description; - } - - /** - * Get the description. - * - * @return The description. - */ - public String getDescription() { - return description; - } - - /** - * Get the creators. - * - * @return The creators. - */ - public List<String> getCreators() { - return creators; - } - - /** - * Get the subjects. - * - * @return The subjects. - */ - public List<String> getSubjects() { - return subjects; - } - - /** - * Get the publishers. - * - * @return The publishers. - */ - public List<String> getPublishers() { - return publishers; - } - - /** - * Get the contributors. - * - * @return The contributors. - */ - public List<String> getContributors() { - return contributors; - } - - /** - * Get the dates. - * - * @return The dates. - */ - public List<String> getDates() { - return dates; - } - - /** - * Get the types. - * - * @return The types. - */ - public List<String> getTypes() { - return types; - } - - /** - * Get the sources. - * - * @return The sources. - */ - public List<String> getSources() { - return sources; - } - - /** - * Get the languages. - * - * @return The languages. - */ - public List<String> getLanguages() { - return languages; - } - - /** - * Get the relations. - * - * @return The relations. - */ - public List<String> getRelations() { - return relations; - } - - /** - * Get the coverages. - * - * @return The coverages. - */ - public List<String> getCoverages() { - return coverages; - } - - /** - * Get the rights. - * - * @return The rights. - */ - public List<String> getRights() { - return rights; - } - - /** - * Get the contexts. - * - * @return The contexts, a list of {@link String}s. - */ - public List<String> getResContexts() { - return contexts; - } - - - /** - * Get the aggregation. - * - * @return The aggregation. - */ - public String getResAggregation() { - return aggregation; - } - - /** - * Set the aggregation. - * - * @param aggregation The aggregation. - */ - public void setResAggregation(String aggregation) { - this.aggregation = aggregation; - } - - /** - * Get the class. - * - * @return The class. - */ - public String getResClass() { - return clazz; - } - - /** - * Set the class. - * - * @param clazz The class. - */ - public void setResClass(String clazz) { - this.clazz = clazz; - } - - /** - * Get the locations. - * - * @return Locations, a list of {@link String}s. - */ - public List<String> getResLocations() { - return locations; - } - - - /** - * Initialize all the various {@link java.util.List} fields. - */ - protected void initializeLists() { - formats = new ArrayList<String>(); - creators = new ArrayList<String>(); - subjects = new ArrayList<String>(); - publishers = new ArrayList<String>(); - contributors = new ArrayList<String>(); - dates = new ArrayList<String>(); - types = new ArrayList<String>(); - sources = new ArrayList<String>(); - languages = new ArrayList<String>(); - relations = new ArrayList<String>(); - coverages = new ArrayList<String>(); - rights = new ArrayList<String>(); - contexts = new ArrayList<String>(); - locations = new ArrayList<String>(); - } - - /** Profile I describe. */ - protected Profile profile; - - /** Identifer. */ - protected String identifier; - - /** Titles. */ - protected String title; - - /** Formats. */ - protected List<String> formats; - - /** Descriptions. */ - protected String description; - - /** Creators. */ - protected List<String> creators; - - /** Subjects. */ - protected List<String> subjects; - - /** Publishers. */ - protected List<String> publishers; - - /** Contributors. */ - protected List<String> contributors; - - /** Dates. */ - protected List<String> dates; - - /** Types. */ - protected List<String> types; - - /** Sources. */ - protected List<String> sources; - - /** Languages. */ - protected List<String> languages; - - /** Relations. */ - protected List<String> relations; - - /** Coverages. */ - protected List<String> coverages; - - /** Rights. */ - protected List<String> rights; - - /** Contexts, one or more list of {@link String}s. */ - protected List<String> contexts; - - /** Aggregation. */ - protected String aggregation; - - /** Clazz. */ - protected String clazz; - - /** Locations, zero or more {@link String}s. */ - protected List<String> locations; - - /** - * Serialize this attributes as an XML node. - * - * @param doc The document that will own this node. - * @return The XML element <resAttributes> representing these attributes. - * @throws DOMException If an error occurs creating the XML nodes. - */ - public Node toXML(Document doc) throws DOMException { - Element root = doc.createElement("resAttributes"); - XML.add(root, "Identifier", identifier); - XML.addNonNull(root, "Title", title); - XML.add(root, "Format", formats); - XML.addNonNull(root, "Description", description); - XML.add(root, "Creator", creators); - XML.add(root, "Subject", subjects); - XML.add(root, "Publisher", publishers); - XML.add(root, "Contributor", contributors); - XML.add(root, "Date", dates); - XML.add(root, "Type", types); - XML.add(root, "Source", sources); - XML.add(root, "Language", languages); - XML.add(root, "Relation", relations); - XML.add(root, "Coverage", coverages); - XML.add(root, "Rights", rights); - List<String> contexts = new ArrayList<String>(this.contexts); - if (contexts.isEmpty()) { - contexts.add("UNKNOWN"); - } - XML.add(root, "resContext", contexts); - XML.addNonNull(root, "resAggregation", aggregation); - if(clazz==null) { - clazz = "UNKNOWN"; - } - XML.addNonNull(root, "resClass", clazz); - XML.add(root, "resLocation", locations); - - return root; - } - - /** - * Create a <resAttributes> document using the profiles DTD. - * - * @return A <resAttributs> document with the profiles DTD. - */ - public static Document createResAttributesDocument() { - return Profile.createDocument("resAttributes"); - } - - /** URI of a profile whose URI is unknown. */ - private static final URI UNKNOWN_URI = URI.create("urn:eda:profile:UNKNOWN"); - - /** Serial version unique ID. */ - static final long serialVersionUID = -4251763559607642607L; -}
