http://git-wip-us.apache.org/repos/asf/atlas/blob/f57fd7f0/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/SchemaElement.java ---------------------------------------------------------------------- diff --git a/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/SchemaElement.java b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/SchemaElement.java new file mode 100644 index 0000000..f85d55e --- /dev/null +++ b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/SchemaElement.java @@ -0,0 +1,161 @@ +/** + * 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 static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * <p> + * The SchemaElement object provides a base class for the pieces that make up a schema for a data asset. + * A schema provides information about how the data is structured in the asset. Schemas are typically + * described as nested structures of linked schema elements. Schemas can also be reused in other schemas. + * </p> + * SchemaElement is an abstract class - used to enable the most accurate and precise mapping of the + * elements in a schema to the asset. + * <ul> + * <li>PrimitiveSchemaElement is for a leaf element in a schema.</li> + * <li>Schema is a complex structure of nested schema elements.</li> + * <li>MapSchemaElement is for an attribute of type Map</li> + * </ul> + * Most assets will be linked to a Schema. + * <p> + * Schema elements can be linked to one another using SchemaLink. + * </p> + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public abstract class SchemaElement extends Referenceable +{ + private String versionNumber = null; + private String author = null; + private String usage = null; + private String encodingStandard = null; + + + /** + * Default constructor + */ + public SchemaElement() + { + super(); + } + + + /** + * 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 templateSchema - template object to copy. + */ + public SchemaElement(SchemaElement templateSchema) + { + super(templateSchema); + + if (templateSchema != null) + { + versionNumber = templateSchema.getVersionNumber(); + author = templateSchema.getAuthor(); + usage = templateSchema.getUsage(); + encodingStandard = templateSchema.getEncodingStandard(); + } + } + + + /** + * Return a clone of the this schema element. This method is needed because schema element + * is abstract. + * + * @return Either a Schema or a PrimitiveSchemaElement depending on the type of the template. + */ + public abstract SchemaElement cloneSchemaElement(); + + + /** + * Return the version number of the schema element - null means no version number. + * + * @return String version number + */ + public String getVersionNumber() { return versionNumber; } + + + /** + * Set up the version number of the schema element - null means no version number. + * + * @param versionNumber - String + */ + public void setVersionNumber(String versionNumber) { this.versionNumber = versionNumber; } + + + /** + * Return the name of the author of the schema element. Null means the author is unknown. + * + * @return String author name + */ + public String getAuthor() { return author; } + + + /** + * Set up the name of the author of the schema element. Null means the author is unknown. + * + * @param author - String author name + */ + public void setAuthor(String author) { this.author = author; } + + + /** + * Return the usage guidance for this schema element. Null means no guidance available. + * + * @return String usage guidance + */ + public String getUsage() { return usage; } + + + /** + * Set up the usage guidance for this schema element. Null means no guidance available. + * + * @param usage - String usage guidance + */ + public void setUsage(String usage) { this.usage = usage; } + + + /** + * Return the format (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. + * + * @return String encoding standard + */ + public String getEncodingStandard() { return encodingStandard; } + + + /** + * Set up the format (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 encodingStandard - String encoding standard + */ + public void setEncodingStandard(String encodingStandard) { this.encodingStandard = encodingStandard; } +} \ 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/SchemaImplementationQuery.java ---------------------------------------------------------------------- diff --git a/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/SchemaImplementationQuery.java b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/SchemaImplementationQuery.java new file mode 100644 index 0000000..a4a0e90 --- /dev/null +++ b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/SchemaImplementationQuery.java @@ -0,0 +1,155 @@ +/* + * 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; + +/** + * SchemaImplementationQuery defines a query on a schema attribute that returns all or part of the value for a + * derived field. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class SchemaImplementationQuery extends PropertyBase +{ + private int queryId = 0; + private String query = null; + private String queryType = null; + private SchemaAttribute queryTargetElement = null; + + /** + * Typical Constructor - sets attributes to null. + */ + public SchemaImplementationQuery() + { + super(); + } + + + /** + * Copy/clone constructor. + * + * @param template - template schema query to copy. + */ + public SchemaImplementationQuery(SchemaImplementationQuery template) + { + super(template); + + if (template != null) + { + queryId = template.getQueryId(); + query = template.getQuery(); + queryType = template.getQueryType(); + + SchemaAttribute templateQueryTargetElement = template.getQueryTargetElement(); + if (templateQueryTargetElement != null) + { + queryTargetElement = new SchemaAttribute(templateQueryTargetElement); + } + } + } + + + /** + * Return the query id - this is used to identify where the results of this query should be plugged into + * the other queries or the formula for the parent derived schema element. + * + * @return int query identifier + */ + public int getQueryId() { return queryId; } + + + /** + * Set up the query id - this is used to identify where the results of this query should be plugged into + * the other queries or the formula for the parent derived schema element. + * + * @param queryId - int query identifier + */ + public void setQueryId(int queryId) { this.queryId = queryId; } + + + /** + * Return the query string for this element. The query string may have placeholders for values returned + * by queries that have a lower queryId than this element. + * + * @return String query + */ + public String getQuery() { return query; } + + + /** + * Set up the query string for this element. The query string may have placeholders for values returned + * by queries that have a lower queryId than this element. + * + * @param query - String with placeholders + */ + public void setQuery(String query) { this.query = query; } + + + /** + * Return the name of the query language used in the query. + * + * @return queryType String + */ + public String getQueryType() { return queryType; } + + + /** + * Set up the name of the query language used in the query. + * + * @param queryType String + */ + public void setQueryType(String queryType) { this.queryType = queryType; } + + /** + * Return the SchemaAttribute that describes the type of the data source that will be queried to get the + * derived value. + * + * @return SchemaAttribute + */ + public SchemaAttribute getQueryTargetElement() + { + if (queryTargetElement == null) + { + return queryTargetElement; + } + else + { + return new SchemaAttribute(queryTargetElement); + } + } + + + /** + * Set up the SchemaAttribute that describes the type of the data source that will be queried to get the + * derived value. + * + * @param queryTargetElement - SchemaAttribute + */ + public void setQueryTargetElement(SchemaAttribute queryTargetElement) + { + this.queryTargetElement = queryTargetElement; + } +} \ 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/SchemaLink.java ---------------------------------------------------------------------- diff --git a/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/SchemaLink.java b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/SchemaLink.java new file mode 100644 index 0000000..8d1878a --- /dev/null +++ b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/SchemaLink.java @@ -0,0 +1,197 @@ +/* + * 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; + +/** + * SchemaLink defines a relationship between 2 SchemaElements. It is used in network type schemas such as a graph. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class SchemaLink extends PropertyBase +{ + /* + * Attributes from the relationship + */ + private String linkGUID = null; + private String linkType = null; + + /* + * Attributes specific to SchemaLink + */ + private String linkName = null; + private AdditionalProperties linkProperties = null; + private List<String> linkedAttributeGUIDs = null; + + + /** + * Default Constructor + */ + public SchemaLink() + { + super(); + } + + + /** + * Copy/clone constructor - makes a copy of the supplied object. + * + * @param template - template object to copy + */ + public SchemaLink(SchemaLink template) + { + super(template); + + if (template != null) + { + linkGUID = template.getLinkGUID(); + linkName = template.getLinkName(); + + AdditionalProperties templateLinkProperties = template.getLinkProperties(); + if (templateLinkProperties != null) + { + linkProperties = new AdditionalProperties(templateLinkProperties); + } + + List<String> templateLinkedAttributeGUIDs = template.getLinkedAttributeGUIDs(); + if (templateLinkedAttributeGUIDs != null) + { + linkedAttributeGUIDs = new ArrayList<>(templateLinkedAttributeGUIDs); + } + } + } + + + /** + * Return the identifier for the schema link. + * + * @return String guid + */ + public String getLinkGUID() { return linkGUID; } + + + /** + * Set up the identifier of the schema link. + * + * @param linkGUID - String guid + */ + public void setLinkGUID(String linkGUID) { this.linkGUID = linkGUID; } + + + /** + * Return the type of the link - this is related to the type of the schema it is a part of. + * + * @return String link type + */ + public String getLinkType() { return linkType; } + + + /** + * Set up the type of the link - this is related to the type of the schema it is a part of. + * + * @param linkType - String link type + */ + public void setLinkType(String linkType) { this.linkType = linkType; } + + /** + * Return the name of this link + * + * @return String name + */ + public String getLinkName() { return linkName; } + + + /** + * Set up the name of the schema link. + * + * @param linkName - String link name + */ + public void setLinkName(String linkName) { this.linkName = linkName; } + + + /** + * Return the list of properties associated with this schema link. + * + * @return AdditionalProperties + */ + public AdditionalProperties getLinkProperties() + { + if (linkProperties == null) + { + return linkProperties; + } + else + { + return new AdditionalProperties(linkProperties); + } + } + + + /** + * Set up the list of properties associated with this schema link. + * + * @param linkProperties - AdditionalProperties + */ + public void setLinkProperties(AdditionalProperties linkProperties) { this.linkProperties = linkProperties; } + + + /** + * Return the GUIDs of the schema attributes that this link connects together. + * + * @return SchemaAttributeGUIDs - GUIDs for either end of the link - return as a list. + */ + public List<String> getLinkedAttributeGUIDs() + { + if (linkedAttributeGUIDs == null) + { + return linkedAttributeGUIDs; + } + else + { + return new ArrayList<>(linkedAttributeGUIDs); + } + } + + + /** + * Set up the GUIDs of the schema attributes that this link connects together. + * + * @param linkedAttributeOneGUID - String GUID for a schema attribute + * @param linkedAttributeTwoGUID - String GUID for a schema attribute + */ + public void setLinkedAttributeGUIDs(String linkedAttributeOneGUID, String linkedAttributeTwoGUID) + { + List<String> linkedAttributeArray = new ArrayList<>(); + + linkedAttributeArray.add(linkedAttributeOneGUID); + linkedAttributeArray.add(linkedAttributeTwoGUID); + + this.linkedAttributeGUIDs = linkedAttributeArray; + } +} \ 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/StarRating.java ---------------------------------------------------------------------- diff --git a/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/StarRating.java b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/StarRating.java new file mode 100644 index 0000000..4d190b8 --- /dev/null +++ b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/StarRating.java @@ -0,0 +1,97 @@ +/* + * 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; + +/** + * A StarRating defines the rating that a user has placed against an asset. This ranges from not recommended + * through to five stars (excellent). + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum StarRating implements Serializable +{ + UNRATED(0, "X", "Not recommended"), + ONE_STAR(1, "*", "Poor"), + TWO_STARS(2, "**", "Usable"), + THREE_STARS(3, "***", "Good"), + FOUR_STARS(4, "****", "Very Good"), + FIVE_STARS(5, "*****", "Excellent"); + + private static final long serialVersionUID = 1L; + + private int starRatingCode = 99; + private String starRatingSymbol = ""; + private String starRatingDescription = ""; + + + /** + * Typical Constructor + */ + StarRating(int starRatingCode, String starRatingSymbol, String starRatingDescription) + { + /* + * Save the values supplied + */ + this.starRatingCode = starRatingCode; + this.starRatingSymbol = starRatingSymbol; + this.starRatingDescription = starRatingDescription; + } + + + /** + * Return the code for this enum instance + * + * @return int - star rating code + */ + public int getStarRatingCode() + { + return starRatingCode; + } + + + /** + * Return the default symbol for this enum instance. + * + * @return String - default symbol + */ + public String getStarRatingSymbol() + { + return starRatingSymbol; + } + + + /** + * Return the default description for the star rating for this enum instance. + * + * @return String - default description + */ + public String getStarRatingDescription() + { + return starRatingDescription; + } +} \ 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/VirtualConnection.java ---------------------------------------------------------------------- diff --git a/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/VirtualConnection.java b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/VirtualConnection.java new file mode 100644 index 0000000..da0907d --- /dev/null +++ b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/properties/VirtualConnection.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.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; + +/** + * A virtual connection is for an asset that provides data by delegating requests to one or more other connections. + * it maintains a list of the connections that are used by its asset. These are referred to as embedded connections. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class VirtualConnection extends Connection +{ + /* + * Attributes of a virtual connection + */ + protected List<EmbeddedConnection> embeddedConnections = null; + + + /** + * Default Constructor + */ + public VirtualConnection() + { + super(); + } + + + /** + * Copy/clone constructor. + * + * @param templateVirtualConnection - element to copy + */ + public VirtualConnection(VirtualConnection templateVirtualConnection) + { + /* + * Save the parent asset description. + */ + super(templateVirtualConnection); + + /* + * Extract additional information from the template if available + */ + if (templateVirtualConnection != null) + { + List<EmbeddedConnection> templateEmbeddedConnections = templateVirtualConnection.getEmbeddedConnections(); + + if (templateEmbeddedConnections != null) + { + /* + * Ensure comment replies has this object's parent asset, not the template's. + */ + embeddedConnections = new ArrayList<>(templateEmbeddedConnections); + } + } + } + + + /** + * Return the enumeration of embedded connections for this virtual connection. + * + * @return EmbeddedConnections + */ + public List<EmbeddedConnection> getEmbeddedConnections() + { + if (embeddedConnections == null) + { + return embeddedConnections; + } + else + { + return new ArrayList<>(embeddedConnections); + } + } + + + /** + * Set up the embedded connections for this virtual connection. + * + * @param embeddedConnections - list of Connections + */ + public void setEmbeddedConnections(List<EmbeddedConnection> embeddedConnections) + { + this.embeddedConnections = embeddedConnections; + } +} \ 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/server/ConnectedAssetRESTServices.java ---------------------------------------------------------------------- diff --git a/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/server/ConnectedAssetRESTServices.java b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/server/ConnectedAssetRESTServices.java new file mode 100644 index 0000000..8ae6c37 --- /dev/null +++ b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/server/ConnectedAssetRESTServices.java @@ -0,0 +1,87 @@ +/** + * 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.server; + +import org.apache.atlas.omas.connectedasset.ffdc.exceptions.PropertyServerException; +import org.apache.atlas.omas.connectedasset.properties.AssetUniverse; +import org.apache.atlas.omas.connectedasset.server.properties.AssetUniverseResponse; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +/** + * The ConnectedAssetRESTServices is the server-side implementation of the Connected Asset OMAS REST interface. + */ +@RestController +@RequestMapping("/omag/omas/connected-asset") +public class ConnectedAssetRESTServices +{ + + public ConnectedAssetRESTServices() + { + /* + * + */ + } + + + /** + * Returns a comprehensive collection of properties about the requested asset. + * + * @param userId - String - userId of user making request. + * @param guid - String - unique id for asset. + * + * @return AssetUniverseResponse - a comprehensive collection of properties about the asset or + * InvalidParameterException - one of the parameters is null or invalid. + * PropertyServerException - There is a problem retrieving the asset properties from + * the metadata repository. + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + @RequestMapping(method = RequestMethod.GET, path = "/{userId}/assets/{guid}") + + public AssetUniverseResponse getAssetProperties(@PathVariable String userId, + @PathVariable String guid) + { + return null; + } + + + + /** + * Returns a comprehensive collection of properties about the asset linked to the supplied connection. + * + * @param userId - String - userId of user making request. + * @param guid - String - unique id for connection. + * @return AssetUniverse - a comprehensive collection of properties about the connected asset + * InvalidParameterException - one of the parameters is null or invalid. + * PropertyServerException - There is a problem retrieving the asset properties from + * the metadata repository. + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + @RequestMapping(method = RequestMethod.GET, path = "/{userId}/assets/by-connection/{guid}") + + public AssetUniverseResponse getAssetPropertiesByConnection(@PathVariable String userId, + @PathVariable String guid) + { + AssetUniverse extractedAssetProperties = null; + + return null; + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/f57fd7f0/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/server/properties/AssetUniverseResponse.java ---------------------------------------------------------------------- diff --git a/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/server/properties/AssetUniverseResponse.java b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/server/properties/AssetUniverseResponse.java new file mode 100644 index 0000000..79d5325 --- /dev/null +++ b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/server/properties/AssetUniverseResponse.java @@ -0,0 +1,83 @@ +/* + * 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.server.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.properties.AssetUniverse; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + + +/** + * AssetUniverseResponse is the response structure used on the Connected Asset OMAS REST API calls that return an + * AssetUniverse object as a response. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AssetUniverseResponse extends ConnectedAssetOMASAPIResponse +{ + private AssetUniverse assetUniverse = null; + + + /** + * Default constructor + */ + public AssetUniverseResponse() + { + } + + + /** + * Return the AssetUniverse object. + * + * @return all details known about the asset + */ + public AssetUniverse getAssetUniverse() + { + return assetUniverse; + } + + + /** + * Set up the AssetUniverse object. + * + * @param assetUniverse - all details known about the asset + */ + public void setAssetUniverse(AssetUniverse assetUniverse) + { + this.assetUniverse = assetUniverse; + } + + + @Override + public String toString() + { + return "AssetUniverseResponse{" + + "assetUniverse=" + assetUniverse + + ", relatedHTTPCode=" + relatedHTTPCode + + ", exceptionClassName='" + exceptionClassName + '\'' + + ", exceptionErrorMessage='" + exceptionErrorMessage + '\'' + + ", exceptionSystemAction='" + exceptionSystemAction + '\'' + + ", exceptionUserAction='" + exceptionUserAction + '\'' + + '}'; + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/f57fd7f0/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/server/properties/ConnectedAssetOMASAPIResponse.java ---------------------------------------------------------------------- diff --git a/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/server/properties/ConnectedAssetOMASAPIResponse.java b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/server/properties/ConnectedAssetOMASAPIResponse.java new file mode 100644 index 0000000..bda4222 --- /dev/null +++ b/omas-connectedasset/src/main/java/org/apache/atlas/omas/connectedasset/server/properties/ConnectedAssetOMASAPIResponse.java @@ -0,0 +1,172 @@ +/* + * 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.server.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; + +/** + * ConnectedAssetOMASAPIResponse provides a common header for Asset Consumer OMAS managed responses to its REST API. + * It manages information about exceptions. If no exception has been raised exceptionClassName is null. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public abstract class ConnectedAssetOMASAPIResponse +{ + protected int relatedHTTPCode = 200; + protected String exceptionClassName = null; + protected String exceptionErrorMessage = null; + protected String exceptionSystemAction = null; + protected String exceptionUserAction = null; + + + /** + * Default constructor + */ + public ConnectedAssetOMASAPIResponse() + { + } + + + /** + * Return the HTTP Code to use if forwarding response to HTTP client. + * + * @return integer HTTP status code + */ + public int getRelatedHTTPCode() + { + return relatedHTTPCode; + } + + + /** + * Set up the HTTP Code to use if forwarding response to HTTP client. + * + * @param relatedHTTPCode - integer HTTP status code + */ + public void setRelatedHTTPCode(int relatedHTTPCode) + { + this.relatedHTTPCode = relatedHTTPCode; + } + + + /** + * Return the name of the Java class name to use to recreate the exception. + * + * @return String name of the fully-qualified java class name + */ + public String getExceptionClassName() + { + return exceptionClassName; + } + + + /** + * Set up the name of the Java class name to use to recreate the exception. + * + * @param exceptionClassName - String name of the fully-qualified java class name + */ + public void setExceptionClassName(String exceptionClassName) + { + this.exceptionClassName = exceptionClassName; + } + + + /** + * Return the error message associated with the exception. + * + * @return string error message + */ + public String getExceptionErrorMessage() + { + return exceptionErrorMessage; + } + + + /** + * Set up the error message associated with the exception. + * + * @param exceptionErrorMessage - string error message + */ + public void setExceptionErrorMessage(String exceptionErrorMessage) + { + this.exceptionErrorMessage = exceptionErrorMessage; + } + + + /** + * Return the description of the action taken by the system as a result of the exception. + * + * @return - string description of the action taken + */ + public String getExceptionSystemAction() + { + return exceptionSystemAction; + } + + + /** + * Set up the description of the action taken by the system as a result of the exception. + * + * @param exceptionSystemAction - string description of the action taken + */ + public void setExceptionSystemAction(String exceptionSystemAction) + { + this.exceptionSystemAction = exceptionSystemAction; + } + + + /** + * Return the action that a user should take to resolve the problem. + * + * @return string instructions + */ + public String getExceptionUserAction() + { + return exceptionUserAction; + } + + + /** + * Set up the action that a user should take to resolve the problem. + * + * @param exceptionUserAction - string instructions + */ + public void setExceptionUserAction(String exceptionUserAction) + { + this.exceptionUserAction = exceptionUserAction; + } + + + @Override + public String toString() + { + return "ConnectedAssetRESTServices{" + + "relatedHTTPCode=" + relatedHTTPCode + + ", exceptionClassName='" + exceptionClassName + '\'' + + ", exceptionErrorMessage='" + exceptionErrorMessage + '\'' + + ", exceptionSystemAction='" + exceptionSystemAction + '\'' + + ", exceptionUserAction='" + exceptionUserAction + '\'' + + '}'; + } +}
