You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by da...@apache.org on 2018/01/27 00:41:37 UTC
[2/7] atlas git commit: ATLAS-1095:final code drop for OCF
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/NoteLogs.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/NoteLogs.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/NoteLogs.java
new file mode 100644
index 0000000..5f4ac05
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/NoteLogs.java
@@ -0,0 +1,127 @@
+/*
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.atlas.ocf.properties;
+
+import java.util.Iterator;
+
+/**
+ * NoteLogs supports an iterator over a list of note logs. Callers can use it to step through the list
+ * just once. If they want to parse the list again, they could use the copy/clone constructor to create
+ * a new iterator.
+ */
+public abstract class NoteLogs extends AssetPropertyIteratorBase implements Iterator<NoteLog>
+{
+ /**
+ * Typical Constructor creates an iterator with the supplied list of elements.
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @param totalElementCount - the total number of elements to process. A negative value is converted to 0.
+ * @param maxCacheSize - maximum number of elements that should be retrieved from the property server and
+ * cached in the element list at any one time. If a number less than one is supplied, 1 is used.
+ */
+ public NoteLogs(AssetDescriptor parentAsset,
+ int totalElementCount,
+ int maxCacheSize)
+ {
+ super(parentAsset, totalElementCount, maxCacheSize);
+ }
+
+
+ /**
+ * Copy/clone constructor. Used to reset iterator element pointer to 0;
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @param template - type-specific iterator to copy; null to create an empty iterator
+ */
+ public NoteLogs(AssetDescriptor parentAsset, NoteLogs template)
+ {
+ super(parentAsset, template);
+ }
+
+
+ /**
+ * Provides a concrete implementation of cloneElement for the specific iterator type.
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @param template - object to clone
+ * @return new cloned object.
+ */
+ protected AssetPropertyBase cloneElement(AssetDescriptor parentAsset, AssetPropertyBase template)
+ {
+ return new NoteLog(parentAsset, (NoteLog)template);
+ }
+
+
+ /**
+ * Clones this iterator.
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @return new cloned object.
+ */
+ protected abstract NoteLogs cloneIterator(AssetDescriptor parentAsset);
+
+
+ /**
+ * The iterator can only be used once to step through the elements. This method returns
+ * a boolean to indicate if it has got to the end of the list yet.
+ *
+ * @return boolean indicating whether there are more elements.
+ */
+ @Override
+ public boolean hasNext()
+ {
+ return super.pagingIterator.hasNext();
+ }
+
+
+ /**
+ * Return the next element in the iteration.
+ *
+ * @return NoteLog - next element object that has been cloned.
+ */
+ @Override
+ public NoteLog next()
+ {
+ return (NoteLog)super.pagingIterator.next();
+ }
+
+
+ /**
+ * Remove the current element in the iterator. (Null implementation since this iterator works off of cached
+ * elements from the property (metadata) server.)
+ */
+ @Override
+ public void remove()
+ {
+ super.pagingIterator.remove();
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return print out of variables in a JSON-style
+ */
+ @Override
+ public String toString()
+ {
+ return "NoteLogs{" +
+ "pagingIterator=" + pagingIterator +
+ '}';
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Notes.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Notes.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Notes.java
new file mode 100644
index 0000000..077d7fa
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Notes.java
@@ -0,0 +1,127 @@
+/*
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.atlas.ocf.properties;
+
+import java.util.Iterator;
+
+/**
+ * Notes supports an iterator over a list of notes within a note log. Callers can use it to step through the list
+ * just once. If they want to parse the list again, they could use the copy/clone constructor to create
+ * a new iterator.
+ */
+public abstract class Notes extends AssetPropertyIteratorBase implements Iterator<Note>
+{
+ /**
+ * Typical Constructor creates an iterator with the supplied list of elements.
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @param totalElementCount - the total number of elements to process. A negative value is converted to 0.
+ * @param maxCacheSize - maximum number of elements that should be retrieved from the property server and
+ * cached in the element list at any one time. If a number less than one is supplied, 1 is used.
+ */
+ public Notes(AssetDescriptor parentAsset,
+ int totalElementCount,
+ int maxCacheSize)
+ {
+ super(parentAsset, totalElementCount, maxCacheSize);
+ }
+
+
+ /**
+ * Copy/clone constructor. Used to reset iterator element pointer to 0;
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @param template - type-specific iterator to copy; null to create an empty iterator
+ */
+ public Notes(AssetDescriptor parentAsset, Notes template)
+ {
+ super(parentAsset, template);
+ }
+
+
+ /**
+ * Provides a concrete implementation of cloneElement for the specific iterator type.
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @param template - object to clone
+ * @return new cloned object.
+ */
+ protected AssetPropertyBase cloneElement(AssetDescriptor parentAsset, AssetPropertyBase template)
+ {
+ return new Note(parentAsset, (Note)template);
+ }
+
+
+ /**
+ * Clones this iterator.
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @return new cloned object.
+ */
+ protected abstract Notes cloneIterator(AssetDescriptor parentAsset);
+
+
+ /**
+ * The iterator can only be used once to step through the elements. This method returns
+ * a boolean to indicate if it has got to the end of the list yet.
+ *
+ * @return boolean indicating whether there are more elements.
+ */
+ @Override
+ public boolean hasNext()
+ {
+ return super.pagingIterator.hasNext();
+ }
+
+
+ /**
+ * Return the next element in the iteration.
+ *
+ * @return Note - next element object that has been cloned.
+ */
+ @Override
+ public Note next()
+ {
+ return (Note)super.pagingIterator.next();
+ }
+
+
+ /**
+ * Remove the current element in the iterator. (Null implementation since this iterator works off of cached
+ * elements from the property (metadata) server.)
+ */
+ @Override
+ public void remove()
+ {
+ super.pagingIterator.remove();
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return print out of variables in a JSON-style
+ */
+ @Override
+ public String toString()
+ {
+ return "Notes{" +
+ "pagingIterator=" + pagingIterator +
+ '}';
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/PagingIterator.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/PagingIterator.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/PagingIterator.java
new file mode 100644
index 0000000..8928041
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/PagingIterator.java
@@ -0,0 +1,337 @@
+/*
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.atlas.ocf.properties;
+
+import org.apache.atlas.ocf.ffdc.OCFErrorCode;
+import org.apache.atlas.ocf.ffdc.OCFRuntimeException;
+import org.apache.atlas.ocf.ffdc.PropertyServerException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * PagingIterator supports an iterator over a list of objects that extend AssetPropertyBase.
+ * Callers can use it to step through the list just once. If they want to parse the list again,
+ * they could use the copy/clone constructor to create a new iterator.
+ *
+ * PagingIterator provides paging support to enable the list in the iterator to be much bigger than
+ * can be stored in memory. It maintains pointers for the full list, and a potentially smaller
+ * cached list that is used to batch up elements being retrieved from the property (metadata) server.
+ * Thus is combines the ability to process very large lists whilst minimising the chatter with the property server.
+ *
+ * The class uses a number of pointers and counts. Imagine a list of 4000 columns in a table.
+ * We can not retrieve all 4000 columns on one call. So we retrieve subsets over a number of REST calls as the
+ * caller walks through the full list.
+ * <ul>
+ * <li>
+ * totalElement is 4000 - ie how many elements there are in total.
+ * </li>
+ * <li>
+ * maxCacheSize is the maximum elements we can retrieve in one call
+ * </li>
+ * <li>
+ * cachedElementList.size() is how many elements we have in memory at this time.
+ * </li>
+ * </ul>
+ *
+ * cachedElementList.size() is set to maxCacheSize() for all retrieves except for processing the last cache of elements.
+ * For example, if the totalElement is 25 and the maxCacheSize() is 10 then we would retrieve 3 caches -
+ * the first two would have 10 elements in them and the third will have 5 elements.
+ * In the first 2 retrieves, maxCacheSize and cachedElementList.size() are set to 10.
+ * In the last one, maxCacheSize==10 and cachedElementList.size()==5.
+ */
+public class PagingIterator extends AssetPropertyBase implements Iterator<AssetPropertyBase>
+{
+ private int maxCacheSize = 1;
+
+ private int totalElementCount = 0;
+ private int cachedElementStart = 0;
+ private ArrayList<AssetPropertyBase> cachedElementList = new ArrayList<>();
+ private int cachedElementPointer = 0;
+
+ private AssetPropertyIteratorBase iterator = null;
+
+ private static final Logger log = LoggerFactory.getLogger(PagingIterator.class);
+
+
+
+ /**
+ * Typical Constructor creates an iterator with the supplied list of comments.
+ *
+ * @param parentAsset - descriptor of parent asset.
+ * @param iterator - type-specific iterator that wraps this paging iterator.
+ * @param totalElementCount - the total number of elements to process. A negative value is converted to 0.
+ * @param maxCacheSize - maximum number of elements that should be retrieved from the property server and
+ * cached in the element list at any one time. If a number less than one is supplied, 1 is used.
+ */
+ public PagingIterator(AssetDescriptor parentAsset,
+ AssetPropertyIteratorBase iterator,
+ int totalElementCount,
+ int maxCacheSize)
+ {
+ super(parentAsset);
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("New PagingIterator:");
+ log.debug("==> totalElementCount: " + totalElementCount);
+ log.debug("==> maxCacheSize: " + maxCacheSize);
+ }
+
+
+ if (totalElementCount > 0)
+ {
+ this.totalElementCount = totalElementCount;
+ }
+
+ if (maxCacheSize > 0)
+ {
+ this.maxCacheSize = maxCacheSize;
+ }
+
+ if (iterator != null)
+ {
+ this.iterator = iterator;
+ }
+ else
+ {
+ /*
+ * Throw runtime exception to show the caller they are not using the list correctly.
+ */
+ OCFErrorCode errorCode = OCFErrorCode.NO_ITERATOR;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(this.getClass().getSimpleName(),
+ super.getParentAssetName(),
+ super.getParentAssetTypeName());
+
+ throw new OCFRuntimeException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "next",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Copy/clone constructor. Used to reset iterator element pointer to 0;
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @param iterator - type-specific iterator that wraps this paging iterator.
+ * @param templateIterator - template to copy; null to create an empty iterator
+ */
+ public PagingIterator(AssetDescriptor parentAsset,
+ AssetPropertyIteratorBase iterator,
+ PagingIterator templateIterator)
+ {
+ super(parentAsset, templateIterator);
+
+ if (templateIterator != null)
+ {
+ this.cachedElementStart = 0;
+ this.cachedElementPointer = 0;
+ this.cachedElementList = new ArrayList<>();
+
+ if (templateIterator.totalElementCount > 0)
+ {
+ this.totalElementCount = templateIterator.totalElementCount;
+ }
+
+ if (templateIterator.maxCacheSize > 0)
+ {
+ this.maxCacheSize = templateIterator.maxCacheSize;
+ }
+
+ if (iterator != null)
+ {
+ this.iterator = iterator;
+ }
+ else
+ {
+ /*
+ * Throw runtime exception to show the caller they are not using the list correctly.
+ */
+ OCFErrorCode errorCode = OCFErrorCode.NO_ITERATOR;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(this.getClass().getSimpleName(),
+ super.getParentAssetName(),
+ super.getParentAssetTypeName());
+
+ throw new OCFRuntimeException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "next",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ if (templateIterator.cachedElementStart == 0)
+ {
+ /*
+ * The template's cache starts at the beginning of the total list so ok to copy it.
+ */
+ for (AssetPropertyBase templateElement : templateIterator.cachedElementList)
+ {
+ this.cachedElementList.add(iterator.cloneElement(parentAsset, templateElement));
+ }
+ }
+ }
+ }
+
+
+ /**
+ * The iterator can only be used once to step through the elements. This method returns
+ * a boolean to indicate if it has got to the end of the list yet.
+ *
+ * @return boolean indicating whether there are more elements.
+ */
+ @Override
+ public boolean hasNext()
+ {
+ return (cachedElementStart < totalElementCount);
+ }
+
+
+ /**
+ * Return the next element in the list
+ *
+ * @return AssetPropertyBase - next element.
+ * @throws OCFRuntimeException - if there are no more elements in the list or there are problems retrieving
+ * elements from the property (metadata) server.
+ */
+ @Override
+ public AssetPropertyBase next()
+ {
+ /*
+ * Check more elements available
+ */
+ if (this.hasNext())
+ {
+ AssetPropertyBase retrievedElement = null;
+
+ /*
+ * If the pointer is at the end of the cache then retrieve more content from the property (metadata)
+ * server.
+ */
+ if (cachedElementPointer == cachedElementList.size())
+ {
+ try
+ {
+ cachedElementList = iterator.getCachedList(cachedElementStart, maxCacheSize);
+ cachedElementPointer = 0;
+ }
+ catch (PropertyServerException error)
+ {
+ /*
+ * Problem retrieving next cache. The exception includes a detailed error message,
+ */
+ OCFErrorCode errorCode = OCFErrorCode.PROPERTIES_NOT_AVAILABLE;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(error.getErrorMessage(),
+ this.toString());
+
+ throw new OCFRuntimeException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "next",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ error);
+ }
+ }
+
+ retrievedElement = iterator.cloneElement(getParentAsset(), cachedElementList.get(cachedElementPointer));
+ cachedElementPointer++;
+ cachedElementStart++;
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Returning next element:");
+ log.debug("==> totalElementCount: " + totalElementCount);
+ log.debug("==> cachedElementPointer: " + cachedElementPointer);
+ log.debug("==> cachedElementStart:" + cachedElementStart);
+ log.debug("==> maxCacheSize:" + maxCacheSize);
+ }
+
+
+ return retrievedElement;
+ }
+ else
+ {
+ /*
+ * Throw runtime exception to show the caller they are not using the list correctly.
+ */
+ OCFErrorCode errorCode = OCFErrorCode.NO_MORE_ELEMENTS;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(this.getClass().getSimpleName(),
+ super.getParentAssetName(),
+ super.getParentAssetTypeName());
+
+ throw new OCFRuntimeException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "next",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Return the number of elements in the list.
+ *
+ * @return elementCount
+ */
+ public int getElementCount()
+ {
+ return totalElementCount;
+ }
+
+
+ /**
+ * Remove the current element in the iterator.
+ */
+ @Override
+ public void remove()
+ {
+ /*
+ * Nothing to do since the removed element can never be revisited through this instance.
+ */
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return print out of variables in a JSON-style
+ */
+ @Override
+ public String toString()
+ {
+ return "PagingIterator{" +
+ "maxCacheSize=" + maxCacheSize +
+ ", totalElementCount=" + totalElementCount +
+ ", cachedElementStart=" + cachedElementStart +
+ ", cachedElementList=" + cachedElementList +
+ ", cachedElementPointer=" + cachedElementPointer +
+ '}';
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/PrimitiveSchemaElement.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/PrimitiveSchemaElement.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/PrimitiveSchemaElement.java
new file mode 100644
index 0000000..ea4b28a
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/PrimitiveSchemaElement.java
@@ -0,0 +1,150 @@
+/*
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.atlas.ocf.properties;
+
+
+/**
+ * PrimitiveSchemaElement describes a schema element that has a primitive type. This class stores which
+ * type of primitive type it is an a default value if supplied.
+ */
+public class PrimitiveSchemaElement extends SchemaElement
+{
+ private String dataType = null;
+ private String defaultValue = null;
+
+
+ /**
+ * Typical constructor
+ *
+ * @param parentAsset - descriptor for parent asset
+ * @param type - details of the metadata type for this properties object
+ * @param guid - String - unique id
+ * @param url - String - URL
+ * @param classifications - enumeration of classifications
+ * @param qualifiedName - unique name
+ * @param additionalProperties - additional properties for the referenceable object.
+ * @param meanings - list of glossary terms (summary)
+ * @param versionNumber - the version number of the schema element - null means no version number.
+ * @param author - the name of the author of the schema element. Null means the author is unknown.
+ * @param usage - the usage guidance for this schema element. Null means no guidance available.
+ * @param encodingStandard - encoding standard used for this schema. It may be XML, JSON, SQL DDL or something else.
+ * Null means the encoding standard is unknown or there are many choices.
+ * @param dataType - the name of the data type for this element. Null means unknown data type.
+ * @param defaultValue - String containing default value for the element
+ */
+ public PrimitiveSchemaElement(AssetDescriptor parentAsset,
+ ElementType type,
+ String guid,
+ String url,
+ Classifications classifications,
+ String qualifiedName,
+ AdditionalProperties additionalProperties,
+ Meanings meanings,
+ String versionNumber,
+ String author,
+ String usage,
+ String encodingStandard,
+ String dataType,
+ String defaultValue)
+ {
+ super(parentAsset,
+ type,
+ guid,
+ url,
+ classifications,
+ qualifiedName,
+ additionalProperties,
+ meanings,
+ versionNumber,
+ author,
+ usage,
+ encodingStandard);
+
+ this.dataType = dataType;
+ this.defaultValue = defaultValue;
+ }
+
+ /**
+ * Copy/clone Constructor - the parentAsset is passed separately to the template because it is also
+ * likely to be being cloned in the same operation and we want the definitions clone to point to the
+ * asset clone and not the original asset.
+ *
+ * @param parentAsset - description of the asset that this schema element is attached to.
+ * @param templateSchemaElement - template object to copy.
+ */
+ public PrimitiveSchemaElement(AssetDescriptor parentAsset, PrimitiveSchemaElement templateSchemaElement)
+ {
+ super(parentAsset, templateSchemaElement);
+
+ if (templateSchemaElement != null)
+ {
+ dataType = templateSchemaElement.getDataType();
+ defaultValue = templateSchemaElement.getDefaultValue();
+ }
+ }
+
+
+ /**
+ * Return the data type for this element. Null means unknown data type.
+ *
+ * @return String DataType
+ */
+ public String getDataType() { return dataType; }
+
+
+ /**
+ * Return the default value for the element. Null means no default value set up.
+ *
+ * @return String containing default value
+ */
+ public String getDefaultValue() { return defaultValue; }
+
+
+ /**
+ * Returns a clone of this object as the abstract SchemaElement class.
+ *
+ * @param parentAsset - description of the asset that this schema element is attached to.
+ * @return PrimitiveSchemaElement object
+ */
+ @Override
+ public SchemaElement cloneSchemaElement(AssetDescriptor parentAsset)
+ {
+ return new PrimitiveSchemaElement(parentAsset, this);
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return print out of variables in a JSON-style
+ */
+ @Override
+ public String toString()
+ {
+ return "PrimitiveSchemaElement{" +
+ "dataType='" + dataType + '\'' +
+ ", defaultValue='" + defaultValue + '\'' +
+ ", qualifiedName='" + qualifiedName + '\'' +
+ ", additionalProperties=" + additionalProperties +
+ ", meanings=" + meanings +
+ ", type=" + type +
+ ", guid='" + guid + '\'' +
+ ", url='" + url + '\'' +
+ '}';
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/PropertyBase.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/PropertyBase.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/PropertyBase.java
new file mode 100644
index 0000000..124ac59
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/PropertyBase.java
@@ -0,0 +1,113 @@
+/*
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.atlas.ocf.properties;
+
+import java.io.Serializable;
+import java.util.UUID;
+
+
+/**
+ * This property header implements any common mechanisms that all property objects need.
+ */
+public abstract class PropertyBase implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+ private int hashCode = UUID.randomUUID().hashCode();
+
+
+ /**
+ * Typical Constructor
+ */
+ public PropertyBase()
+ {
+ /*
+ * Nothing to do. This constructor is included so variables are added in this class at a later date
+ * without impacting the subclasses.
+ */
+ }
+
+
+ /**
+ * Copy/clone Constructor - the resulting object will return true if tested with this.equals(template) as
+ * long as the template object is not null;
+ *
+ * @param template - object being copied
+ */
+ public PropertyBase(PropertyBase template)
+ {
+ /*
+ * The hashCode value is replaced with the value from the template so the template object and this
+ * new object will return equals set to true.
+ */
+ if (template != null)
+ {
+ hashCode = template.hashCode();
+ }
+ }
+
+
+ /**
+ * Provide a common implementation of hashCode for all OCF properties objects. The UUID is unique and
+ * is randomly assigned and so its hashCode is as good as anything to describe the hash code of the properties
+ * object. This method may be overridden by subclasses.
+ */
+ public int hashCode()
+ {
+ return hashCode;
+ }
+
+
+ /**
+ * Provide a common implementation of equals for all OCF properties objects. The UUID is unique and
+ * is randomly assigned and so its hashCode is as good as anything to evaluate the equality of the properties
+ * object.
+ *
+ * @param object - object to test
+ * @return boolean flag
+ */
+ @Override
+ public boolean equals(Object object)
+ {
+ if (this == object)
+ {
+ return true;
+ }
+ if (object == null || getClass() != object.getClass())
+ {
+ return false;
+ }
+
+ PropertyBase that = (PropertyBase) object;
+
+ return hashCode == that.hashCode;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return print out of variables in a JSON-style
+ */
+ @Override
+ public String toString()
+ {
+ return "PropertyBase{" +
+ "hashCode=" + hashCode +
+ '}';
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Rating.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Rating.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Rating.java
new file mode 100644
index 0000000..4ad041d
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Rating.java
@@ -0,0 +1,142 @@
+/*
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.atlas.ocf.properties;
+
+
+/**
+ * Stores information about a rating connected to an asset. Ratings provide informal feedback on the quality of assets
+ * and can be added at any time.
+ *
+ * Ratings have the userId of the person who added it, a star rating and an optional review comment.
+ *
+ * The content of the rating is a personal judgement (which is why the user's id is in the object)
+ * and there is no formal review of the ratings. However, they can be used as a basis for crowd-sourcing
+ * feedback to asset owners.
+ */
+public class Rating extends ElementHeader
+{
+ /*
+ * Attributes of a Rating
+ */
+ private StarRating starRating = null;
+ private String review = null;
+ private String user = null;
+
+
+ /**
+ * Typical Constructor
+ *
+ * @param parentAsset - descriptor for parent asset
+ * @param type - details of the metadata type for this properties object
+ * @param guid - String - unique id
+ * @param url - String - URL
+ * @param classifications - enumeration of classifications
+ * @param starRating - StarRating enum - the star value for the rating.
+ * @param review - String - review comments
+ * @param user - String - user id of person providing the rating
+ */
+ public Rating(AssetDescriptor parentAsset,
+ ElementType type,
+ String guid,
+ String url,
+ Classifications classifications,
+ StarRating starRating,
+ String review,
+ String user)
+ {
+ super(parentAsset, type, guid, url, classifications);
+
+ this.starRating = starRating;
+ this.review = review;
+ this.user = user;
+ }
+
+ /**
+ * Copy/clone constructor.
+ *
+ * @param parentAsset - descriptor for parent asset
+ * @param templateRating - element to copy
+ */
+ public Rating(AssetDescriptor parentAsset, Rating templateRating)
+ {
+ /*
+ * Save the parent asset description.
+ */
+ super(parentAsset, templateRating);
+
+ if (templateRating != null)
+ {
+ /*
+ * Copy the values from the supplied tag.
+ */
+ user = templateRating.getUser();
+ starRating = templateRating.getStarRating();
+ review = templateRating.getReview();
+ }
+ }
+
+
+ /**
+ * Return the user id of the person who created the rating. Null means the user id is not known.
+ *
+ * @return String - user
+ */
+ public String getUser() {
+ return user;
+ }
+
+
+ /**
+ * Return the stars for the rating.
+ *
+ * @return StarRating - starRating
+ */
+ public StarRating getStarRating() {
+ return starRating;
+ }
+
+
+ /**
+ * Return the review comments - null means no review is available.
+ *
+ * @return String - review comments
+ */
+ public String getReview()
+ {
+ return review;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return print out of variables in a JSON-style
+ */
+ @Override
+ public String toString()
+ {
+ return "Rating{" +
+ "starRating=" + starRating +
+ ", review='" + review + '\'' +
+ ", user='" + user + '\'' +
+ ", type=" + type +
+ ", guid='" + guid + '\'' +
+ ", url='" + url + '\'' +
+ '}';
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Ratings.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Ratings.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Ratings.java
new file mode 100644
index 0000000..98e25ed
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Ratings.java
@@ -0,0 +1,128 @@
+/*
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.atlas.ocf.properties;
+
+import java.util.Iterator;
+
+/**
+ * Ratings supports an iterator over a list of ratings for an asset.
+ * Callers can use it to step through the list
+ * just once. If they want to parse the list again, they could use the copy/clone constructor to create
+ * a new iterator.
+ */
+public abstract class Ratings extends AssetPropertyIteratorBase implements Iterator<Rating>
+{
+ /**
+ * Typical Constructor creates an iterator with the supplied list of elements.
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @param totalElementCount - the total number of elements to process. A negative value is converted to 0.
+ * @param maxCacheSize - maximum number of elements that should be retrieved from the property server and
+ * cached in the element list at any one time. If a number less than one is supplied, 1 is used.
+ */
+ public Ratings(AssetDescriptor parentAsset,
+ int totalElementCount,
+ int maxCacheSize)
+ {
+ super(parentAsset, totalElementCount, maxCacheSize);
+ }
+
+
+ /**
+ * Copy/clone constructor. Used to reset iterator element pointer to 0;
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @param template - type-specific iterator to copy; null to create an empty iterator
+ */
+ public Ratings(AssetDescriptor parentAsset, Ratings template)
+ {
+ super(parentAsset, template);
+ }
+
+
+ /**
+ * Provides a concrete implementation of cloneElement for the specific iterator type.
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @param template - object to clone
+ * @return new cloned object.
+ */
+ protected AssetPropertyBase cloneElement(AssetDescriptor parentAsset, AssetPropertyBase template)
+ {
+ return new Rating(parentAsset, (Rating)template);
+ }
+
+
+ /**
+ * Clones this iterator.
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @return new cloned object.
+ */
+ protected abstract Ratings cloneIterator(AssetDescriptor parentAsset);
+
+
+ /**
+ * The iterator can only be used once to step through the elements. This method returns
+ * a boolean to indicate if it has got to the end of the list yet.
+ *
+ * @return boolean indicating whether there are more elements.
+ */
+ @Override
+ public boolean hasNext()
+ {
+ return super.pagingIterator.hasNext();
+ }
+
+
+ /**
+ * Return the next element in the iteration.
+ *
+ * @return Rating - next element object that has been cloned.
+ */
+ @Override
+ public Rating next()
+ {
+ return (Rating)super.pagingIterator.next();
+ }
+
+
+ /**
+ * Remove the current element in the iterator. (Null implementation since this iterator works off of cached
+ * elements from the property (metadata) server.)
+ */
+ @Override
+ public void remove()
+ {
+ super.pagingIterator.remove();
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return print out of variables in a JSON-style
+ */
+ @Override
+ public String toString()
+ {
+ return "Ratings{" +
+ "pagingIterator=" + pagingIterator +
+ '}';
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Referenceable.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Referenceable.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Referenceable.java
new file mode 100644
index 0000000..6d75aea
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Referenceable.java
@@ -0,0 +1,176 @@
+/*
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.atlas.ocf.properties;
+
+
+/**
+ * Many open metadata entities are referenceable. It means that they have a qualified name and additional
+ * properties. In addition the Referenceable class adds support for the parent asset, guid, url and type
+ * for the entity through extending ElementHeader.
+ */
+public class Referenceable extends ElementHeader
+{
+ /*
+ * Attributes of a Referenceable
+ */
+ protected String qualifiedName = null;
+ protected AdditionalProperties additionalProperties = null;
+
+ /*
+ * Attached glossary terms
+ */
+ protected Meanings meanings = null;
+
+
+ /**
+ * Typical Constructor
+ *
+ * @param parentAsset - descriptor for parent asset
+ * @param type - details of the metadata type for this properties object
+ * @param guid - String - unique id
+ * @param url - String - URL
+ * @param classifications - enumeration of classifications
+ * @param qualifiedName - unique name
+ * @param additionalProperties - additional properties for the referenceable object.
+ * @param meanings - list of glossary terms (summary)
+ */
+ public Referenceable(AssetDescriptor parentAsset,
+ ElementType type,
+ String guid,
+ String url,
+ Classifications classifications,
+ String qualifiedName,
+ AdditionalProperties additionalProperties,
+ Meanings meanings)
+ {
+ super(parentAsset, type, guid, url, classifications);
+
+ this.qualifiedName = qualifiedName;
+ this.additionalProperties = additionalProperties;
+ this.meanings = meanings;
+ }
+
+
+ /**
+ * Copy/clone constructor.
+ *
+ * @param parentAsset - descriptor for parent asset
+ * @param templateReferenceable - element to copy
+ */
+ public Referenceable(AssetDescriptor parentAsset, Referenceable templateReferenceable)
+ {
+ /*
+ * Save the parent asset description.
+ */
+ super(parentAsset, templateReferenceable);
+
+ if (templateReferenceable != null)
+ {
+ /*
+ * Copy the qualified name from the supplied template.
+ */
+ qualifiedName = templateReferenceable.getQualifiedName();
+
+ /*
+ * Create a copy of the additional properties since the parent asset may have changed.
+ */
+ AdditionalProperties templateAdditionalProperties = templateReferenceable.getAdditionalProperties();
+ if (templateAdditionalProperties != null)
+ {
+ additionalProperties = new AdditionalProperties(parentAsset, templateAdditionalProperties);
+ }
+
+ /*
+ * Create a copy of any glossary terms
+ */
+ Meanings templateMeanings = templateReferenceable.getMeanings();
+ if (templateMeanings != null)
+ {
+ meanings = templateMeanings.cloneIterator(parentAsset);
+ }
+ }
+ }
+
+
+ /**
+ * Returns the stored qualified name property for the metadata entity.
+ * If no qualified name is available then the empty string is returned.
+ *
+ * @return qualifiedName
+ */
+ public String getQualifiedName()
+ {
+ return qualifiedName;
+ }
+
+
+ /**
+ * Return a copy of the additional properties. Null means no additional properties are available.
+ *
+ * @return AdditionalProperties
+ */
+ public AdditionalProperties getAdditionalProperties()
+ {
+ if (additionalProperties == null)
+ {
+ return additionalProperties;
+ }
+ else
+ {
+ return new AdditionalProperties(super.getParentAsset(), additionalProperties);
+ }
+ }
+
+
+ /**
+ * Return a list of the glossary terms attached to this referenceable object. Null means no terms available.
+ *
+ * @return list of glossary terms (summary)
+ */
+ public Meanings getMeanings()
+ {
+ if (meanings == null)
+ {
+ return meanings;
+ }
+ else
+ {
+ return meanings.cloneIterator(super.getParentAsset());
+ }
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return print out of variables in a JSON-style
+ */
+ @Override
+ public String toString()
+ {
+ return "Referenceable{" +
+ "qualifiedName='" + qualifiedName + '\'' +
+ ", additionalProperties=" + additionalProperties +
+ ", meanings=" + meanings +
+ ", type=" + type +
+ ", guid='" + guid + '\'' +
+ ", url='" + url + '\'' +
+ '}';
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedAsset.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedAsset.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedAsset.java
new file mode 100644
index 0000000..877a60b
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedAsset.java
@@ -0,0 +1,167 @@
+/*
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.atlas.ocf.properties;
+
+import org.apache.atlas.ocf.ffdc.PropertyServerException;
+
+/**
+ * RelatedAsset describes assets that are related to this asset. For example, if the asset is a data store, the
+ * related assets could be its supported data sets.
+ */
+public class RelatedAsset extends Referenceable
+{
+ /*
+ * Properties that make up the summary properties of the related asset.
+ */
+ private String displayName = null;
+ private String description = null;
+ private String owner = null;
+
+ /*
+ * The detailed properties that are retrieved from the server
+ */
+ private RelatedAssetProperties relatedAssetProperties = null;
+
+
+ /**
+ * Typical constructor
+ *
+ * @param parentAsset - descriptor for parent asset
+ * @param type - details of the metadata type for this properties object
+ * @param guid - String - unique id
+ * @param url - String - URL
+ * @param classifications - enumeration of classifications
+ * @param qualifiedName - unique name
+ * @param additionalProperties - additional properties for the referenceable object.
+ * @param meanings - list of glossary terms (summary)
+ * @param displayName - consumable name
+ * @param description - description property stored for the related asset.
+ * @param owner - the owner details for this related asset.
+ * @param relatedAssetProperties - detailed properties of the asset.
+ */
+ public RelatedAsset(AssetDescriptor parentAsset,
+ ElementType type,
+ String guid,
+ String url,
+ Classifications classifications,
+ String qualifiedName,
+ AdditionalProperties additionalProperties,
+ Meanings meanings,
+ String displayName,
+ String description,
+ String owner,
+ RelatedAssetProperties relatedAssetProperties)
+ {
+ super(parentAsset, type, guid, url, classifications, qualifiedName, additionalProperties, meanings);
+
+ this.displayName = displayName;
+ this.description = description;
+ this.owner = owner;
+ this.relatedAssetProperties = relatedAssetProperties;
+ }
+
+
+ /**
+ * Copy/clone constructor
+ *
+ * @param parentAsset - description of the asset that this related asset is attached to.
+ * @param templateRelatedAsset - template object to copy.
+ */
+ public RelatedAsset(AssetDescriptor parentAsset, RelatedAsset templateRelatedAsset)
+ {
+ super(parentAsset, templateRelatedAsset);
+ if (templateRelatedAsset != null)
+ {
+ displayName = templateRelatedAsset.getDisplayName();
+ description = templateRelatedAsset.getDescription();
+ owner = templateRelatedAsset.getOwner();
+ }
+ }
+
+
+ /**
+ * Returns the stored display name property for the related asset.
+ * If no display name is available then null is returned.
+ *
+ * @return displayName
+ */
+ public String getDisplayName()
+ {
+ return displayName;
+ }
+
+
+ /**
+ * Returns the stored description property for the related asset.
+ * If no description is provided then null is returned.
+ *
+ * @return description
+ */
+ public String getDescription()
+ {
+ return description;
+ }
+
+
+ /**
+ * Returns the details of the owner for this related asset.
+ *
+ * @return String owner
+ */
+ public String getOwner() { return owner; }
+
+
+ /**
+ * Return the detailed properties for a related asset.
+ *
+ * @return a refreshed version of the RelatedAssetProperties
+ * @throws PropertyServerException - problems communicating with the property (metadata) server
+ */
+ public RelatedAssetProperties getRelatedAssetProperties() throws PropertyServerException
+ {
+ if (relatedAssetProperties != null)
+ {
+ relatedAssetProperties.refresh();
+ }
+
+ return relatedAssetProperties;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return print out of variables in a JSON-style
+ */
+ @Override
+ public String toString()
+ {
+ return "RelatedAsset{" +
+ "displayName='" + displayName + '\'' +
+ ", description='" + description + '\'' +
+ ", owner='" + owner + '\'' +
+ ", relatedAssetProperties=" + relatedAssetProperties +
+ ", qualifiedName='" + qualifiedName + '\'' +
+ ", additionalProperties=" + additionalProperties +
+ ", meanings=" + meanings +
+ ", type=" + type +
+ ", guid='" + guid + '\'' +
+ ", url='" + url + '\'' +
+ '}';
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedAssetProperties.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedAssetProperties.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedAssetProperties.java
new file mode 100644
index 0000000..2ed017e
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedAssetProperties.java
@@ -0,0 +1,143 @@
+/*
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.atlas.ocf.properties;
+
+
+import org.apache.atlas.ocf.ffdc.PropertyServerException;
+
+
+/**
+ * RelatedAssetProperties returns detailed information about an asset that is related to a connected asset.
+ *
+ * It is a generic interface for all types of open metadata assets. However, it assumes the asset's metadata model
+ * inherits from <b>Asset</b> (see model 0010 in Area 0).
+ *
+ * The RelatedAssetProperties returns metadata about the asset at three levels of detail:
+ * <ul>
+ * <li><b>assetSummary</b> - used for displaying details of the asset in summary lists or hover text</li>
+ * <li><b>assetDetail</b> - used to display all of the information known about the asset with summaries
+ * of the relationships to other metadata entities</li>
+ * <li><b>assetUniverse</b> - used to define the broader context for the asset</li>
+ * </ul>
+ *
+ * RelatedAssetProperties is a base class for the asset information that returns null,
+ * for the asset's properties. Metadata repository implementations extend this class to add their
+ * implementation of the refresh() method that calls to the metadata repository to populate the metadata properties.
+ */
+public abstract class RelatedAssetProperties extends PropertyBase
+{
+ /*
+ * AssetUniverse extends AssetDetails which extends AssetSummary. The interaction with the metadata repository
+ * pulls the asset universe in one single network interaction and the caller can then explore the metadata
+ * property by property without incurring many network interactions (unless there are too many instances
+ * of a particular type of property and one of the iterators is forced to use paging).
+ *
+ * If null is returned, the caller is not linked to a metadata repository.
+ */
+ protected AssetUniverse assetProperties = null;
+ protected AssetDescriptor connectedAsset = null;
+ protected RelatedAsset relatedAsset = null;
+
+
+ /**
+ * Typical constructor.
+ *
+ * @param connectedAsset - original top-level asset
+ * @param relatedAsset - asset to extract the full set of properties.
+ */
+ public RelatedAssetProperties(AssetDescriptor connectedAsset, RelatedAsset relatedAsset)
+ {
+ /*
+ * Remember the parent asset and details of the related asset to be retrieved.
+ */
+ this.connectedAsset = connectedAsset;
+ this.relatedAsset = relatedAsset;
+ }
+
+
+ /**
+ * Copy/clone constructor*
+ *
+ * @param templateProperties - template to copy
+ */
+ public RelatedAssetProperties(RelatedAssetProperties templateProperties)
+ {
+ if (templateProperties != null)
+ {
+ AssetUniverse templateAssetUniverse = templateProperties.getAssetUniverse();
+ if (templateAssetUniverse != null)
+ {
+ assetProperties = new AssetUniverse(templateAssetUniverse);
+ connectedAsset = templateProperties.connectedAsset;
+ relatedAsset = templateProperties.relatedAsset;
+ }
+ }
+ }
+
+
+ /**
+ * Returns the summary information organized in the assetSummary structure.
+ *
+ * @return AssetSummary - summary object
+ */
+ public AssetSummary getAssetSummary() { return assetProperties; }
+
+
+
+ /**
+ * Returns detailed information about the asset organized in the assetDetail structure.
+ *
+ * @return AssetDetail - detail object
+ */
+ public AssetDetail getAssetDetail() { return assetProperties; }
+
+
+ /**
+ * Returns all of the detail of the asset and information connected to it in organized in the assetUniverse
+ * structure.
+ *
+ * @return AssetUniverse - universe object
+ */
+ public AssetUniverse getAssetUniverse() { return assetProperties; }
+
+
+ /**
+ * Request the values in the RelatedAssetProperties are refreshed with the current values from the
+ * metadata repository.
+ *
+ * @throws PropertyServerException - there is a problem connecting to the server to retrieve metadata.
+ */
+ public abstract void refresh() throws PropertyServerException;
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return print out of variables in a JSON-style
+ */
+ @Override
+ public String toString()
+ {
+ return "RelatedAssetProperties{" +
+ "assetProperties=" + assetProperties +
+ ", connectedAsset=" + connectedAsset +
+ ", relatedAsset=" + relatedAsset +
+ '}';
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedAssets.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedAssets.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedAssets.java
new file mode 100644
index 0000000..82634bc
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedAssets.java
@@ -0,0 +1,127 @@
+/*
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.atlas.ocf.properties;
+
+import java.util.Iterator;
+
+/**
+ * RelatedAssets supports an iterator over a list of related assets. Callers can use it to step through the list
+ * just once. If they want to parse the list again, they could use the copy/clone constructor to create
+ * a new iterator.
+ */
+public abstract class RelatedAssets extends AssetPropertyIteratorBase implements Iterator<RelatedAsset>
+{
+ /**
+ * Typical Constructor creates an iterator with the supplied list of elements.
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @param totalElementCount - the total number of elements to process. A negative value is converted to 0.
+ * @param maxCacheSize - maximum number of elements that should be retrieved from the property server and
+ * cached in the element list at any one time. If a number less than one is supplied, 1 is used.
+ */
+ public RelatedAssets(AssetDescriptor parentAsset,
+ int totalElementCount,
+ int maxCacheSize)
+ {
+ super(parentAsset, totalElementCount, maxCacheSize);
+ }
+
+
+ /**
+ * Copy/clone constructor. Used to reset iterator element pointer to 0;
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @param template - type-specific iterator to copy; null to create an empty iterator
+ */
+ public RelatedAssets(AssetDescriptor parentAsset, RelatedAssets template)
+ {
+ super(parentAsset, template);
+ }
+
+
+ /**
+ * Provides a concrete implementation of cloneElement for the specific iterator type.
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @param template - object to clone
+ * @return new cloned object.
+ */
+ protected AssetPropertyBase cloneElement(AssetDescriptor parentAsset, AssetPropertyBase template)
+ {
+ return new RelatedAsset(parentAsset, (RelatedAsset)template);
+ }
+
+
+ /**
+ * Clones this iterator.
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @return new cloned object.
+ */
+ protected abstract RelatedAssets cloneIterator(AssetDescriptor parentAsset);
+
+
+ /**
+ * The iterator can only be used once to step through the elements. This method returns
+ * a boolean to indicate if it has got to the end of the list yet.
+ *
+ * @return boolean indicating whether there are more elements.
+ */
+ @Override
+ public boolean hasNext()
+ {
+ return super.pagingIterator.hasNext();
+ }
+
+
+ /**
+ * Return the next element in the iteration.
+ *
+ * @return RelatedAsset - next element object that has been cloned.
+ */
+ @Override
+ public RelatedAsset next()
+ {
+ return (RelatedAsset)super.pagingIterator.next();
+ }
+
+
+ /**
+ * Remove the current element in the iterator. (Null implementation since this iterator works off of cached
+ * elements from the property (metadata) server.)
+ */
+ @Override
+ public void remove()
+ {
+ super.pagingIterator.remove();
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return print out of variables in a JSON-style
+ */
+ @Override
+ public String toString()
+ {
+ return "RelatedAssets{" +
+ "pagingIterator=" + pagingIterator +
+ '}';
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedMediaReference.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedMediaReference.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedMediaReference.java
new file mode 100644
index 0000000..8209ee0
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedMediaReference.java
@@ -0,0 +1,240 @@
+/*
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.atlas.ocf.properties;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * RelatedMediaReference stores information about an link to an external media file that
+ * is relevant to this asset.
+ */
+public class RelatedMediaReference extends Referenceable
+{
+ /*
+ * Attributes of a related media reference
+ */
+ private String mediaId = null;
+ private String linkDescription = null;
+ private String displayName = null;
+ private String uri = null;
+ private String resourceDescription = null;
+ private String version = null;
+ private String organization = null;
+ private RelatedMediaType mediaType = null;
+ private ArrayList<RelatedMediaUsage> mediaUsageList = null;
+
+
+ /**
+ * Typical Constructor
+ *
+ * @param parentAsset - descriptor for parent asset
+ * @param type - details of the metadata type for this properties object
+ * @param guid - String - unique id
+ * @param url - String - URL
+ * @param classifications - enumeration of classifications
+ * @param qualifiedName - unique name
+ * @param additionalProperties - additional properties for the referenceable object.
+ * @param meanings - list of glossary terms (summary)
+ * @param mediaId the reference identifier for this asset's related media.
+ * @param linkDescription - description of the reference (with respect to this asset).
+ * @param displayName - consumable name
+ * @param uri - the URI used to retrieve the resource for this media reference.
+ * @param resourceDescription - the description of this external media.
+ * @param version - the version of the resource that this external reference represents.
+ * @param organization - the name of the organization that owns the resource that this external reference represents.
+ * @param mediaType - the type of media referenced
+ * @param mediaUsageList - List of ways the media may be used
+ */
+ public RelatedMediaReference(AssetDescriptor parentAsset,
+ ElementType type,
+ String guid,
+ String url,
+ Classifications classifications,
+ String qualifiedName,
+ AdditionalProperties additionalProperties,
+ Meanings meanings,
+ String mediaId,
+ String linkDescription,
+ String displayName,
+ String uri,
+ String resourceDescription,
+ String version,
+ String organization,
+ RelatedMediaType mediaType,
+ ArrayList<RelatedMediaUsage> mediaUsageList)
+ {
+ super(parentAsset, type, guid, url, classifications, qualifiedName, additionalProperties, meanings);
+ this.mediaId = mediaId;
+ this.linkDescription = linkDescription;
+ this.displayName = displayName;
+ this.uri = uri;
+ this.resourceDescription = resourceDescription;
+ this.version = version;
+ this.organization = organization;
+ this.mediaType = mediaType;
+ this.mediaUsageList = mediaUsageList;
+ }
+
+ /**
+ * Copy/clone constructor.
+ *
+ * @param parentAsset - descriptor for parent asset
+ * @param templateRelatedMediaReference - element to copy
+ */
+ public RelatedMediaReference(AssetDescriptor parentAsset,
+ RelatedMediaReference templateRelatedMediaReference)
+ {
+ /*
+ * Initialize the super class.
+ */
+ super(parentAsset, templateRelatedMediaReference);
+
+ if (templateRelatedMediaReference != null)
+ {
+ /*
+ * Copy the values from the supplied template.
+ */
+ mediaId = templateRelatedMediaReference.getMediaId();
+ linkDescription = templateRelatedMediaReference.getLinkDescription();
+ displayName = templateRelatedMediaReference.getDisplayName();
+ uri = templateRelatedMediaReference.getURI();
+ resourceDescription = templateRelatedMediaReference.getResourceDescription();
+ version = templateRelatedMediaReference.getVersion();
+ organization = templateRelatedMediaReference.getOrganization();
+ mediaType = templateRelatedMediaReference.getMediaType();
+
+ List<RelatedMediaUsage> templateMediaUsageList = templateRelatedMediaReference.getMediaUsageList();
+ if (templateMediaUsageList != null)
+ {
+ mediaUsageList = new ArrayList<RelatedMediaUsage>(templateMediaUsageList);
+ }
+ }
+ }
+
+
+ /**
+ * Return the identifier given to this reference (with respect to this asset).
+ *
+ * @return String mediaId
+ */
+ public String getMediaId() { return mediaId; }
+
+
+ /**
+ * Return the description of the reference (with respect to this asset).
+ *
+ * @return String link description.
+ */
+ public String getLinkDescription() { return linkDescription; }
+
+
+ /**
+ * Return the display name of this media reference.
+ *
+ * @return String display name.
+ */
+ public String getDisplayName() { return displayName; }
+
+
+ /**
+ * Return the URI used to retrieve the resource for this media reference.
+ *
+ * @return String URI
+ */
+ public String getURI() { return uri; }
+
+
+ /**
+ * Return the description of this external media.
+ *
+ * @return String resource description
+ */
+ public String getResourceDescription() { return resourceDescription; }
+
+
+ /**
+ * Return the version of the resource that this media reference represents.
+ *
+ * @return String version
+ */
+ public String getVersion() { return version; }
+
+
+ /**
+ * Return the name of the organization that owns the resource that this external reference represents.
+ *
+ * @return String organization name
+ */
+ public String getOrganization() { return organization; }
+
+
+ /**
+ * Return the type of media referenced.
+ *
+ * @return RelatedMediaType
+ */
+ public RelatedMediaType getMediaType() { return mediaType; }
+
+
+ /**
+ * Return the list of recommended usage for the related media. Null means no usage guidance is available.
+ *
+ * @return List of RelatedMediaUsage
+ */
+ public ArrayList<RelatedMediaUsage> getMediaUsageList()
+ {
+ if (mediaUsageList != null)
+ {
+ return mediaUsageList;
+ }
+ else
+ {
+ return new ArrayList<RelatedMediaUsage>(mediaUsageList);
+ }
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return print out of variables in a JSON-style
+ */
+ @Override
+ public String toString()
+ {
+ return "RelatedMediaReference{" +
+ "mediaId='" + mediaId + '\'' +
+ ", linkDescription='" + linkDescription + '\'' +
+ ", displayName='" + displayName + '\'' +
+ ", uri='" + uri + '\'' +
+ ", resourceDescription='" + resourceDescription + '\'' +
+ ", version='" + version + '\'' +
+ ", organization='" + organization + '\'' +
+ ", mediaType=" + mediaType +
+ ", mediaUsageList=" + mediaUsageList +
+ ", qualifiedName='" + qualifiedName + '\'' +
+ ", additionalProperties=" + additionalProperties +
+ ", meanings=" + meanings +
+ ", type=" + type +
+ ", guid='" + guid + '\'' +
+ ", url='" + url + '\'' +
+ '}';
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedMediaReferences.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedMediaReferences.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedMediaReferences.java
new file mode 100644
index 0000000..b4e0d5a
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedMediaReferences.java
@@ -0,0 +1,127 @@
+/*
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.atlas.ocf.properties;
+
+import java.util.Iterator;
+
+/**
+ * RelatedMediaReferences supports an iterator over a list of related media references. Callers can use it to step
+ * through the list just once. If they want to parse the list again, they could use the copy/clone constructor to
+ * create a new iterator.
+ */
+public abstract class RelatedMediaReferences extends AssetPropertyIteratorBase implements Iterator<RelatedMediaReference>
+{
+ /**
+ * Typical Constructor creates an iterator with the supplied list of elements.
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @param totalElementCount - the total number of elements to process. A negative value is converted to 0.
+ * @param maxCacheSize - maximum number of elements that should be retrieved from the property server and
+ * cached in the element list at any one time. If a number less than one is supplied, 1 is used.
+ */
+ public RelatedMediaReferences(AssetDescriptor parentAsset,
+ int totalElementCount,
+ int maxCacheSize)
+ {
+ super(parentAsset, totalElementCount, maxCacheSize);
+ }
+
+
+ /**
+ * Copy/clone constructor. Used to reset iterator element pointer to 0;
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @param template - type-specific iterator to copy; null to create an empty iterator
+ */
+ public RelatedMediaReferences(AssetDescriptor parentAsset, RelatedMediaReferences template)
+ {
+ super(parentAsset, template);
+ }
+
+
+ /**
+ * Provides a concrete implementation of cloneElement for the specific iterator type.
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @param template - object to clone
+ * @return new cloned object.
+ */
+ protected AssetPropertyBase cloneElement(AssetDescriptor parentAsset, AssetPropertyBase template)
+ {
+ return new RelatedMediaReference(parentAsset, (RelatedMediaReference)template);
+ }
+
+
+ /**
+ * Clones this iterator.
+ *
+ * @param parentAsset - descriptor of parent asset
+ * @return new cloned object.
+ */
+ protected abstract RelatedMediaReferences cloneIterator(AssetDescriptor parentAsset);
+
+
+ /**
+ * The iterator can only be used once to step through the elements. This method returns
+ * a boolean to indicate if it has got to the end of the list yet.
+ *
+ * @return boolean indicating whether there are more elements.
+ */
+ @Override
+ public boolean hasNext()
+ {
+ return super.pagingIterator.hasNext();
+ }
+
+
+ /**
+ * Return the next element in the iteration.
+ *
+ * @return RelatedMediaReference - next element object that has been cloned.
+ */
+ @Override
+ public RelatedMediaReference next()
+ {
+ return (RelatedMediaReference)super.pagingIterator.next();
+ }
+
+
+ /**
+ * Remove the current element in the iterator. (Null implementation since this iterator works off of cached
+ * elements from the property (metadata) server.)
+ */
+ @Override
+ public void remove()
+ {
+ super.pagingIterator.remove();
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return print out of variables in a JSON-style
+ */
+ @Override
+ public String toString()
+ {
+ return "RelatedMediaReferences{" +
+ "pagingIterator=" + pagingIterator +
+ '}';
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedMediaType.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedMediaType.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedMediaType.java
new file mode 100644
index 0000000..0b71d46
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/RelatedMediaType.java
@@ -0,0 +1,92 @@
+/*
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.atlas.ocf.properties;
+
+import java.io.Serializable;
+
+/**
+ * The RelatedMediaType defines the type of resource referenced in a related media reference.
+ * <ul>
+ * <li>Image - The media is an image.</li>
+ * <li>Audio - The media is an audio recording.</li>
+ * <li>Document - The media is a text document - probably rich text.</li>
+ * <li>Video - The media is a video recording.</li>
+ * <li>Other - The media type is not supported.</li>
+ * </ul>
+ */
+public enum RelatedMediaType implements Serializable
+{
+ IMAGE(0, "Image", "The media is an image."),
+ AUDIO(1, "Audio", "The media is an audio recording."),
+ DOCUMENT(2, "Document", "The media is a text document - probably rich text."),
+ VIDEO(3, "Video", "The media is a video recording."),
+ OTHER(99, "Other", "The media type is not supported.");
+
+ private static final long serialVersionUID = 1L;
+
+ private int mediaTypeCode;
+ private String mediaTypeName;
+ private String mediaTypeDescription;
+
+
+ /**
+ * Typical Constructor
+ */
+ RelatedMediaType(int mediaTypeCode, String mediaTypeName, String mediaTypeDescription)
+ {
+ /*
+ * Save the values supplied
+ */
+ this.mediaTypeCode = mediaTypeCode;
+ this.mediaTypeName = mediaTypeName;
+ this.mediaTypeDescription = mediaTypeDescription;
+ }
+
+
+ /**
+ * Return the code for this enum instance
+ *
+ * @return int - media type code
+ */
+ public int getMediaUsageCode()
+ {
+ return mediaTypeCode;
+ }
+
+
+ /**
+ * Return the default name for this enum instance.
+ *
+ * @return String - default name
+ */
+ public String getMediaUsageName()
+ {
+ return mediaTypeName;
+ }
+
+
+ /**
+ * Return the default description for this enum instance.
+ *
+ * @return String - default description
+ */
+ public String getMediaTypeDescription()
+ {
+ return mediaTypeDescription;
+ }
+}
\ No newline at end of file