http://git-wip-us.apache.org/repos/asf/atlas/blob/f57fd7f0/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/AnnotationStatus.java ---------------------------------------------------------------------- diff --git a/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/AnnotationStatus.java b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/AnnotationStatus.java new file mode 100644 index 0000000..61b49b0 --- /dev/null +++ b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/AnnotationStatus.java @@ -0,0 +1,98 @@ +/* + * 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.omas.connectedasset.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serializable; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * An AnnotationStatus defines the current status for an annotation plus some default descriptive text. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum AnnotationStatus implements Serializable +{ + NEW_ANNOTATION(0, "New", "Annotation has been created but not reviewed"), + REVIEWED_ANNOTATION(1, "Reviewed", "Annotation has been reviewed by no decision has been made"), + APPROVED_ANNOTATION(2, "Approved", "Annotation has been approved"), + ACTIONED_ANNOTATION(3, "Actioned", "Annotation has been approved and insight has been added to Asset's metadata"), + INVALID_ANNOTATION(4, "Invalid", "Annotation has been reviewed and declared invalid"), + IGNORE_ANNOTATION(5, "Ignore", "Annotation is invalid and should be ignored"), + OTHER_STATUS(98, "Other", "Annotation's status stored in additional properties"), + UNKNOWN_STATUS(99, "Unknown", "Annotation has not had a status assigned"); + + private static final long serialVersionUID = 1L; + + private int statusCode = 99; + private String statusName = ""; + private String statusDescription = ""; + + + /** + * Typical Constructor + */ + AnnotationStatus(int statusCode, String statusName, String statusDescription) + { + /* + * Save the values supplied + */ + this.statusCode = statusCode; + this.statusName = statusName; + this.statusDescription = statusDescription; + } + + + /** + * Return the status code for this enum instance + * + * @return int - status code + */ + public int getStatusCode() + { + return statusCode; + } + + + /** + * Return the default name for the status for this enum instance. + * + * @return String - default status name + */ + public String getStatusName() + { + return statusName; + } + + + /** + * REturn the default description for the status for this enum instance. + * + * @return String - default status description + */ + public String getStatusDescription() + { + return statusDescription; + } +} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/f57fd7f0/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/AssetDescriptor.java ---------------------------------------------------------------------- diff --git a/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/AssetDescriptor.java b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/AssetDescriptor.java new file mode 100644 index 0000000..0927e3b --- /dev/null +++ b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/AssetDescriptor.java @@ -0,0 +1,154 @@ +/* + * 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.omas.connectedasset.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * This is the base class for a connected asset. It is passed to all of the embedded property objects so the name + * and type can be used for error messages and other diagnostics. It also carries the URL of the + * metadata repository where this is known to enable properties to be retrieved on request. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AssetDescriptor extends PropertyBase +{ + /* + * Derived name and type for use by nested property object for messages/debug. If these default values + * are seen it is a sign that the asset properties are not being populated from the metadata repository. + */ + private String assetName = "<Unknown>"; + private String assetTypeName = "<Unknown>"; + + /* + * URL where the metadata about the asset is located. It remains null if no repository is known. + */ + private String assetRepositoryURL = null; + + + /** + * Typical constructor - the asset descriptor is effectively empty - and the set methods need to be called to + * add useful content to it. + */ + public AssetDescriptor() + { + /* + * Nothing to do except call superclass + */ + super(); + } + + + /** + * Explicit constructor - the asset descriptor is explicitly given the name and type for the asset. This + * constructor is used to override the hard coded defaults. + * + * @param assetName - name of asset + * @param assetTypeName - name of asset type + * @param assetRepositoryURL - URL for the metadata repository + */ + public AssetDescriptor(String assetName, String assetTypeName, String assetRepositoryURL) + { + super(); + + this.assetName = assetName; + this.assetTypeName = assetTypeName; + this.assetRepositoryURL = assetRepositoryURL; + } + + + /** + * Copy/clone Constructor - used to copy the asset descriptor for a new consumer. + * + * @param templateAssetDescriptor - template asset descriptor to copy. + */ + public AssetDescriptor(AssetDescriptor templateAssetDescriptor) + { + super(); + + this.assetName = templateAssetDescriptor.getAssetName(); + this.assetTypeName = templateAssetDescriptor.getAssetTypeName(); + this.assetRepositoryURL = templateAssetDescriptor.getAssetRepositoryURL(); + } + + + /** + * Method to enable a subclass to set up the asset name. + * + * @param assetName - String - name of asset for messages etc + */ + protected void setAssetName(String assetName) + { + this.assetName = assetName; + } + + + /** + * Method to enable a subclass to set up the asset type name. + * + * @param assetTypeName - String - new type name + */ + protected void setAssetTypeName(String assetTypeName) + { + this.assetTypeName = assetTypeName; + } + + + /** + * Set up the URL of the metadata repository where the asset properties are held. + * + * @param assetRepositoryURL - String - URL + */ + protected void setAssetRepositoryURL(String assetRepositoryURL) { this.assetRepositoryURL = assetRepositoryURL; } + + + /** + * Return the name of the asset - for use in messages and other diagnostics. + * + * @return String - asset name + */ + public String getAssetName() + { + return assetName; + } + + + /** + * Return the name of the asset's type - for use in messages and other diagnostics. + * + * @return String - asset type name + */ + public String getAssetTypeName() + { + return assetTypeName; + } + + + /** + * Return the URL of the metadata repository where the asset properties are held. + * + * @return String - URL + */ + public String getAssetRepositoryURL() { return assetRepositoryURL; } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/atlas/blob/f57fd7f0/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/AssetDetail.java ---------------------------------------------------------------------- diff --git a/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/AssetDetail.java b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/AssetDetail.java new file mode 100644 index 0000000..be0dacc --- /dev/null +++ b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/AssetDetail.java @@ -0,0 +1,356 @@ +/** + * 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.atlas.omas.connectedasset.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.ArrayList; +import java.util.List; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AssetDetail extends AssetSummary to provide all of the properties related to this asset. It includes: + * <ul> + * <li>AssetProperties - properties unique to the particular type of asset including any vendor-specific facets.</li> + * <li>ExternalIdentifiers - list of identifiers for this asset that are used in other systems.</li> + * <li>RelatedMediaReferences - list of links to external media (images, audio, video) about this asset.</li> + * <li>NoteLogs - list of NoteLogs for this asset, often providing more detail on how to use the asset and + * its current status.</li> + * <li>ExternalReferences - list of links to additional information about this asset.</li> + * <li>Connections - list of connections defined to access this asset.</li> + * <li>Licenses - list of licenses associated with the asset.</li> + * <li>Certifications - list of certifications that have been awarded to this asset.</li> + * </ul> + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AssetDetail extends AssetSummary +{ + private AdditionalProperties assetProperties = null; + private List<ExternalIdentifier> externalIdentifiers = null; + private List<RelatedMediaReference> relatedMediaReferences = null; + private List<NoteLog> noteLogs = null; + private List<ExternalReference> externalReferences = null; + private List<Connection> connections = null; + private List<License> licenses = null; + private List<Certification> certifications = null; + + + /** + * Typical constructor - initialize superclasses + */ + public AssetDetail() + { + super(); + } + + + /** + * Copy/clone constructor. Note, this is a deep copy + * + * @param templateAssetDetail - template to copy + */ + public AssetDetail(AssetDetail templateAssetDetail) + { + /* + * Initialize superclass + */ + super(templateAssetDetail); + + /* + * Copy details from template, ensuring the parentAsset is this object, not the template's. + */ + if (templateAssetDetail != null) + { + AdditionalProperties templateAssetProperties = templateAssetDetail.getAssetProperties(); + List<ExternalIdentifier> templateExternalIdentifiers = templateAssetDetail.getExternalIdentifiers(); + List<RelatedMediaReference> templateRelatedMediaReferences = templateAssetDetail.getRelatedMediaReferences(); + List<NoteLog> templateNoteLogs = templateAssetDetail.getNoteLogs(); + List<ExternalReference> templateExternalReferences = templateAssetDetail.getExternalReferences(); + List<Connection> templateConnections = templateAssetDetail.getConnections(); + List<License> templateLicenses = templateAssetDetail.getLicenses(); + List<Certification> templateCertifications = templateAssetDetail.getCertifications(); + + if (templateAssetProperties != null) + { + assetProperties = new AdditionalProperties(templateAssetProperties); + } + if (templateExternalIdentifiers != null) + { + externalIdentifiers = new ArrayList<>(templateExternalIdentifiers); + } + if (templateRelatedMediaReferences != null) + { + relatedMediaReferences = new ArrayList<>(templateRelatedMediaReferences); + } + if (templateNoteLogs != null) + { + noteLogs = new ArrayList<>(templateNoteLogs); + } + if (templateExternalReferences != null) + { + externalReferences = new ArrayList<>(templateExternalReferences); + } + if (templateConnections != null) + { + connections = new ArrayList<>(templateConnections); + } + if (templateLicenses != null) + { + licenses = new ArrayList<>(templateLicenses); + } + if (templateCertifications != null) + { + certifications = new ArrayList<>(templateCertifications); + } + } + } + + + /** + * Return the set of properties that are specific to the particular type of asset. The caller is given their + * own copy of the property object. The properties are named entityName.attributeName. The values are all strings. + * + * @return AdditionalProperties - asset properties using the name of attributes from the model. + */ + public AdditionalProperties getAssetProperties() + { + if (assetProperties == null) + { + return assetProperties; + } + else + { + return new AdditionalProperties(assetProperties); + } + } + + + /** + * Set up the asset properties for this asset. + * + * @param assetProperties - AdditionalProperties object + */ + public void setAssetProperties(AdditionalProperties assetProperties) + { + this.assetProperties = assetProperties; + } + + + /** + * Return an enumeration of the external identifiers for this asset (or null if none). + * + * @return ExternalIdentifiers list + */ + public List<ExternalIdentifier> getExternalIdentifiers() + { + if (externalIdentifiers == null) + { + return externalIdentifiers; + } + else + { + return new ArrayList<>(externalIdentifiers); + } + } + + + /** + * Set up the external identifiers for this asset. + * + * @param externalIdentifiers - ExternalIdentifiers list + */ + public void setExternalIdentifiers(List<ExternalIdentifier> externalIdentifiers) + { + this.externalIdentifiers = externalIdentifiers; + } + + + /** + * Return an enumeration of references to the related media associated with this asset. + * + * @return RelatedMediaReferences List + */ + public List<RelatedMediaReference> getRelatedMediaReferences() + { + if (relatedMediaReferences == null) + { + return relatedMediaReferences; + } + else + { + return new ArrayList<>(relatedMediaReferences); + } + } + + + /** + * Set up the enumeration of references to the related media associated with this asset. + * + * @param relatedMediaReferences - RelatedMediaReferences list + */ + public void setRelatedMediaReferences(List<RelatedMediaReference> relatedMediaReferences) + { + this.relatedMediaReferences = relatedMediaReferences; + } + + + /** + * Return an enumeration of NoteLogs linked to this asset. + * + * @return Notelogs list + */ + public List<NoteLog> getNoteLogs() + { + if (noteLogs == null) + { + return noteLogs; + } + else + { + return new ArrayList<>(noteLogs); + } + } + + + /** + * Set up the list of note logs for this asset. + * + * @param noteLogs - NoteLogs list + */ + public void setNoteLogs(List<NoteLog> noteLogs) + { + this.noteLogs = noteLogs; + } + + + /** + * Return the list of external references associated with this asset. + * + * @return ExternalReferences list + */ + public List<ExternalReference> getExternalReferences() + { + if (externalReferences == null) + { + return externalReferences; + } + else + { + return new ArrayList<>(externalReferences); + } + } + + + /** + * Set up the external references for this asset. + * + * @param externalReferences - ExternalReferences list + */ + public void setExternalReferences(List<ExternalReference> externalReferences) + { + this.externalReferences = externalReferences; + } + + + /** + * Return an enumeration of the connections defined for this asset. + * + * @return Connections enumeration + */ + public List<Connection> getConnections() + { + if (connections == null) + { + return connections; + } + else + { + return new ArrayList<>(connections); + } + } + + + /** + * Set up the list of connections defined for accessing this asset. + * + * @param connections - Connections list + */ + public void setConnections(ArrayList<Connection> connections) + { + this.connections = connections; + } + + + /** + * Return the list of licenses associated with the asset. + * + * @return Licenses + */ + public List<License> getLicenses() + { + if (licenses == null) + { + return licenses; + } + else + { + return new ArrayList<>(licenses); + } + } + + + /** + * Set up the licenses associated with this asset. + * + * @param licenses - List of licenses + */ + public void setLicenses(List<License> licenses) { this.licenses = licenses; } + + + /** + * Return the list of certifications awarded to the asset. + * + * @return Certifications - list of certifications + */ + public List<Certification> getCertifications() + { + if (certifications == null) + { + return certifications; + } + else + { + return new ArrayList<>(certifications); + } + } + + + /** + * Set up the list of certifications awarded to the asset. + * + * @param certifications - Certifications - list of certifications + */ + public void setCertifications(List<Certification> certifications) { this.certifications = certifications; } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/f57fd7f0/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/AssetSummary.java ---------------------------------------------------------------------- diff --git a/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/AssetSummary.java b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/AssetSummary.java new file mode 100644 index 0000000..4a69c02 --- /dev/null +++ b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/AssetSummary.java @@ -0,0 +1,384 @@ +/** + * 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.atlas.omas.connectedasset.properties; + + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.ArrayList; +import java.util.List; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AssetSummary is a POJO that holds asset properties that are used for displaying details of + * an asset in summary lists or hover text. It includes the following properties: + * <ul> + * <li>type - metadata type information for the asset properties</li> + * <li>guid - globally unique identifier for the asset</li> + * <li>url - external link for the asset</li> + * <li>qualifiedName - The official (unique) name for the asset. This is often defined by the IT systems + * management organization and should be used (when available) on audit logs and error messages. + * (qualifiedName from Referenceable - model 0010)</li> + * <li>displayName - A consumable name for the endpoint. Often a shortened form of the assetQualifiedName + * for use on user interfaces and messages. The assetDisplayName should be only be used for audit logs and error + * messages if the assetQualifiedName is not set. (Sourced from attribute name within Asset - model 0010)</li> + * <li>shortDescription - short description about the asset. + * (Sourced from assetSummary within ConnectionsToAsset - model 0205)</li> + * <li>description - full description of the asset. + * (Sourced from attribute description within Asset - model 0010)</li> + * <li>owner - name of the person or organization that owns the asset. + * (Sourced from attribute owner within Asset - model 0010)</li> + * <li>classifications - list of classifications assigned to the asset</li> + * </ul> + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AssetSummary extends AssetDescriptor +{ + /* + * Official type definition for this asset + */ + private ElementType type = null; + + /* + * Standard header for any metadata entity + */ + private String guid = null; + private String url = null; + + /* + * Base attributes from Referenceable and Asset + */ + private String qualifiedName = null; + private String displayName = null; + private String shortDescription = null; + private String description = null; + private String owner = null; + + /* + * Attached classifications + */ + private List<Classification> classifications = null; + + + /** + * Typical Constructor - the AssetSummary is empty + */ + public AssetSummary() + { + /* + * Initialize super class + */ + super(); + } + + + /** + * Copy/clone constructor. Note, this is a deep copy + * + * @param templateAssetSummary - template values for asset summary + */ + public AssetSummary(AssetSummary templateAssetSummary) + { + /* + * Initialize super class + */ + super(templateAssetSummary); + + /* + * Copy relevant values from the template + */ + if (templateAssetSummary != null) + { + type = templateAssetSummary.getType(); + guid = templateAssetSummary.getGUID(); + url = templateAssetSummary.getURL(); + qualifiedName = templateAssetSummary.getQualifiedName(); + displayName = templateAssetSummary.getDisplayName(); + shortDescription = templateAssetSummary.getShortDescription(); + description = templateAssetSummary.getDescription(); + owner = templateAssetSummary.getOwner(); + + List<Classification> templateClassifications = templateAssetSummary.getClassifications(); + if (templateClassifications != null) + { + classifications = new ArrayList<>(templateClassifications); + } + + } + } + + + /** + * Return the element type properties for this asset. These values are set up by the metadata repository + * and define details to the metadata entity used to represent this element. + * + * @return ElementType - type information. + */ + public ElementType getType() + { + return type; + } + + + /** + * Set up the type properties for this element. + * + * @param type - details of the metadata type for this asset + */ + public void setType(ElementType type) + { + if (type == null) + { + this.type = new ElementType(); + } + else + { + this.type = type; + super.setAssetTypeName(type.getElementTypeName()); + } + } + + + /** + * Return the unique id for this element. + * + * @return guid - unique id + */ + public String getGUID() { + return guid; + } + + + /** + * Updates the guid property stored for the element. + * If a null is supplied it is saved as a null. + * + * @param newGUID - guid property + */ + public void setGUID(String newGUID) + { + if (newGUID != null) + { + guid = newGUID; + } + else + { + guid = ""; + } + } + + + /** + * Returns the URL for this element in the metadata repository. + * If no URL is known for the element then null is returned. + * + * @return element URL + */ + public String getURL() { + return url; + } + + + /** + * Updates the URL for the element used to access its properties in the metadata repository. + * If a null is supplied it is saved as a null. + * + * @param url - element URL + */ + public void setURL(String url) { + this.url = url; + } + + + /** + * Returns the stored qualified name property for the asset. + * If no qualified name is provided then null is returned. + * + * @return qualifiedName + */ + public String getQualifiedName() { + return qualifiedName; + } + + + /** + * Updates the qualified name property stored for the asset. + * If a null is supplied it is saved as a null. + * + * @param newQualifiedName - unique name + */ + public void setQualifiedName(String newQualifiedName) + { + if (newQualifiedName != null) + { + qualifiedName = newQualifiedName; + + /* + * Use the qualified name as the asset name if it is not the empty string. + */ + if (!qualifiedName.equals("")) + { + super.setAssetName(qualifiedName); + } + } + else + { + qualifiedName = ""; + } + } + + + /** + * Returns the stored display name property for the asset. + * If no display name is available then null is returned. + * + * @return displayName + */ + public String getDisplayName() + { + return displayName; + } + + + /** + * Updates the display name property stored for the asset. + * If a null is supplied it clears the display name. + * + * @param newDisplayName - consumable name + */ + public void setDisplayName(String newDisplayName) + { + displayName = newDisplayName; + + if (displayName != null && (!displayName.equals(""))) + { + /* + * Use the display name for the asset name if qualified name is not set up. + */ + if (qualifiedName == null || qualifiedName.equals("")) + { + super.setAssetName(displayName); + } + } + } + + + /** + * Returns the short description of the asset from relationship with Connection. + * + * @return shortDescription + */ + public String getShortDescription() + { + return shortDescription; + } + + + /** + * Sets the short description for the asset. + * + * @param assetShortDescription - short description from relationship with Connection + */ + public void setShortDescription(String assetShortDescription) + { + this.shortDescription = assetShortDescription; + } + + + /** + * Returns the stored description property for the asset. + * If no description is provided then null is returned. + * + * @return description + */ + public String getDescription() + { + return description; + } + + + /** + * Updates the description property stored for the asset. + * If a null is supplied it clears any saved description. + * + * @param newDescription - description + */ + public void setDescription(String newDescription) { description = newDescription; } + + + /** + * Returns the name of the owner for this asset. + * + * @return owner + */ + public String getOwner() { + return owner; + } + + + /** + * Updates the name of the owner for this asset. + * + * @param newOwner - owner name + */ + public void setOwner(String newOwner) { owner = newOwner; } + + + /** + * Return the list of classifications associated with the asset. This is an enumeration and the + * pointers are set to the start of the list of classifications + * + * @return Classifications - list of classifications + */ + public List<Classification> getClassifications() + { + if (classifications == null) + { + return classifications; + } + else + { + return new ArrayList<>(classifications); + } + } + + + /** + * Set up the list of classifications for this asset. + * + * @param classifications - list of classifications + */ + public void setClassifications(List<Classification> classifications) + { + if (classifications == null) + { + this.classifications = classifications; + } + else + { + this.classifications = new ArrayList<>(classifications); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/atlas/blob/f57fd7f0/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/AssetUniverse.java ---------------------------------------------------------------------- diff --git a/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/AssetUniverse.java b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/AssetUniverse.java new file mode 100644 index 0000000..0042f1e --- /dev/null +++ b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/AssetUniverse.java @@ -0,0 +1,332 @@ +/** + * 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.atlas.omas.connectedasset.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.ArrayList; +import java.util.List; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AssetUniverse extends AssetDetail which extend AssetSummary. AssetUniverse adds information about the + * common open metadata entities related to this asset. + * <ul> + * <li>Meanings - glossary term(s) assigned to this asset.</li> + * <li>Schema - details of the schema associated with the asset.</li> + * <li>Analysis - details of the annotations added by the discovery services.</li> + * <li>Feedback - details of the people, products and feedback that are connected to the asset.</li> + * <li>Locations - details of the known locations of the asset.</li> + * <li>Lineage - details of the lineage for the asset.</li> + * <li>Related Assets - details of the assets lined to this asset.</li> + * </ul> + * + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AssetUniverse extends AssetDetail +{ + private List<Meaning> meanings = null; + private SchemaElement schema = null; + private Analysis analysis = null; + private Feedback feedback = null; + private List<Location> knownLocations = null; + private Lineage lineage = null; + private List<RelatedAsset> relatedAssets = null; + + + /** + * Typical Constructor + */ + public AssetUniverse() + { + /* + * Initialize the super classes + */ + super(); + } + + + /** + * Copy/clone Constructor - note this is a deep copy + * + * @param templateAssetUniverse - template to copy + */ + public AssetUniverse(AssetUniverse templateAssetUniverse) + { + /* + * Initialize the super classes + */ + super(templateAssetUniverse); + + /* + * Set up the universe private variables. + */ + if (templateAssetUniverse != null) + { + /* + * Create the top-level property objects for this new asset using the values from the template. + * The get methods create clones of the returned objects so no need to duplicate objects here. + */ + List<Meaning> templateMeanings = templateAssetUniverse.getMeanings(); + SchemaElement templateSchema = templateAssetUniverse.getSchema(); + Analysis templateAnalysis = templateAssetUniverse.getAnalysis(); + Feedback templateFeedback = templateAssetUniverse.getFeedback(); + List<Location> templateLocations = templateAssetUniverse.getKnownLocations(); + Lineage templateLineage = templateAssetUniverse.getLineage(); + List<RelatedAsset> templateRelatedAssets = templateAssetUniverse.getRelatedAssets(); + + if (templateMeanings != null) + { + meanings = new ArrayList<>(templateMeanings); + } + if (templateSchema != null) + { + if (templateSchema.getType().equals("Schema")) + { + schema = new Schema((Schema) templateSchema); + } + else + { + schema = new PrimitiveSchemaElement((PrimitiveSchemaElement) templateSchema); + } + } + if (templateAnalysis != null) + { + analysis = new Analysis(templateAnalysis); + } + if (templateFeedback != null) + { + feedback = new Feedback(templateFeedback); + } + if (templateLocations != null) + { + knownLocations = new ArrayList<>(templateLocations); + } + if (templateLineage != null) + { + lineage = new Lineage(templateLineage); + } + if (templateRelatedAssets != null) + { + relatedAssets = new ArrayList<>(templateRelatedAssets); + } + } + } + + + /** + * Return the list of glossary definitions assigned directly to this asset. + * + * @return Meanings - list of glossary definitions. + */ + public List<Meaning> getMeanings() + { + if (meanings == null) + { + return meanings; + } + else + { + return new ArrayList<>(meanings); + } + } + + + /** + * Set up definitions assigned to the asset. + * + * @param meanings - Meanings - list of glossary definitions. + */ + public void setMeanings(List<Meaning> meanings) { this.meanings = meanings; } + + + /** + * Return details of the schema associated with the asset. + * + * @return SchemaElement - schema object to query the schema associated with the connected asset. + */ + public SchemaElement getSchema() + { + if (schema == null) + { + return schema; + } + else + { + return schema.cloneSchemaElement(); + } + } + + + /** + * Set up the schema object for this connected asset. This should contain the schema itself and + * the glossary definitions linked to the schema elements. + * + * @param schema - Schema object to query schema and related glossary definitions. + */ + public void setSchema(SchemaElement schema) { + this.schema = schema; + } + + + + /** + * Return details of the metadata discovery analysis for the asset. + * + * @return Analysis - analysis object to query the annotations + */ + public Analysis getAnalysis() + { + if (analysis == null) + { + return analysis; + } + else + { + return new Analysis(analysis); + } + } + + + /** + * Set up the analysis object for the connected asset. This should contain all of the annotations associated + * with the asset. + * + * @param analysis - Analysis object to query the annotations + */ + public void setAnalysis(Analysis analysis) + { + this.analysis = analysis; + } + + + /** + * Return details of the people, products and feedback that are connected to the asset. + * + * @return Feedback - feedback object to query the feedback on the asset. + */ + public Feedback getFeedback() + { + if (feedback == null) + { + return feedback; + } + else + { + return new Feedback(feedback); + } + } + + + /** + * Set up the feedback object for the connected asset. This should contain all of the feedback associated + * with the asset. + * + * @param feedback - Feedback object to query the feedback. + */ + public void setFeedback(Feedback feedback) { + this.feedback = feedback; + } + + + /** + * Set up the list of locations for the asset. + * + * @return Locations - list of locations. + */ + public List<Location> getKnownLocations() + { + if (knownLocations == null) + { + return knownLocations; + } + else + { + return new ArrayList<>(knownLocations); + } + } + + + /** + * Set up the list of locations for the assets. + * + * @param knownLocations - Locations list + */ + public void setKnownLocations(List<Location> knownLocations) { this.knownLocations = knownLocations; } + + + /** + * Return details of the lineage for the asset. + * + * @return Lineage - lineage object that allows queries about the lineage of the asset. + */ + public Lineage getLineage() + { + if (lineage == null) + { + return lineage; + } + else + { + return new Lineage(lineage); + } + } + + + /** + * Set up the lineage object for the asset. + * + * @param lineage - lineage object to query the origin of the asset. + */ + public void setLineage(Lineage lineage) { + this.lineage = lineage; + } + + + /** + * Return the list of assets related to this asset. + * + * @return RelatedAssets list + */ + public List<RelatedAsset> getRelatedAssets() + { + if (relatedAssets == null) + { + return relatedAssets; + } + else + { + return new ArrayList<>(relatedAssets); + } + } + + + /** + * Set up the related assets for this asset. + * + * @param relatedAssets - RelatedAssets list + */ + public void setRelatedAssets(List<RelatedAsset> relatedAssets) { this.relatedAssets = relatedAssets; } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/atlas/blob/f57fd7f0/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/Certification.java ---------------------------------------------------------------------- diff --git a/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/Certification.java b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/Certification.java new file mode 100644 index 0000000..9e98c03 --- /dev/null +++ b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/Certification.java @@ -0,0 +1,321 @@ +/* + * 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.omas.connectedasset.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Date; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * <p> + * Certification stores the certifications awarded to the asset. + * </p> + * <p> + * Many regulations and industry bodies define certifications that can confirm a level of support, + * capability or competence in an aspect of a digital organizationâs operation. + * Having certifications may be necessary to operating legally or may be a business advantage. + * </p> + * <p> + * The certifications awarded to an asset can be captured in the metadata repository to enable both + * use and management of the certification process. + * </p> + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class Certification extends Referenceable +{ + /* + * Properties of a certification + */ + private String certificationTypeGUID = null; + private String certificationTypeName = null; + private String examiner = null; + private String summary = null; + private ExternalReference link = null; + private Date startDate = null; + private Date endDate = null; + private String certificationConditions = null; + private String createdBy = null; + private String custodian = null; + private String notes = null; + + + /** + * Default constructor. + */ + public Certification() + { + super(); + } + + + /** + * Copy/clone constructor. + * + * @param templateCertification - element to copy + */ + public Certification(Certification templateCertification) + { + super(templateCertification); + + if (templateCertification != null) + { + certificationTypeGUID = templateCertification.getCertificationTypeGUID(); + certificationTypeName = templateCertification.getCertificationTypeName(); + examiner = templateCertification.getExaminer(); + summary = templateCertification.getSummary(); + + ExternalReference templateLink = templateCertification.getLink(); + if (templateLink != null) + { + link = new ExternalReference(templateLink); + } + + Date templateStartDate = templateCertification.getStartDate(); + if (templateStartDate != null) + { + startDate = new Date(templateStartDate.getTime()); + } + + Date templateEndDate = templateCertification.getEndDate(); + if (templateEndDate != null) + { + endDate = new Date(templateStartDate.getTime()); + } + + certificationConditions = templateCertification.getCertificationConditions(); + createdBy = templateCertification.getCreatedBy(); + custodian = templateCertification.getCustodian(); + notes = templateCertification.getNotes(); + } + } + + + /** + * Return the unique id for the type of certification. + * + * @return String certification type GUID + */ + public String getCertificationTypeGUID() { return certificationTypeGUID; } + + + /** + * Set up the unique id of the certification type. + * + * @param certificationGUID - String certification type GUID + */ + public void setCertificationTypeGUID(String certificationGUID) { this.certificationTypeGUID = certificationGUID; } + + + /** + * Return the type of the certification. + * + * @return String certification type + */ + public String getCertificationTypeName() { return certificationTypeName; } + + + /** + * Set up the type of the certification. + * + * @param certificationTypeName - String certification type + */ + public void setCertificationTypeName(String certificationTypeName) { this.certificationTypeName = certificationTypeName; } + + + /** + * Get the name of the organization or person that issued the certification. + * + * @return String name + */ + public String getExaminer() { return examiner; } + + + /** + * Set up the name of the organization or person that issued the certification. + * + * @param examiner - String name + */ + public void setExaminer(String examiner) { this.examiner = examiner; } + + + /** + * Return a brief summary of the certification. + * + * @return String summary + */ + public String getSummary() { return summary; } + + + /** + * Set up a brief summary of the certification. + * + * @param summary - String + */ + public void setSummary(String summary) { this.summary = summary; } + + + /** + * Return the link to the full text of the certification. + * + * @return ExternalReference for full text + */ + public ExternalReference getLink() + { + if (link == null) + { + return link; + } + else + { + return new ExternalReference(link); + } + } + + + /** + * Set up the link to the full text of the certification. + * + * @param link - ExternalReference for full text + */ + public void setLink(ExternalReference link) { this.link = link; } + + + /** + * Return the start date for the certification. Null means unknown or not relevant. + * + * @return Date + */ + public Date getStartDate() + { + if (startDate == null) + { + return startDate; + } + else + { + return new Date(startDate.getTime()); + } + } + + + /** + * Set up start date for the certification. Null means unknown or not relevant. + * + * @param startDate - Date + */ + public void setStartDate(Date startDate) { this.startDate = startDate; } + + + /** + * Return the end date for the certification. Null means it does not expire. + * + * @return Date + */ + public Date getEndDate() + { + if (endDate == null) + { + return endDate; + } + else + { + return new Date(endDate.getTime()); + } + } + + + /** + * Set up the end date for the certification. Null means it does not expire. + * + * @param endDate - Date + */ + public void setEndDate(Date endDate) { this.endDate = endDate; } + + + /** + * Return any special conditions that apply to the certification - such as endorsements. + * + * @return String certification conditions + */ + public String getCertificationConditions() { return certificationConditions; } + + + /** + * Set up any special conditions that apply to the certification - such as endorsements. + * + * @param conditions - String certification conditions + */ + public void setCertificationConditions(String conditions) { this.certificationConditions = conditions; } + + + /** + * Return the name of the person or organization that set up the certification for this asset. + * + * @return String name + */ + public String getCreatedBy() { return createdBy; } + + + /** + * Set up the name of the person or organization that set up the certification for this asset. + * + * @param createdBy - String name + */ + public void setCreatedBy(String createdBy) { this.createdBy = createdBy; } + + + /** + * Return the name of the person or organization that is responsible for the correct management of the asset + * according to the certification. + * + * @return String name + */ + public String getCustodian() { return custodian; } + + + /** + * Set up the name of the person or organization that is responsible for the correct management of the asset + * according to the certification. + * + * @param custodian - String name + */ + public void setCustodian(String custodian) { this.custodian = custodian; } + + + /** + * Return the notes from the custodian. + * + * @return String notes + */ + public String getNotes() { return notes; } + + + /** + * Set up the notes from the custodian. + * + * @param notes - String + */ + public void setNotes(String notes) { this.notes = notes; } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/atlas/blob/f57fd7f0/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/Classification.java ---------------------------------------------------------------------- diff --git a/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/Classification.java b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/Classification.java new file mode 100644 index 0000000..5a41333 --- /dev/null +++ b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/Classification.java @@ -0,0 +1,169 @@ +/* + * 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.omas.connectedasset.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.apache.atlas.omas.connectedasset.ffdc.ConnectedAssetErrorCode; +import org.apache.atlas.omas.connectedasset.ffdc.exceptions.ConnectedAssetRuntimeException; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * The Classification class stores information about a classification assigned to an asset. The Classification + * has a name and some properties. It also stores the typename of the asset it is connected to for debug purposes. + * + * Note: it is not valid to have a classification with a null or blank name. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class Classification extends PropertyBase +{ + private String classificationName; + private AdditionalProperties classificationProperties; + + /** + * A private validation method used by the constructors. + * + * @param name - name to check + * @return validated name + */ + private String validateName(String name) + { + final String methodName = "validateName"; + + /* + * Throw an exception if the classification's name is null because that does not make sense. + * The constructors do not catch this exception so it is received by the creator of the classification + * object. + */ + if (name == null || name.equals("")) + { + /* + * Build and throw exception. This should not happen - likely to be a problem in the + * repository connector. + */ + ConnectedAssetErrorCode errorCode = ConnectedAssetErrorCode.NULL_CLASSIFICATION_NAME; + String errorMessage = errorCode.getErrorMessageId() + + errorCode.getFormattedErrorMessage(methodName, this.getClass().getName()); + + throw new ConnectedAssetRuntimeException(errorCode.getHTTPErrorCode(), + this.getClass().getName(), + methodName, + errorMessage, + errorCode.getSystemAction(), + errorCode.getUserAction()); + } + else + { + return name; + } + } + + + /** + * Typical constructor - verifies and saves parameters. + * + * @param name - name of the classification + * @param properties - additional properties for the classification + */ + public Classification(String name, + AdditionalProperties properties) + { + super(); + + this.classificationName = validateName(name); + this.classificationProperties = properties; + } + + + /** + * Copy/clone Constructor - sets up new classification using values from the template + * + * @param templateClassification - object to copy + */ + public Classification(Classification templateClassification) + { + super(templateClassification); + + final String methodName = "Constructor"; + + /* + * An empty classification object is passed in the variable declaration so throw exception + * because we need the classification name. + */ + if (templateClassification == null) + { + /* + * Build and throw exception. This should not happen - likely to be a problem in the + * repository connector. + */ + ConnectedAssetErrorCode errorCode = ConnectedAssetErrorCode.NULL_CLASSIFICATION_NAME; + String errorMessage = errorCode.getErrorMessageId() + + errorCode.getFormattedErrorMessage(methodName, this.getClass().getName()); + + throw new ConnectedAssetRuntimeException(errorCode.getHTTPErrorCode(), + this.getClass().getName(), + methodName, + errorMessage, + errorCode.getSystemAction(), + errorCode.getUserAction()); + } + else + { + /* + * Save the name and properties. + */ + this.classificationName = validateName(templateClassification.getName()); + this.classificationProperties = templateClassification.getProperties(); + } + } + + + /** + * Return the name of the classification + * + * @return name of classification + */ + public String getName() + { + return classificationName; + } + + + /** + * Returns a collection of the additional stored properties for the classification. + * If no stored properties are present then null is returned. + * + * @return properties for the classification + */ + public AdditionalProperties getProperties() + { + if (classificationProperties == null) + { + return classificationProperties; + } + else + { + return new AdditionalProperties(classificationProperties); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/atlas/blob/f57fd7f0/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/Comment.java ---------------------------------------------------------------------- diff --git a/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/Comment.java b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/Comment.java new file mode 100644 index 0000000..40c354c --- /dev/null +++ b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/Comment.java @@ -0,0 +1,186 @@ +/* + * 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.omas.connectedasset.properties; + + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.ArrayList; +import java.util.List; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * Stores information about a comment connected to an asset. Comments provide informal feedback to assets + * and can be added at any time. + * + * Comments have the userId of the person who added the feedback, along with their comment text. + * + * Comments can have other comments attached. + * + * The content of the comment is a personal statement (which is why the user's id is in the comment) + * and there is no formal review of the content. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class Comment extends ElementHeader +{ + /* + * Attributes of a Comment + */ + private String commentText = null; + private String user = null; + private List<Comment> commentReplies = null; + private CommentType commentType = null; + + + /** + * Default Constructor + */ + public Comment() + { + super(); + } + + + /** + * Copy/clone constructor. + * + * @param templateComment - element to copy + */ + public Comment(Comment templateComment) + { + super(templateComment); + + if (templateComment != null) + { + /* + * Copy the values from the supplied comment. + */ + user = templateComment.getUser(); + commentText = templateComment.getCommentText(); + + List<Comment> templateCommentReplies = templateComment.getCommentReplies(); + if (templateCommentReplies != null) + { + commentReplies = new ArrayList<>(templateCommentReplies); + } + } + } + + + /** + * Return the user id of the person who created the comment. Null means the user id is not known. + * + * @return String - commenting user + */ + public String getUser() { + return user; + } + + + /** + * Set up the user id of the person who created the comment. Null means the user id is not known. + * + * @param user - String - commenting user + */ + public void setUser(String user) { + this.user = user; + } + + + /** + * Return the comment text. + * + * @return String - commentText + */ + public String getCommentText() { + return commentText; + } + + + /** + * Set up the comment text. + * + * @param commentText String + */ + public void setCommentText(String commentText) { this.commentText = commentText; } + + + /** + * Return an enumeration of the replies to this comment - null means no replies are available. + * + * @return Comments - comment replies list + */ + public List<Comment> getCommentReplies() + { + if (commentReplies == null) + { + return commentReplies; + } + else + { + return new ArrayList<>(commentReplies); + } + } + + + /** + * Set up the comment replies enumeration - null means no replies are available. + * + * @param commentReplies - List of Comments + */ + public void setCommentReplies(List<Comment> commentReplies) + { + if (commentReplies == null) + { + this.commentReplies = null; + } + else + { + this.commentReplies = new ArrayList<>(commentReplies); + } + } + + + /** + * Return the type of comment. + * + * @return comment type enum + */ + public CommentType getCommentType() + { + return commentType; + } + + + /** + * Set up the type of comment. + * + * @param commentType - enum + */ + public void setCommentType(CommentType commentType) + { + this.commentType = commentType; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/atlas/blob/f57fd7f0/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/CommentType.java ---------------------------------------------------------------------- diff --git a/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/CommentType.java b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/CommentType.java new file mode 100644 index 0000000..675b2cc --- /dev/null +++ b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/CommentType.java @@ -0,0 +1,96 @@ +/* + * 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.omas.connectedasset.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serializable; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * The CommentType allows comments to be used to ask and answer questions as well as make suggestions and + * provide useful information to other users. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum CommentType implements Serializable +{ + STANDARD_COMMENT(0, "Comment", "General comment about the asset."), + QUESTION(1, "Question", "Asks a question to the people owning, managing or using the asset."), + ANSWER(2, "Answer", "Answers a question (posted as a reply to the question)."), + SUGGESTION(3, "Suggestion", "Provides a suggestion on how to improve the asset or its properties and description."), + USAGE_EXPERIENCE(4, "Experience", "Describes situations where this asset has been used and related hints and tips."); + + private static final long serialVersionUID = 1L; + + private int commentTypeCode; + private String commentType; + private String commentTypeDescription; + + + /** + * Typical Constructor + */ + CommentType(int commentTypeCode, String commentType, String commentTypeDescription) + { + /* + * Save the values supplied + */ + this.commentTypeCode = commentTypeCode; + this.commentType = commentType; + this.commentTypeDescription = commentTypeDescription; + } + + + /** + * Return the code for this enum instance + * + * @return int - comment type code + */ + public int getCommentTypeCode() + { + return commentTypeCode; + } + + + /** + * Return the default type name for this enum instance. + * + * @return String - default type name + */ + public String getCommentType() + { + return commentType; + } + + + /** + * Return the default description for the star rating for this enum instance. + * + * @return String - default description + */ + public String getCommentTypeDescription() + { + return commentTypeDescription; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/atlas/blob/f57fd7f0/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/Connection.java ---------------------------------------------------------------------- diff --git a/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/Connection.java b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/Connection.java new file mode 100644 index 0000000..1bafb4b --- /dev/null +++ b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/Connection.java @@ -0,0 +1,313 @@ +/* + * 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.omas.connectedasset.properties; + + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * The connection is an object that contains the properties needed to create and initialise a connector to access a + * specific data assets. + * + * The properties for a connection are defined in model 0201. They include the following options for connector name: + * <ul> + * <li> + * guid - Globally unique identifier for the connection. + * </li> + * <li> + * url - URL of the connection definition in the metadata repository. + * This URL can be stored as a property in another entity to create an explicit link to this connection. + * </li> + * <li> + * qualifiedName - The official (unique) name for the connection. + * This is often defined by the IT systems management organization and should be used (when available) on + * audit logs and error messages. The qualifiedName is defined in the 0010 model as part of Referenceable. + * </li> + * <li> + * displayName - A consumable name for the connection. Often a shortened form of the qualifiedName for use + * on user interfaces and messages. The displayName should be only be used for audit logs and error messages + * if the qualifiedName is not set. + * </li> + * </ul> + * Either the guid, qualifiedName or displayName can be used to specify the name for a connection. + * + * Other properties for the connection include: + * + * <ul> + * <li> + * type - information about the TypeDef for Connection + * </li> + * <li> + * description - A full description of the connection covering details of the assets it connects to + * along with usage and versioning information. + * </li> + * <li> + * additionalProperties - Any additional properties associated with the connection. + * </li> + * <li> + * securedProperties - Protected properties for secure log on by connector to back end server. These + * are protected properties that can only be retrieved by privileged connector code. + * </li> + * <li> + * connectorType - Properties that describe the connector type for the connector. + * </li> + * <li> + * endpoint - Properties that describe the server endpoint where the connector will retrieve the assets. + * </li> + * </ul> + + * The connection class is simply used to cache the properties for an connection. + * It is used by other classes to exchange this information between a metadata repository and a consumer. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class Connection extends Referenceable +{ + /* + * Attributes of a connector + */ + private String displayName = null; + private String description = null; + private ConnectorType connectorType = null; + private Endpoint endpoint = null; + + /* + * Secured properties are protected so they can only be accessed by subclassing this object. + */ + protected AdditionalProperties securedProperties = null; + + + /** + * Default Constructor - this is used when the connection is being used independently of the connected + * asset - typically when constructing Connectors and managing information about remote systems. + * This is why the parent asset is null. + */ + public Connection() + { + super(null); + } + + + /** + * Copy/clone Constructor to return a copy of a connection object that is not connected to an asset. + * + * @param templateConnection - Connection to copy + */ + public Connection(Connection templateConnection) + { + super(templateConnection); + + /* + * Copy over properties from the template. + */ + if (templateConnection != null) + { + displayName = templateConnection.getDisplayName(); + description = templateConnection.getDescription(); + + ConnectorType templateConnectorType = templateConnection.getConnectorType(); + Endpoint templateEndpoint = templateConnection.getEndpoint(); + AdditionalProperties templateSecuredProperties = templateConnection.getSecuredProperties(); + + if (templateConnectorType != null) + { + connectorType = new ConnectorType(templateConnectorType); + } + if (templateEndpoint != null) + { + endpoint = new Endpoint(templateEndpoint); + } + if (templateSecuredProperties != null) + { + securedProperties = new AdditionalProperties(templateSecuredProperties); + } + } + } + + + /** + * Returns the stored display name property for the connection. + * Null means no displayName is available. + * + * @return displayName + */ + public String getDisplayName() { return displayName; } + + + /** + * Updates the display name property stored for the connection. + * If a null is supplied it means no display name is available. + * + * @param newDisplayName - consumable name + */ + public void setDisplayName(String newDisplayName) { displayName = newDisplayName; } + + + /** + * Returns a formatted string with the connection name. It is used in formatting error messages for the + * exceptions thrown by consuming components. It is extremely cautious because most of the exceptions + * are reporting a malformed connection object so who knows what else is wrong with it. + * + * Within the connection are 2 possible properties that could + * contain the connection name: + * ** qualifiedName - this is a uniqueName and should be there + * ** displayName - shorter simpler name but may not be unique - so may not identify the connection in error + * + * This method inspects these properties and builds up a string to represent the connection name + * + * @return connection name + */ + public String getConnectionName() + { + String connectionName = "<Unknown>"; /* if all properties are blank */ + + /* + * The qualifiedName is preferred because it is unique. + */ + if (qualifiedName != null && (!qualifiedName.equals(""))) + { + /* + * Use qualified name. + */ + connectionName = qualifiedName; + } + else if (displayName != null && (!displayName.equals(""))) + { + /* + * The qualifiedName is not set but the displayName is available so use it. + */ + connectionName = displayName; + } + + return connectionName; + } + + + /** + * Returns the stored description property for the connection. + * If no description is provided then null is returned. + * + * @return description + */ + public String getDescription() + { + return description; + } + + + /** + * Updates the description property stored for the connection. + * If a null is supplied it means no description is available. + * + * @param newDescription - description + */ + public void setDescription(String newDescription) { description = newDescription; } + + + /** + * Returns a copy of the properties for this connection's connector type. + * A null means there is no connection type. + * + * @return connector type + */ + public ConnectorType getConnectorType() + { + if (connectorType == null) + { + return connectorType; + } + else + { + return new ConnectorType(connectorType); + } + } + + + /** + * Updates the connector type for the connection. If null is supplied, it means there is no connection type. + * + * @param newConnectorType - connector type to copy + */ + public void setConnectorType(ConnectorType newConnectorType) { connectorType = newConnectorType; } + + + /** + * Returns a copy of the properties for this connection's endpoint. + * Null means no endpoint information available. + * + * @return endpoint + */ + public Endpoint getEndpoint() + { + if (endpoint == null) + { + return endpoint; + } + else + { + return new Endpoint(endpoint); + } + } + + + /** + * Updates the endpoint properties for this connection. If null is supplied is means there is no endpoint + * defined for this connection. + * + * @param newEndpoint - endpoint properties + */ + public void setEndpoint(Endpoint newEndpoint) { endpoint = newEndpoint; } + + + /** + * Return a copy of the secured properties. Null means no secured properties are available. + * This method is protected so only OCF (or subclasses) can access them. When Connector is passed to calling + * OMAS, the secured properties are not available. + * + * @return secured properties - typically user credentials for the connection + */ + protected AdditionalProperties getSecuredProperties() + { + if (securedProperties == null) + { + return securedProperties; + } + else + { + return new AdditionalProperties(securedProperties); + } + } + + + /** + * Set up a new secured properties object. This is public so the metadata repository can set up the + * secured properties retrieved from the metadata repository. + * + * @param newSecuredProperties - typically user credentials for the connection + */ + public void setSecuredProperties(AdditionalProperties newSecuredProperties) + { + securedProperties = newSecuredProperties; + } +} \ No newline at end of file
