Commit 68b47923 by Graham Wallis

ATLAS-2787; Removed redundant OM modules

parent fbb244c2
......@@ -136,7 +136,6 @@ atlas.graph.index.search.solr.wait-searcher=true
<descriptor>src/main/assemblies/standalone-package.xml</descriptor>
<descriptor>src/main/assemblies/src-package.xml</descriptor>
<descriptor>src/main/assemblies/migration-exporter.xml</descriptor>
<descriptor>src/main/assemblies/omag-server.xml</descriptor>
</descriptors>
<finalName>apache-atlas-${project.version}</finalName>
<tarLongFileMode>gnu</tarLongFileMode>
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<assembly xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<formats>
<format>tar.gz</format>
<format>dir</format>
</formats>
<id>omag-server</id>
<baseDirectory>omag-server-${project.version}</baseDirectory>
<fileSets>
<fileSet>
<directory>../omag-server/target</directory>
<outputDirectory>.</outputDirectory>
<includes>
<include>*.jar</include>
<include>*.sh</include>
</includes>
<fileMode>0755</fileMode>
<directoryMode>0755</directoryMode>
</fileSet>
<fileSet>
<directory>../omag-server</directory>
<outputDirectory>.</outputDirectory>
<includes>
<include>*.md</include>
</includes>
<fileMode>0755</fileMode>
<directoryMode>0755</directoryMode>
</fileSet>
</fileSets>
</assembly>
<!--
~ 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.
-->
# Open Connector Framework (OCF)
The OCF, as the name suggests, is an open framework for supporting connectors.
Connectors support access to remote assets such as data sets, APIs and software components.
OCF Connectors also provide access to metadata about the asset and they may call the Governance Action Framework
GAF to execute appropriate governance actions related to the use of these assets in real-time.
## Terminology
There are a number of key components within the OCF:
* **Connector** - this is a Java object for accessing an asset and its
related metadata and governance functions.
* **Connection** - this is a Java object containing the properties needed to
create a connector instance.
Connection properties are typically managed as metadata entities in the metadata
repository but they can also be manually populated.
Connections have 2 sub-objects:
* **ConnectorType** - this is a Java object that describes the type of
the connector, including the Java implementation class of its connector provider (see below).
* **Endpoint** - this is the Java object that describes the server endpoint where the asset is accessed from.
* **Connector Broker** - this is a generic factory for all OCF connectors.
* **Connector Provider** - this is a factory for a specific type of connector.
It is used by the Connector Broker.
* **Connected Asset** - this is the asset that the connector is accessing. It is hosted on a server
and the connector makes the remote calls necessary to retrieve, update, delete the asset itself.
The connector also includes an API to retrieve the metadata properties about the connected asset.
## Open Metadata Type Models
Model 0040 defines the structure of an Endpoint and
model 0201 defines the structures for Connections and Connector Types.
Model 0205 defines the linkage between the connection and the connected asset.
## Java Implementation
The OCF provides the interface schema and base class implementation for these components.
The Java implementation is located in packages org.apache.atlas.ocf.*:
* **org.apache.atlas.ocf** - Java interface and base classes for Connector and Connector Provider
plus the implementation of the Connector Broker.
* **org.apache.atlas.ocf.ffdc** - Implementation of the OCF's error codes and exceptions.
* **org.apache.atlas.ocf.properties** - Implementation of the properties for connections and connected assets.
These are simple POJO objects.
## Related Modules
The ConnectedAsset OMAS (omas-connectedasset) supports the retrieval
of connection and connected asset properties from the open metadata
repository/repositories.
The AssetConsumer OMAS (omas-assetconsumer) embeds the OCF to provide
client-side support for connectors.
The Open Metadata Repository Services (omrs) provides implementations
of OCF connectors for accessing open metadata repository servers.
These connectors are collectively called the OMRS Connectors.
## Wiki References
Further information on the OCF at: https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=69408729
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>apache-atlas</artifactId>
<groupId>org.apache.atlas</groupId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>om-fwk-ocf</artifactId>
<name>Open Connector Framework (OCF)</name>
<description>Open Connector Framework (OCF) interfaces and implementation for building metadata and governance enabled connectors.</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-base</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>${javax-inject.version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
/**
* 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.ocf;
import org.apache.atlas.ocf.ffdc.ConnectorCheckedException;
import org.apache.atlas.ocf.ffdc.PropertyServerException;
import org.apache.atlas.ocf.properties.ConnectedAssetProperties;
import org.apache.atlas.ocf.properties.Connection;
/**
* <p>
* The Connector is the interface for all connector instances. Connectors are client-side interfaces to assets
* such as data stores, data sets, APIs, analytical functions. They handle the communication with the server that
* hosts the assets, along with the communication with the metadata server to serve up metadata (properties) about
* the assets.
* </p>
* <p>
* Each connector implementation is paired with a connector provider. The connector provider is the factory for
* connector instances.
* </p>
* <p>
* The Connector interface defines that a connector instance should be able to return a unique
* identifier, a connection object and a metadata object called ConnectedAssetProperties.
* </p>
* <p>
* Each specific implementation of a connector then extends the Connector interface to add the methods to work with the
* particular type of asset it supports. For example, a JDBC connector would add the standard JDBC SQL interface, the
* OMRS Connectors add the metadata repository management APIs...
* </p>
* <p>
* The initialize() method is called by the Connector Provider to set up the connector instance Id and the
* Connection properties for the connector as part of its construction process.
* </p>
* <p>
* ConnectedAssetProperties provides descriptive properties about the asset that the connector is accessing.
* It is supplied to the connector later during its initialization through the initializeConnectedAssetProperties() method.
* See AssetConsumer OMAS for an example of this.
* </p>
* <p>
* Both the connector and the connector provider have base classes (ConnectorBase and
* ConnectorProviderBase respectively) that implement all of the standard methods. The connector developer extends
* these classes to add the specific methods to manage the asset and configure the base classes.
* </p>
*/
public abstract class Connector
{
/**
* Call made by the ConnectorProvider to initialize the Connector with the base services.
*
* @param connectorInstanceId - unique id for the connector instance - useful for messages etc
* @param connection - POJO for the configuration used to create the connector.
*/
public abstract void initialize(String connectorInstanceId,
Connection connection);
/**
* Returns the unique connector instance id that assigned to the connector instance when it was created.
* It is useful for error and audit messages.
*
* @return guid for the connector instance
*/
public abstract String getConnectorInstanceId();
/**
* Returns the connection object that was used to create the connector instance. Its contents are never refreshed
* during the lifetime of a connector instance even if the connection information is updated or removed from
* the originating metadata repository.
*
* @return connection object
*/
public abstract Connection getConnection();
/**
* Set up the connected asset properties object. This provides the known metadata properties stored in one or more
* metadata repositories. The implementation of the connected asset properties object is free to determine when
* the properties are populated. It may be as lazy as whenever getConnectedAssetProperties() is called.
*
* @param connectedAssetProperties - properties of the connected asset
*/
public abstract void initializeConnectedAssetProperties(ConnectedAssetProperties connectedAssetProperties);
/**
* Returns the properties that contain the metadata for the asset. The asset metadata is retrieved from the
* metadata repository and cached in the ConnectedAssetProperties object each time the getConnectedAssetProperties
* method is requested by the caller. Once the ConnectedAssetProperties object has the metadata cached, it can be
* used to access the asset property values many times without a return to the metadata repository.
* The cache of metadata can be refreshed simply by calling this getConnectedAssetProperties() method again.
*
* @return ConnectedAssetProperties - connected asset properties
* @throws PropertyServerException - indicates a problem retrieving properties from a metadata repository
*/
public abstract ConnectedAssetProperties getConnectedAssetProperties() throws PropertyServerException;
/**
* Indicates that the connector is completely configured and can begin processing.
*
* @throws ConnectorCheckedException - there is a problem within the connector.
*/
public abstract void start() throws ConnectorCheckedException;
/**
* Free up any resources held since the connector is no longer needed.
*
* @throws ConnectorCheckedException - there is a problem within the connector.
*/
public abstract void disconnect() throws ConnectorCheckedException;
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf;
import org.apache.atlas.ocf.ffdc.ConnectionCheckedException;
import org.apache.atlas.ocf.ffdc.ConnectorCheckedException;
import org.apache.atlas.ocf.properties.Connection;
/**
* The ConnectorProvider is a formal plug-in interface for the Open Connector Framework (OCF). It provides a factory
* class for a specific type of connector. Therefore is it typical to find the ConnectorProvider and Connector
* implementation written as a pair.
*
* The ConnectorProvider uses the properties stored in a Connection object to initialize itself and its Connector instances.
* the Connection object has the endpoint properties for the server that the connector must communicate with
* as well as optional additional properties that may be needed for a particular type of connector.
*
* It is suggested that the ConnectorProvider validates the contents of the connection and throws
* ConnectionErrorExceptions if the connection has missing or invalid properties. If there are errors detected in the
* instantiations or initialization of the connector, then these should be thrown as ConnectorErrorExceptions.
*/
public abstract class ConnectorProvider
{
/**
* Creates a new instance of a connector based on the information in the supplied connection.
*
* @param connection - connection that should have all of the properties needed by the Connector Provider
* to create a connector instance.
* @return Connector - instance of the connector.
* @throws ConnectionCheckedException - if there are missing or invalid properties in the connection
* @throws ConnectorCheckedException - if there are issues instantiating or initializing the connector
*/
public abstract Connector getConnector(Connection connection) throws ConnectionCheckedException, ConnectorCheckedException;
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.ffdc;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* ConnectionCheckedException provides a checked exception for reporting errors found in connection objects.
* Typically these errors are configuration errors that can be fixed by an administrator or power user.
* The connection object has a complex structure and the aim of this exception, in conjunction with
* OCFErrorCode, is to identify exactly what is wrong with the contents of the connection object
* and the consequences of this error.
*/
public class ConnectionCheckedException extends OCFCheckedExceptionBase
{
private static final Logger log = LoggerFactory.getLogger(ConnectionCheckedException.class);
/**
* This is the typical constructor for creating a ConnectionCheckedException. It captures the essential details
* about the error, where it occurred and how to fix it.
*
* @param httpCode code to use across a REST interface
* @param className name of class reporting error
* @param actionDescription description of function it was performing when error detected
* @param errorMessage description of error
* @param systemAction actions of the system as a result of the error
* @param userAction instructions for correcting the error
*/
public ConnectionCheckedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
if (log.isDebugEnabled())
{
log.debug(httpCode + ", " + className + ", " + actionDescription);
}
}
/**
* This constructor is used when an unexpected exception has been caught that needs to be wrapped in a
* ConnectionCheckedException in order to add the essential details about the error, where it occurred and
* how to fix it.
*
* @param httpCode code to use across a REST interface
* @param className name of class reporting error
* @param actionDescription description of function it was performing when error detected
* @param errorMessage description of error
* @param systemAction actions of the system as a result of the error
* @param userAction instructions for correcting the error
* @param caughtError the exception/error that caused this exception to be raised
*/
public ConnectionCheckedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
if (log.isDebugEnabled())
{
log.debug(httpCode + ", " + className + ", " + actionDescription + ", " + caughtError.toString());
}
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.ffdc;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* ConnectorCheckedException provides a checked exception for reporting errors found when using OCF connectors.
* Typically these errors are either configuration or operational errors that can be fixed by an administrator
* or power user. However, there may be the odd bug that surfaces here. The OCFErrorCode can be used with
* this exception to populate it with standard messages. Otherwise messages defined uniquely for a
* ConnectorProvider/Connector implementation can be used. The aim is to be able to uniquely identify the cause
* and remedy for the error.
*/
public class ConnectorCheckedException extends OCFCheckedExceptionBase
{
private static final Logger log = LoggerFactory.getLogger(ConnectorCheckedException.class);
/**
* This is the typical constructor used for creating a ConnectorCheckedException.
*
* @param httpCode http response code to use if this exception flows over a REST call
* @param className name of class reporting error
* @param actionDescription description of function it was performing when error detected
* @param errorMessage description of error
* @param systemAction actions of the system as a result of the error
* @param userAction instructions for correcting the error
*/
public ConnectorCheckedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
if (log.isDebugEnabled())
{
log.debug(httpCode + ", " + className + ", " + actionDescription);
}
}
/**
* This is the constructor used for creating a ConnectorCheckedException in response to a previous exception.
*
* @param httpCode http response code to use if this exception flows over a REST call
* @param className name of class reporting error
* @param actionDescription description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
* @param caughtError - the error that resulted in this exception.
*/
public ConnectorCheckedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
if (log.isDebugEnabled())
{
log.debug(httpCode + ", " + className + ", " + actionDescription + ", " + caughtError.toString());
}
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.ffdc;
import java.util.UUID;
/**
* OCFCheckedExceptionBase provides a checked exception for reporting errors found when using OCF connectors.
* Typically these errors are either configuration or operational errors that can be fixed by an administrator
* or power user. However, there may be the odd bug that surfaces here. The OCFErrorCode can be used with
* this exception to populate it with standard messages. Otherwise messages defined uniquely for a
* ConnectorProvider/Connector implementation can be used. The aim is to be able to uniquely identify the cause
* and remedy for the error.
*/
public class OCFCheckedExceptionBase extends Exception
{
private static final int hashCode = UUID.randomUUID().hashCode();
/*
* These default values are only seen if this exception is initialized using one of its superclass constructors.
*/
private int reportedHTTPCode = 500;
private String reportingClassName = "<Unknown>";
private String reportingActionDescription = "<Unknown>";
private String reportedErrorMessage = "<Unknown>";
private String reportedSystemAction = "<Unknown>";
private String reportedUserAction = "<Unknown>";
private Throwable reportedCaughtException = null;
/**
* This is the typical constructor used for creating an OCFCheckedException.
*
* @param httpCode - http response code to use if this exception flows over a REST call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
*/
public OCFCheckedExceptionBase(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
{
super(errorMessage);
this.reportedHTTPCode = httpCode;
this.reportingClassName = className;
this.reportingActionDescription = actionDescription;
this.reportedErrorMessage = errorMessage;
this.reportedSystemAction = systemAction;
this.reportedUserAction = userAction;
}
/**
* This is the constructor used for creating an OCFCheckedException when an unexpected error has been caught.
*
* @param httpCode - http response code to use if this exception flows over a REST call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
* @param caughtError - previous error causing this exception
*/
public OCFCheckedExceptionBase(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
{
super(errorMessage, caughtError);
this.reportedHTTPCode = httpCode;
this.reportingClassName = className;
this.reportingActionDescription = actionDescription;
this.reportedErrorMessage = errorMessage;
this.reportedSystemAction = systemAction;
this.reportedUserAction = userAction;
this.reportedCaughtException = caughtError;
}
/**
* Return the HTTP response code to use with this exception.
*
* @return reportedHTTPCode
*/
public int getReportedHTTPCode()
{
return reportedHTTPCode;
}
/**
* The class that created this exception.
*
* @return reportingClassName
*/
public String getReportingClassName()
{
return reportingClassName;
}
/**
* The type of request that the class was performing when the condition occurred that resulted in this
* exception.
*
* @return reportingActionDescription
*/
public String getReportingActionDescription()
{
return reportingActionDescription;
}
/**
* A formatted short description of the cause of the condition that resulted in this exception.
*
* @return reportedErrorMessage
*/
public String getErrorMessage()
{
return reportedErrorMessage;
}
/**
* A description of the action that the system took as a result of the error condition.
*
* @return reportedSystemAction
*/
public String getReportedSystemAction()
{
return reportedSystemAction;
}
/**
* A description of the action necessary to correct the error.
*
* @return reportedUserAction
*/
public String getReportedUserAction()
{
return reportedUserAction;
}
/**
* An exception that was caught and wrapped by this exception. If a null is returned, then this exception is
* newly created and not the result of a previous exception.
*
* @return reportedCaughtException
*/
public Throwable getReportedCaughtException() { return reportedCaughtException; }
/**
* Provide a common implementation of hashCode for all OCF properties objects. The UUID is unique and
* is randomly assigned and so its hashCode is as good as anything to describe the hash code of the properties
* object.
*/
public int hashCode()
{
return hashCode;
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.ffdc;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.UUID;
/**
* OCFRuntimeException is used for all runtime exceptions generated by the OCF. The OCFErrorCode provides
* first failure data capture information for this exception, although this information can also be provided
* using custom values.
*/
public class OCFRuntimeException extends RuntimeException
{
private static final int hashCode = UUID.randomUUID().hashCode();
/*
* These default values are only seen if this exception is initialized using one of its superclass constructors.
*/
private int reportedHTTPCode = 500;
private String reportingClassName = "<Unknown>";
private String reportingActionDescription = "<Unknown>";
private String reportedErrorMessage = "<Unknown>";
private String reportedSystemAction = "<Unknown>";
private String reportedUserAction = "<Unknown>";
private Throwable reportedCaughtException = null;
private static final Logger log = LoggerFactory.getLogger(OCFRuntimeException.class);
/**
* This is the typical constructor used for creating an OCFRuntimeException.
*
* @param httpCode - http response code to use if this exception flows over a REST call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
*/
public OCFRuntimeException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
{
super(errorMessage);
this.reportedHTTPCode = httpCode;
this.reportingClassName = className;
this.reportingActionDescription = actionDescription;
this.reportedErrorMessage = errorMessage;
this.reportedSystemAction = systemAction;
this.reportedUserAction = userAction;
if (log.isDebugEnabled())
{
log.debug(httpCode + ", " + className + ", " + actionDescription);
}
}
/**
* This is the constructor used for creating a OCFRuntimeException that results from a previous error/exception
* being thrown.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
* @param caughtError - previous error causing this exception
*/
public OCFRuntimeException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
{
super(errorMessage, caughtError);
this.reportedHTTPCode = httpCode;
this.reportingClassName = className;
this.reportingActionDescription = actionDescription;
this.reportedErrorMessage = errorMessage;
this.reportedSystemAction = systemAction;
this.reportedUserAction = userAction;
this.reportedCaughtException = caughtError;
if (log.isDebugEnabled())
{
log.debug(httpCode + ", " + className + ", " + actionDescription + ", " + caughtError.toString());
}
}
/**
* Return the HTTP response code to use with this exception.
*
* @return reportedHTTPCode
*/
public int getReportedHTTPCode()
{
return reportedHTTPCode;
}
/**
* The class that created this exception.
*
* @return reportingClassName
*/
public String getReportingClassName()
{
return reportingClassName;
}
/**
* The type of request that the class was performing when the condition occurred that resulted in this
* exception.
*
* @return reportingActionDescription
*/
public String getReportingActionDescription()
{
return reportingActionDescription;
}
/**
* A formatted short description of the cause of the condition that resulted in this exception.
*
* @return reportedErrorMessage
*/
public String getErrorMessage()
{
return reportedErrorMessage;
}
/**
* A description of the action that the system took as a result of the error condition.
*
* @return reportedSystemAction
*/
public String getReportedSystemAction()
{
return reportedSystemAction;
}
/**
* A description of the action necessary to correct the error.
*
* @return reportedUserAction
*/
public String getReportedUserAction()
{
return reportedUserAction;
}
/**
* An exception that was caught and wrapped by this exception. If a null is returned, then this exception is
* newly created and not the result of a previous exception.
*
* @return reportedCaughtException
*/
public Throwable getReportedCaughtException() { return reportedCaughtException; }
/**
* Provide a common implementation of hashCode for all OCF properties objects. The UUID is unique and
* is randomly assigned and so its hashCode is as good as anything to describe the hash code of the properties
* object.
*/
public int hashCode()
{
return hashCode;
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.ffdc;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* PropertyServerException provides a checked exception for reporting errors when connecting to a
* metadata repository to retrieve properties about the connected asset.
* It may be a configuration error or temporary outage. The parameters captured by the constructors
* pinpoint the type an cause of the error.
*/
public class PropertyServerException extends OCFCheckedExceptionBase
{
private static final Logger log = LoggerFactory.getLogger(PropertyServerException.class);
/**
* This is the typical constructor for creating a PropertyServerException. It captures the essential details
* about the error, where it occurred and how to fix it.
*
* @param httpCode - code to use on a REST interface
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
*/
public PropertyServerException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
if (log.isDebugEnabled())
{
log.debug(httpCode + ", " + className + ", " + actionDescription);
}
}
/**
* This constructor is used when an unexpected exception has been caught that needs to be wrapped in a
* PropertyServerException in order to add the essential details about the error, where it occurred and
* how to fix it.
*
* @param httpCode -- code to use on a REST interface
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
* @param caughtError - the exception/error that caused this exception to be raised
*/
public PropertyServerException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
if (log.isDebugEnabled())
{
log.debug(httpCode + ", " + className + ", " + actionDescription + ", " + caughtError.toString());
}
}
}
\ No newline at end of file
<!--
~ 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.
-->
# Open Connector Framework (OCF) FFDC
Package org.apache.atlas.ocf.ffdc provides the first failure data capture
(FFDC) support for the OCF module. This includes an error code enum,
a runtime exception, a base class for checked exceptions plus
implementation of each specific checked exception.
The error code enum (OCFErrorCode) has an entry for each unique situation
where an exception is returned. Each entry defines:
* A unique id for the error
* An HTTP error code for rest calls
* A unique message Id
* Message text with place holders for specific values
* A description of the cause of the error and system action as a result.
* A description of how to correct the error (if known)
Each exception (whether a checked or runtime exception) has two constructors.
* The first constructor is used when a new error has been detected.
* The second constructor is used when another exception has been caught.
This caught exception is passed on the constructor so it is effectively
embedded in the OCF exception.
Both constructors take the values from the OCFErrorCode
enum to define the cause and resolution. These values are passed
as individual parameters so that subclasses implemented outside of
the OCF packages can define their own FFDC values.
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
import java.util.*;
/**
* The AdditionalProperties class provides support for arbitrary properties to be added to a properties object.
* It wraps a java.util.Map map object built around HashMap.
*/
public class AdditionalProperties extends AssetPropertyBase
{
protected Map<String,Object> additionalProperties = new HashMap<>();
/**
* Constructor for a new set of additional properties that are not connected either directly or indirectly to an asset.
*
* @param additionalProperties - map of properties for the metadata element.
*/
public AdditionalProperties(Map<String,Object> additionalProperties)
{
this(null, additionalProperties);
}
/**
* Constructor for a new set of additional properties that are connected either directly or indirectly to an asset.
*
* @param parentAsset - description of the asset that these additional properties are attached to.
* @param additionalProperties - map of properties for the metadata element.
*/
public AdditionalProperties(AssetDescriptor parentAsset,
Map<String,Object> additionalProperties)
{
super(parentAsset);
if (additionalProperties != null)
{
this.additionalProperties = new HashMap<>(additionalProperties);
}
}
/**
* Copy/clone Constructor for additional properties that are connected to an asset.
*
* @param parentAsset - description of the asset that these additional properties are attached to.
* @param templateProperties - template object to copy.
*/
public AdditionalProperties(AssetDescriptor parentAsset, AdditionalProperties templateProperties)
{
super(parentAsset, templateProperties);
/*
* An empty properties object is created in the private variable declaration so nothing to do.
*/
if (templateProperties != null)
{
/*
* Process templateProperties if they are not null
*/
Iterator<String> propertyNames = templateProperties.getPropertyNames();
if (propertyNames != null)
{
while (propertyNames.hasNext())
{
String newPropertyName = propertyNames.next();
Object newPropertyValue = templateProperties.getProperty(newPropertyName);
additionalProperties.put(newPropertyName, newPropertyValue);
}
}
}
}
/**
* Returns a list of the additional stored properties for the element.
* If no stored properties are present then null is returned.
*
* @return list of additional properties
*/
public Iterator<String> getPropertyNames()
{
return additionalProperties.keySet().iterator();
}
/**
* Returns the requested additional stored property for the element.
* If no stored property with that name is present then null is returned.
*
* @param name - String name of the property to return.
* @return requested property value.
*/
public Object getProperty(String name)
{
return additionalProperties.get(name);
}
/**
* Test whether the supplied object is equal to this object.
*
* @param testObject - object to test
* @return boolean indicating if the supplied object represents the same content as this object.
*/
@Override
public boolean equals(Object testObject)
{
if (this == testObject)
{
return true;
}
if (testObject == null || getClass() != testObject.getClass())
{
return false;
}
AdditionalProperties that = (AdditionalProperties) testObject;
return additionalProperties != null ? additionalProperties.equals(that.additionalProperties) : that.additionalProperties == null;
}
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "AdditionalProperties{" +
"additionalProperties=" + additionalProperties +
'}';
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
import 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;
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;
}
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "AnnotationStatus{" +
"statusCode=" + statusCode +
", statusName='" + statusName + '\'' +
", statusDescription='" + statusDescription + '\'' +
'}';
}
}
\ No newline at end of file
/**
* 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.ocf.properties;
import java.util.Iterator;
/**
* Annotations supports an iterator over a list of annotations. Callers can use it to step through the list
* just once. If they want to parse the list again, they could use the copy/clone constructor to create
* a new iterator.
*/
public abstract class Annotations extends AssetPropertyIteratorBase implements Iterator<Annotation>
{
/**
* Typical Constructor creates an iterator with the supplied list of elements.
*
* @param parentAsset - descriptor of parent asset
* @param totalElementCount - the total number of elements to process. A negative value is converted to 0.
* @param maxCacheSize - maximum number of elements that should be retrieved from the property server and
* cached in the element list at any one time. If a number less than one is supplied, 1 is used.
*/
public Annotations(AssetDescriptor parentAsset,
int totalElementCount,
int maxCacheSize)
{
super(parentAsset, totalElementCount, maxCacheSize);
}
/**
* Copy/clone constructor. Used to reset iterator element pointer to 0;
*
* @param parentAsset - descriptor of parent asset
* @param template - type-specific iterator to copy; null to create an empty iterator
*/
public Annotations(AssetDescriptor parentAsset, Annotations template)
{
super(parentAsset, template);
}
/**
* Provides a concrete implementation of cloneElement for the specific iterator type.
*
* @param parentAsset - descriptor of parent asset
* @param template - object to clone
* @return new cloned object.
*/
protected AssetPropertyBase cloneElement(AssetDescriptor parentAsset, AssetPropertyBase template)
{
return new Annotation(parentAsset, (Annotation)template);
}
/**
* Clones this iterator.
*
* @param parentAsset - descriptor of parent asset
* @return new cloned object.
*/
protected abstract Annotations cloneIterator(AssetDescriptor parentAsset);
/**
* The iterator can only be used once to step through the elements. This method returns
* a boolean to indicate if it has got to the end of the list yet.
*
* @return boolean indicating whether there are more elements.
*/
@Override
public boolean hasNext()
{
return super.pagingIterator.hasNext();
}
/**
* Return the next element in the iteration.
*
* @return Annotation - next element object that has been cloned.
*/
@Override
public Annotation next()
{
return (Annotation)super.pagingIterator.next();
}
/**
* Remove the current element in the iterator. (Null implementation since this iterator works off of cached
* elements from the property (metadata) server.)
*/
@Override
public void remove()
{
super.pagingIterator.remove();
}
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "Annotations{" +
"pagingIterator=" + pagingIterator +
'}';
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
/**
* 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 asset in the
* metadata repository where this is known to enable properties to be retrieved on request.
*/
public abstract 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 url = null;
/*
* Unique id for the asset.
*/
private String guid = null;
/**
* Typical constructor - the asset descriptor is effectively empty - and the protected
* 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 url for the asset.
*
* @param guid - unique id for the asset
* @param url - URL for the asset in the metadata repository
*/
public AssetDescriptor(String guid, String url)
{
super();
this.guid = guid;
this.url = url;
}
/**
* 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.guid = templateAssetDescriptor.getGUID();
this.assetName = templateAssetDescriptor.getAssetName();
this.assetTypeName = templateAssetDescriptor.getAssetTypeName();
this.url = templateAssetDescriptor.getURL();
}
/**
* 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;
}
/**
* Return the unique id for this element.
*
* @return guid - unique id
*/
public String getGUID() {
return guid;
}
/**
* 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 asset in the metadata repository if supported.
*
* @return String - URL
*/
public String getURL() { return url; }
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "AssetDescriptor{" +
"assetName='" + assetName + '\'' +
", assetTypeName='" + assetTypeName + '\'' +
", url='" + url + '\'' +
", guid='" + guid + '\'' +
'}';
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
/**
* The AssetPropertyBase class is a base class for all properties that link off of the connected asset.
* It manages the information about the parent asset.
*/
public abstract class AssetPropertyBase extends PropertyBase
{
private AssetDescriptor parentAsset = null;
/**
* Typical constructor that sets the link to the connected asset to null
*
* @param parentAsset - descriptor of asset that his property relates to.
*/
protected AssetPropertyBase(AssetDescriptor parentAsset)
{
/*
* Initialize superclass and save the parent asset.
*/
super();
this.parentAsset = parentAsset;
}
/**
* Copy/clone constructor - sets up details of the parent asset from the template
*
* @param parentAsset - descriptor of asset that his property relates to.
* @param template - AssetPropertyBase to copy
*/
protected AssetPropertyBase(AssetDescriptor parentAsset, AssetPropertyBase template)
{
/*
* Initialize superclass and save the parentAsset
*/
super(template);
this.parentAsset = parentAsset;
}
/**
* Return the asset descriptor of the parent asset.
*
* @return AssetDescriptor
*/
protected AssetDescriptor getParentAsset() { return parentAsset; }
/**
* Return the name of the connected asset that this property is connected to.
*
* @return String name of the connected asset
*/
protected String getParentAssetName()
{
String parentAssetName = "<Unknown>";
if (parentAsset != null)
{
parentAssetName = parentAsset.getAssetName();
}
return parentAssetName;
}
/**
* Return the type of the connected asset that this property relates to.
*
* @return String name of the connected asset's type.
*/
protected String getParentAssetTypeName()
{
String parentAssetTypeName = "<Unknown>";
if (parentAsset != null)
{
parentAssetTypeName = parentAsset.getAssetTypeName();
}
return parentAssetTypeName;
}
/**
* An equals() method for subclasses to check they are connected to the same parent asset.
*
* @param testObject - object to test
* @return boolean indicating whether this object is connected to equivalent parent assets.
*/
@Override
public boolean equals(Object testObject)
{
if (this == testObject)
{
return true;
}
if (testObject == null || getClass() != testObject.getClass())
{
return false;
}
AssetPropertyBase that = (AssetPropertyBase) testObject;
return parentAsset != null ? parentAsset.equals(that.parentAsset) : that.parentAsset == null;
}
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "AssetPropertyBase{" +
"parentAsset=" + parentAsset +
'}';
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
import org.apache.atlas.ocf.ffdc.PropertyServerException;
import java.util.ArrayList;
public abstract class AssetPropertyIteratorBase extends AssetPropertyBase
{
protected PagingIterator pagingIterator = null;
/**
* Typical Constructor creates an iterator with the supplied list of comments.
*
* @param parentAsset - descriptor of parent asset
* @param totalElementCount - the total number of elements to process. A negative value is converted to 0.
* @param maxCacheSize - maximum number of elements that should be retrieved from the property server and
* cached in the element list at any one time. If a number less than one is supplied, 1 is used.
*/
protected AssetPropertyIteratorBase(AssetDescriptor parentAsset,
int totalElementCount,
int maxCacheSize)
{
/*
* Initialize superclass.
*/
super(parentAsset);
pagingIterator = new PagingIterator(parentAsset, this, totalElementCount, maxCacheSize);
}
/**
* Copy/clone constructor - sets up details of the parent asset from the template
*
* @param parentAsset - descriptor of asset that his property relates to.
* @param template - AssetPropertyBaseImpl to copy
*/
protected AssetPropertyIteratorBase(AssetDescriptor parentAsset, AssetPropertyIteratorBase template)
{
/*
* Initialize superclass.
*/
super(parentAsset, template);
if (template != null)
{
pagingIterator = new PagingIterator(parentAsset, this, template.pagingIterator);
}
}
/**
* Return the number of elements in the list.
*
* @return elementCount
*/
public int getElementCount()
{
if (pagingIterator == null)
{
return 0;
}
else
{
return pagingIterator.getElementCount();
}
}
/**
* Method implemented by a subclass that ensures the cloning process is a deep clone.
*
* @param parentAsset - descriptor of parent asset
* @param template - object to clone
* @return new cloned object.
*/
protected abstract AssetPropertyBase cloneElement(AssetDescriptor parentAsset, AssetPropertyBase template);
/**
* Method implemented by subclass to retrieve the next cached list of elements.
*
* @param cacheStartPointer - where to start the cache.
* @param maximumSize - maximum number of elements in the cache.
* @return list of elements corresponding to the supplied cache pointers.
* @throws PropertyServerException - there is a problem retrieving elements from the property (metadata) server.
*/
protected abstract ArrayList<AssetPropertyBase> getCachedList(int cacheStartPointer,
int maximumSize) throws PropertyServerException;
}
/**
* 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.ocf.properties;
/**
* AssetSummary 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>
*/
public class AssetSummary extends AssetDescriptor
{
private ElementType type = null;
private String qualifiedName = null;
private String displayName = null;
private String shortDescription = null;
private String description = null;
private String owner = null;
private Classifications classifications = null;
/**
* Typical constructor with parameters to fill properties.
*
* @param type - details of the metadata type for this asset
* @param guid - guid property
* @param url - element URL used to access its properties in the metadata repository.
* @param qualifiedName - unique name
* @param displayName - consumable name
* @param description - description of the asset
* @param shortDescription - short description from relationship with Connection
* @param owner - owner name
* @param classifications - enumeration of classifications
*/
public AssetSummary(ElementType type,
String guid,
String url,
String qualifiedName,
String displayName,
String shortDescription,
String description,
String owner,
Classifications classifications)
{
super(guid, url);
this.type = type;
if (type != null)
{
super.setAssetTypeName(type.getElementTypeName());
}
this.qualifiedName = qualifiedName;
this.displayName = displayName;
/*
* Use the qualified name as the asset name if it is not null or the empty string.
* Otherwise use display name (unless it is null or the empty string).
*/
if ((qualifiedName == null) || (qualifiedName.equals("")))
{
if ((displayName != null) && (!displayName.equals("")))
{
/*
* Good display name
*/
super.setAssetName(displayName);
}
}
else /* good qualified name */
{
super.setAssetName(qualifiedName);
}
this.shortDescription = shortDescription;
this.description = description;
this.owner = owner;
this.classifications = classifications;
}
/**
* 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();
qualifiedName = templateAssetSummary.getQualifiedName();
displayName = templateAssetSummary.getDisplayName();
shortDescription = templateAssetSummary.getShortDescription();
description = templateAssetSummary.getDescription();
owner = templateAssetSummary.getOwner();
Classifications templateClassifications = templateAssetSummary.getClassifications();
if (templateClassifications != null)
{
classifications = templateClassifications.cloneIterator(this);
}
}
}
/**
* 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;
}
/**
* 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;
}
/**
* 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;
}
/**
* Returns the short description of the asset from relationship with Connection.
*
* @return shortDescription String
*/
public String getShortDescription()
{
return shortDescription;
}
/**
* Returns the stored description property for the asset.
* If no description is provided then null is returned.
*
* @return description String
*/
public String getDescription()
{
return description;
}
/**
* Returns the name of the owner for this asset.
*
* @return owner String
*/
public String getOwner() {
return owner;
}
/**
* 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 - enumeration of classifications
*/
public Classifications getClassifications()
{
if (classifications == null)
{
return classifications;
}
else
{
return classifications.cloneIterator(this);
}
}
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "AssetSummary{" +
"type=" + type +
", qualifiedName='" + qualifiedName + '\'' +
", displayName='" + displayName + '\'' +
", shortDescription='" + shortDescription + '\'' +
", description='" + description + '\'' +
", owner='" + owner + '\'' +
", classifications=" + classifications +
'}';
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
import java.util.Iterator;
/**
* Certifications supports an iterator over a list of certifications awarded to the asset.
* Callers can use it to step through the list
* just once. If they want to parse the list again, they could use the copy/clone constructor to create
* a new iterator.
*/
public abstract class Certifications extends AssetPropertyIteratorBase implements Iterator<Certification>
{
/**
* Typical Constructor creates an iterator with the supplied list of elements.
*
* @param parentAsset - descriptor of parent asset
* @param totalElementCount - the total number of elements to process. A negative value is converted to 0.
* @param maxCacheSize - maximum number of elements that should be retrieved from the property server and
* cached in the element list at any one time. If a number less than one is supplied, 1 is used.
*/
public Certifications(AssetDescriptor parentAsset,
int totalElementCount,
int maxCacheSize)
{
super(parentAsset, totalElementCount, maxCacheSize);
}
/**
* Copy/clone constructor. Used to reset iterator element pointer to 0;
*
* @param parentAsset - descriptor of parent asset
* @param template - type-specific iterator to copy; null to create an empty iterator
*/
public Certifications(AssetDescriptor parentAsset, Certifications template)
{
super(parentAsset, template);
}
/**
* Provides a concrete implementation of cloneElement for the specific iterator type.
*
* @param parentAsset - descriptor of parent asset
* @param template - object to clone
* @return new cloned object.
*/
protected Certification cloneElement(AssetDescriptor parentAsset, AssetPropertyBase template)
{
return new Certification(parentAsset, (Certification)template);
}
/**
* Clones this iterator.
*
* @param parentAsset - descriptor of parent asset
* @return new cloned object.
*/
protected abstract Certifications cloneIterator(AssetDescriptor parentAsset);
/**
* The iterator can only be used once to step through the elements. This method returns
* a boolean to indicate if it has got to the end of the list yet.
*
* @return boolean indicating whether there are more elements.
*/
@Override
public boolean hasNext()
{
return super.pagingIterator.hasNext();
}
/**
* Return the next element in the iteration.
*
* @return Certification - next element object that has been cloned.
*/
@Override
public Certification next()
{
return (Certification)super.pagingIterator.next();
}
/**
* Remove the current element in the iterator. (Null implementation since this iterator works off of cached
* elements from the property (metadata) server.)
*/
@Override
public void remove()
{
super.pagingIterator.remove();
}
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "Certifications{" +
"pagingIterator=" + pagingIterator +
'}';
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
import org.apache.atlas.ocf.ffdc.OCFErrorCode;
import org.apache.atlas.ocf.ffdc.OCFRuntimeException;
/**
* 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.
*/
public class Classification extends AssetPropertyBase
{
private String classificationName = null;
private AdditionalProperties classificationProperties = null;
/**
* A private validation method used by the constructors.
*
* @param name - name to check
* @return validated name
*/
private String validateName(String name)
{
/*
* 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.
*/
OCFErrorCode errorCode = OCFErrorCode.NULL_CLASSIFICATION_NAME;
String errorMessage = errorCode.getErrorMessageId()
+ errorCode.getFormattedErrorMessage(super.getParentAssetName(),
super.getParentAssetTypeName());
throw new OCFRuntimeException(errorCode.getHTTPErrorCode(),
this.getClass().getName(),
"validateName",
errorMessage,
errorCode.getSystemAction(),
errorCode.getUserAction());
}
else
{
return name;
}
}
/**
* Typical constructor - verifies and saves parameters.
*
* @param parentAsset - name and type of related asset
* @param name - name of the classification
* @param properties - additional properties for the classification
*/
public Classification(AssetDescriptor parentAsset,
String name,
AdditionalProperties properties)
{
super(parentAsset);
this.classificationName = validateName(name);
this.classificationProperties = properties;
}
/**
* Copy/clone Constructor - sets up new classification using values from the template
*
* @param parentAsset - details of the asset that this classification is linked to.
* @param templateClassification - object to copy
*/
public Classification(AssetDescriptor parentAsset, Classification templateClassification)
{
super(parentAsset, templateClassification);
/*
* 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.
*/
OCFErrorCode errorCode = OCFErrorCode.NULL_CLASSIFICATION_NAME;
String errorMessage = errorCode.getErrorMessageId()
+ errorCode.getFormattedErrorMessage("<Unknown>");
throw new OCFRuntimeException(errorCode.getHTTPErrorCode(),
this.getClass().getName(),
"Copy Constructor",
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(super.getParentAsset(), classificationProperties);
}
}
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "Classification{" +
"classificationName='" + classificationName + '\'' +
", classificationProperties=" + classificationProperties +
'}';
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
import java.util.Iterator;
/**
* Classifications supports an iterator over a list of classifications. Callers can use it to step through the list
* just once. If they want to parse the list again, they could use the copy/clone constructor to create
* a new iterator.
*/
public abstract class Classifications extends AssetPropertyIteratorBase implements Iterator<Classification>
{
/**
* Typical Constructor creates an iterator with the supplied list of elements.
*
* @param parentAsset - descriptor of parent asset
* @param totalElementCount - the total number of elements to process. A negative value is converted to 0.
* @param maxCacheSize - maximum number of elements that should be retrieved from the property server and
* cached in the element list at any one time. If a number less than one is supplied, 1 is used.
*/
public Classifications(AssetDescriptor parentAsset,
int totalElementCount,
int maxCacheSize)
{
super(parentAsset, totalElementCount, maxCacheSize);
}
/**
* Copy/clone constructor. Used to reset iterator element pointer to 0;
*
* @param parentAsset - descriptor of parent asset
* @param template - type-specific iterator to copy; null to create an empty iterator
*/
public Classifications(AssetDescriptor parentAsset, Classifications template)
{
super(parentAsset, template);
}
/**
* Provides a concrete implementation of cloneElement for the specific iterator type.
*
* @param parentAsset - descriptor of parent asset
* @param template - object to clone
* @return new cloned object.
*/
protected AssetPropertyBase cloneElement(AssetDescriptor parentAsset, AssetPropertyBase template)
{
return new Classification(parentAsset, (Classification)template);
}
/**
* Clones this iterator.
*
* @param parentAsset - descriptor of parent asset
* @return new cloned object.
*/
protected abstract Classifications cloneIterator(AssetDescriptor parentAsset);
/**
* The iterator can only be used once to step through the elements. This method returns
* a boolean to indicate if it has got to the end of the list yet.
*
* @return boolean indicating whether there are more elements.
*/
@Override
public boolean hasNext()
{
return super.pagingIterator.hasNext();
}
/**
* Return the next element in the iteration.
*
* @return Classification - next element object that has been cloned.
*/
@Override
public Classification next()
{
return (Classification)super.pagingIterator.next();
}
/**
* Remove the current element in the iterator. (Null implementation since this iterator works off of cached
* elements from the property (metadata) server.)
*/
@Override
public void remove()
{
super.pagingIterator.remove();
}
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "Classifications{" +
"pagingIterator=" + pagingIterator +
'}';
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
/**
* Stores information about a 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.
*/
public class Comment extends ElementHeader
{
/*
* Attributes of a Comment
*/
private CommentType commentType = null;
private String commentText = null;
private String user = null;
private Comments commentReplies = null;
/**
* Typical Constructor
*
* @param parentAsset - descriptor for parent asset
* @param type - details of the metadata type for this properties object
* @param guid - String - unique id
* @param url - String - URL
* @param classifications - list of classifications
* @param commentType - enum describing the type of the comment
* @param commentText - comment text String
* @param user - String - user id of the person who created the comment. Null means the user id is not known.
* @param commentReplies - Nested list of comments replies
*/
public Comment(AssetDescriptor parentAsset,
ElementType type,
String guid,
String url,
Classifications classifications,
CommentType commentType,
String commentText,
String user,
Comments commentReplies)
{
super(parentAsset, type, guid, url, classifications);
this.commentType = commentType;
this.commentText = commentText;
this.user = user;
this.commentReplies = commentReplies;
}
/**
* Copy/clone constructor.
*
* @param parentAsset - descriptor for parent asset
* @param templateComment - element to copy
*/
public Comment(AssetDescriptor parentAsset, Comment templateComment)
{
/*
* Save the parent asset description.
*/
super(parentAsset, templateComment);
if (templateComment != null)
{
/*
* Copy the values from the supplied comment.
*/
commentType = templateComment.getCommentType();
user = templateComment.getUser();
commentText = templateComment.getCommentText();
Comments templateCommentReplies = templateComment.getCommentReplies();
if (templateCommentReplies != null)
{
/*
* Ensure comment replies has this object's parent asset, not the template's.
*/
commentReplies = templateCommentReplies.cloneIterator(parentAsset);
}
}
}
/**
* Return an enum that describes the type of comment.
*
* @return CommentType enum
*/
public CommentType getCommentType()
{
return commentType;
}
/**
* 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;
}
/**
* Return the comment text.
*
* @return String - commentText
*/
public String getCommentText()
{
return commentText;
}
/**
* Return an iterator of the replies to this comment - null means no replies are available.
*
* @return Comments - comment replies iterator
*/
public Comments getCommentReplies()
{
if (commentReplies == null)
{
return commentReplies;
}
else
{
return commentReplies.cloneIterator(super.getParentAsset());
}
}
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "Comment{" +
"commentText='" + commentText + '\'' +
", user='" + user + '\'' +
", commentReplies=" + commentReplies +
", type=" + type +
", guid='" + guid + '\'' +
", url='" + url + '\'' +
'}';
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
import 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;
}
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "CommentType{" +
"commentTypeCode=" + commentTypeCode +
", commentType='" + commentType + '\'' +
", commentTypeDescription='" + commentTypeDescription + '\'' +
'}';
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
import java.util.Iterator;
/**
* Comments supports an iterator over a list of Comment objects. Callers can use it to step through the list
* just once. If they want to parse the list again, they could use the copy/clone constructor to create
* a new iterator.
*/
public abstract class Comments extends AssetPropertyIteratorBase implements Iterator<Comment>
{
/**
* Typical Constructor creates an iterator with the supplied list of elements.
*
* @param parentAsset - descriptor of parent asset
* @param totalElementCount - the total number of elements to process. A negative value is converted to 0.
* @param maxCacheSize - maximum number of elements that should be retrieved from the property server and
* cached in the element list at any one time. If a number less than one is supplied, 1 is used.
*/
public Comments(AssetDescriptor parentAsset,
int totalElementCount,
int maxCacheSize)
{
super(parentAsset, totalElementCount, maxCacheSize);
}
/**
* Copy/clone constructor. Used to reset iterator element pointer to 0;
*
* @param parentAsset - descriptor of parent asset
* @param template - type-specific iterator to copy; null to create an empty iterator
*/
public Comments(AssetDescriptor parentAsset, Comments template)
{
super(parentAsset, template);
}
/**
* Provides a concrete implementation of cloneElement for the specific iterator type.
*
* @param parentAsset - descriptor of parent asset
* @param template - object to clone
* @return new cloned object.
*/
protected AssetPropertyBase cloneElement(AssetDescriptor parentAsset, AssetPropertyBase template)
{
return new Comment(parentAsset, (Comment)template);
}
/**
* Clones this iterator.
*
* @param parentAsset - descriptor of parent asset
* @return new cloned object.
*/
protected abstract Comments cloneIterator(AssetDescriptor parentAsset);
/**
* The iterator can only be used once to step through the elements. This method returns
* a boolean to indicate if it has got to the end of the list yet.
*
* @return boolean indicating whether there are more elements.
*/
@Override
public boolean hasNext()
{
return super.pagingIterator.hasNext();
}
/**
* Return the next element in the iteration.
*
* @return Comment - next element object that has been cloned.
*/
@Override
public Comment next()
{
return (Comment)super.pagingIterator.next();
}
/**
* Remove the current element in the iterator. (Null implementation since this iterator works off of cached
* elements from the property (metadata) server.)
*/
@Override
public void remove()
{
super.pagingIterator.remove();
}
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "Comments{" +
"pagingIterator=" + pagingIterator +
'}';
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
import org.apache.atlas.ocf.ffdc.PropertyServerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* ConnectedAssetProperties is associated with a Connector. Connectors provide access to
* assets. ConnectedAssetProperties returns properties (metadata) about the connector's asset.
*
* It is a generic interface for all types of open metadata assets. However, it assumes the asset's metadata model
* inherits from <b>Asset</b> (see model 0010 in Area 0).
*
* The ConnectedAssetProperties returns metadata about the asset at three levels of detail:
* <ul>
* <li><b>assetSummary</b> - used for displaying details of the asset in summary lists or hover text</li>
* <li><b>assetDetail</b> - used to display all of the information known about the asset with summaries
* of the relationships to other metadata entities</li>
* <li><b>assetUniverse</b> - used to define the broader context for the asset</li>
* </ul>
*
* ConnectedAssetProperties is a base class for the connector's metadata API that returns null,
* for the asset's properties. Metadata repository implementations extend this class to add their
* implementation of the refresh() method that calls to the metadata repository to populate the metadata properties.
*/
public abstract class ConnectedAssetProperties extends PropertyBase
{
/*
* AssetUniverse extends AssetDetails which extends AssetSummary. The interaction with the metadata repository
* pulls the asset universe in one single network interaction and the caller can then explore the metadata
* property by property without incurring many network interactions (unless there are too many instances
* of a particular type of property and one of the iterators is forced to use paging).
*
* If null is returned, the connector is not linked to a metadata repository.
*/
protected AssetUniverse assetProperties = null;
private static final Logger log = LoggerFactory.getLogger(ConnectedAssetProperties.class);
/**
* Typical constructor.
*/
public ConnectedAssetProperties()
{
/*
* Nothing to do except initialize superclass.
*/
super();
}
/**
* Copy/clone constructor.
*
* @param templateProperties - template to copy.
*/
public ConnectedAssetProperties(ConnectedAssetProperties templateProperties)
{
super(templateProperties);
if (templateProperties != null)
{
AssetUniverse templateAssetUniverse = templateProperties.getAssetUniverse();
if (templateAssetUniverse != null)
{
assetProperties = new AssetUniverse(templateAssetUniverse);
}
}
}
/**
* Returns the summary information organized in the assetSummary structure.
*
* @return AssetSummary - summary object
*/
public AssetSummary getAssetSummary() { return assetProperties; }
/**
* Returns detailed information about the asset organized in the assetDetail structure.
*
* @return AssetDetail - detail object
*/
public AssetDetail getAssetDetail() { return assetProperties; }
/**
* Returns all of the detail of the asset and information connected to it in organized in the assetUniverse
* structure.
*
* @return AssetUniverse - universe object
*/
public AssetUniverse getAssetUniverse() { return assetProperties; }
/**
* Request the values in the ConnectedAssetProperties are refreshed with the current values from the
* metadata repository.
*
* @throws PropertyServerException - there is a problem connecting to the server to retrieve metadata.
*/
public abstract void refresh() throws PropertyServerException;
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "ConnectedAssetProperties{" +
"assetProperties=" + assetProperties +
'}';
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
import java.util.Iterator;
/**
* Connections supports an iterator over a list of connections. Callers can use it to step through the list
* just once. If they want to parse the list again, they could use the copy/clone constructor to create
* a new iterator.
*/
public abstract class Connections extends AssetPropertyIteratorBase implements Iterator<Connection>
{
/**
* Typical Constructor creates an iterator with the supplied list of elements.
*
* @param parentAsset - descriptor of parent asset
* @param totalElementCount - the total number of elements to process. A negative value is converted to 0.
* @param maxCacheSize - maximum number of elements that should be retrieved from the property server and
* cached in the element list at any one time. If a number less than one is supplied, 1 is used.
*/
public Connections(AssetDescriptor parentAsset,
int totalElementCount,
int maxCacheSize)
{
super(parentAsset, totalElementCount, maxCacheSize);
}
/**
* Copy/clone constructor. Used to reset iterator element pointer to 0;
*
* @param parentAsset - descriptor of parent asset
* @param template - type-specific iterator to copy; null to create an empty iterator
*/
public Connections(AssetDescriptor parentAsset, Connections template)
{
super(parentAsset, template);
}
/**
* Provides a concrete implementation of cloneElement for the specific iterator type.
*
* @param parentAsset - descriptor of parent asset
* @param template - object to clone
* @return new cloned object.
*/
protected AssetPropertyBase cloneElement(AssetDescriptor parentAsset, AssetPropertyBase template)
{
return new Connection(parentAsset, (Connection)template);
}
/**
* Clones this iterator.
*
* @param parentAsset - descriptor of parent asset
* @return new cloned object.
*/
protected abstract Connections cloneIterator(AssetDescriptor parentAsset);
/**
* The iterator can only be used once to step through the elements. This method returns
* a boolean to indicate if it has got to the end of the list yet.
*
* @return boolean indicating whether there are more elements.
*/
@Override
public boolean hasNext()
{
return super.pagingIterator.hasNext();
}
/**
* Return the next element in the iteration.
*
* @return Connection - next element object that has been cloned.
*/
@Override
public Connection next()
{
return (Connection)super.pagingIterator.next();
}
/**
* Remove the current element in the iterator. (Null implementation since this iterator works off of cached
* elements from the property (metadata) server.)
*/
@Override
public void remove()
{
super.pagingIterator.remove();
}
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "Connections{" +
"pagingIterator=" + pagingIterator +
'}';
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
/**
* The ConnectorType describe the implementation details of a particular type of OCF connector.
* The properties for a connector type are defined in model 0201.
* They include:
*
* <ul>
* <li>
* guid - Globally unique identifier for the connector type.
* </li>
* <li>
* url - External link address for the connector type properties in the metadata repository. This URL can be
* stored as a property in another entity to create an explicit link to this connector type.
* </li>
* <li>
* qualifiedName - The official (unique) name for the connector type. This is often defined by the IT
* systems management organization and should be used (when available) on audit logs and error messages.
* </li>
* <li>
* displayName - A consumable name for the connector type. 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>
* <li>
* description - A full description of the connector type covering details of the assets it connects to
* along with usage and versioning information.
* </li>
* <li>
* connectorProviderClassName - The connector provider is the factory for a particular type of connector.
* This property defines the class name for the connector provider that the Connector Broker should use to request
* new connector instances.
* </li>
* <li>
* additionalProperties - Any additional properties that the connector provider needs to know in order to
* create connector instances.
* </li>
* </ul>
*
* The connectorTypeProperties class is simply used to cache the properties for an connector type.
* It is used by other classes to exchange this information between a metadata repository and a consumer.
*/
public class ConnectorType extends Referenceable
{
/*
* Attributes of a connector type
*/
protected String displayName = null;
protected String description = null;
protected String connectorProviderClassName = null;
/**
* Typical Constructor - used when Connector Type is used inside a connection object which is itself
* not yet connected to an asset. In this case the ParentAsset is null.
*
* @param type - details of the metadata type for this properties object
* @param guid - String - unique id
* @param url - String - URL
* @param classifications - enumeration of classifications
* @param qualifiedName - unique name
* @param additionalProperties - additional properties for the referenceable object.
* @param meanings - list of glossary terms (summary)
* @param displayName - consumable name property stored for the connector type.
* @param description - description property stored for the connector type.
* @param connectorProviderClassName - class name (including package name)
*/
public ConnectorType(ElementType type,
String guid,
String url,
Classifications classifications,
String qualifiedName,
AdditionalProperties additionalProperties,
Meanings meanings,
String displayName,
String description,
String connectorProviderClassName)
{
super(null, type, guid, url, classifications, qualifiedName, additionalProperties, meanings);
this.displayName = displayName;
this.description = description;
this.connectorProviderClassName = connectorProviderClassName;
}
/**
* Typical constructor for creating a connectorType linked to an asset.
*
* @param parentAsset - descriptor for parent asset
* @param type - details of the metadata type for this properties object
* @param guid - String - unique id
* @param url - String - URL
* @param classifications - enumeration of classifications
* @param qualifiedName - unique name
* @param additionalProperties - additional properties for the referenceable object.
* @param meanings - list of glossary terms (summary)
* @param displayName - consumable name property stored for the connector type.
* @param description - description property stored for the connector type.
* @param connectorProviderClassName - class name (including package name)
*/
public ConnectorType(AssetDescriptor parentAsset, ElementType type, String guid, String url, Classifications classifications, String qualifiedName, AdditionalProperties additionalProperties, Meanings meanings, String displayName, String description, String connectorProviderClassName)
{
super(parentAsset, type, guid, url, classifications, qualifiedName, additionalProperties, meanings);
this.displayName = displayName;
this.description = description;
this.connectorProviderClassName = connectorProviderClassName;
}
/**
* Copy/clone constructor for a connectorType that is not connected to an asset (either directly or indirectly).
*
* @param templateConnectorType - template object to copy.
*/
public ConnectorType(ConnectorType templateConnectorType)
{
this(null, templateConnectorType);
}
/**
* Copy/clone constructor for a connectorType that is connected to an asset (either directly or indirectly).
*
* @param parentAsset - description of the asset that this connector type is attached to.
* @param templateConnectorType - template object to copy.
*/
public ConnectorType(AssetDescriptor parentAsset, ConnectorType templateConnectorType)
{
/*
* Save parentAsset.
*/
super(parentAsset, templateConnectorType);
/*
* All properties are initialised as null so only change their default setting if the template is
* not null
*/
if (templateConnectorType != null)
{
displayName = templateConnectorType.getDisplayName();
description = templateConnectorType.getDescription();
connectorProviderClassName = templateConnectorType.getConnectorProviderClassName();
}
}
/**
* Returns the stored display name property for the connector type.
* If no display name is available then null is returned.
*
* @return displayName
*/
public String getDisplayName()
{
return displayName;
}
/**
* Returns the stored description property for the connector type.
* If no description is available then null is returned.
*
* @return description
*/
public String getDescription()
{
return description;
}
/**
* Returns the stored connectorProviderClassName property for the connector type.
* If no connectorProviderClassName is available then null is returned.
*
* @return connectorProviderClassName - class name (including package name)
*/
public String getConnectorProviderClassName()
{
return connectorProviderClassName;
}
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "ConnectorType{" +
"displayName='" + displayName + '\'' +
", description='" + description + '\'' +
", connectorProviderClassName='" + connectorProviderClassName + '\'' +
", qualifiedName='" + qualifiedName + '\'' +
", additionalProperties=" + additionalProperties +
", meanings=" + meanings +
", type=" + type +
", guid='" + guid + '\'' +
", url='" + url + '\'' +
'}';
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
/**
* Derived schema elements are used in views to define elements that are calculated using data from other sources.
* It contains a list of queries and a formula to combine the resulting values.
*/
public class DerivedSchemaElement extends PrimitiveSchemaElement
{
private String formula = null;
private SchemaImplementationQueries queries = null;
/**
* Typical constructor
*
* @param parentAsset - descriptor for parent asset
* @param type - details of the metadata type for this properties object
* @param guid - String - unique id
* @param url - String - URL
* @param classifications - enumeration of classifications
* @param qualifiedName - unique name
* @param additionalProperties - additional properties for the referenceable object.
* @param meanings - list of glossary terms (summary)
* @param versionNumber - the version number of the schema element - null means no version number.
* @param author - the name of the author of the schema element. Null means the author is unknown.
* @param usage - the usage guidance for this schema element. Null means no guidance available.
* @param encodingStandard - encoding standard used for this schema. It may be XML, JSON, SQL DDL or something else.
* Null means the encoding standard is unknown or there are many choices.
* @param dataType - the name of the data type for this element. Null means unknown data type.
* @param defaultValue - String containing default value for the element
* @param formula - the formula used to combine the values of the queries. Each query is numbers 0, 1, ... and the
* formula has placeholders in it to show how the query results are combined.
* @param queries - list of queries that are used to create the derived schema element.
*/
public DerivedSchemaElement(AssetDescriptor parentAsset,
ElementType type,
String guid,
String url,
Classifications classifications,
String qualifiedName,
AdditionalProperties additionalProperties,
Meanings meanings,
String versionNumber,
String author,
String usage,
String encodingStandard,
String dataType,
String defaultValue,
String formula,
SchemaImplementationQueries queries)
{
super(parentAsset,
type,
guid,
url,
classifications,
qualifiedName,
additionalProperties,
meanings,
versionNumber,
author,
usage,
encodingStandard,
dataType,
defaultValue);
this.formula = formula;
this.queries = queries;
}
/**
* Copy/clone Constructor - the parentAsset is passed separately to the template because it is also
* likely to be being cloned in the same operation and we want the definitions clone to point to the
* asset clone and not the original asset.
*
* @param parentAsset - description of the asset that this schema element is attached to.
* @param templateSchemaElement - template object to copy.
*/
public DerivedSchemaElement(AssetDescriptor parentAsset, DerivedSchemaElement templateSchemaElement)
{
super(parentAsset, templateSchemaElement);
if (templateSchemaElement != null)
{
SchemaImplementationQueries templateQueries = templateSchemaElement.getQueries();
formula = templateSchemaElement.getFormula();
queries = templateQueries.cloneIterator(super.getParentAsset());
}
}
/**
* Return the formula used to combine the values of the queries. Each query is numbers 0, 1, ... and the
* formula has placeholders in it to show how the query results are combined.
*
* @return String formula
*/
public String getFormula() { return formula; }
/**
* Return the list of queries that are used to create the derived schema element.
*
* @return SchemaImplementationQueries - list of queries
*/
public SchemaImplementationQueries getQueries()
{
if (queries == null)
{
return queries;
}
else
{
return queries.cloneIterator(super.getParentAsset());
}
}
/**
* Returns a clone of this object as the abstract SchemaElement class.
*
* @param parentAsset - description of the asset that this schema element is attached to.
* @return PrimitiveSchemaElement object
*/
@Override
public SchemaElement cloneSchemaElement(AssetDescriptor parentAsset)
{
return new DerivedSchemaElement(parentAsset, this);
}
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "DerivedSchemaElement{" +
"formula='" + formula + '\'' +
", queries=" + queries +
", qualifiedName='" + qualifiedName + '\'' +
", additionalProperties=" + additionalProperties +
", meanings=" + meanings +
", type=" + type +
", guid='" + guid + '\'' +
", url='" + url + '\'' +
'}';
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
/**
* ElementHeader provides the common identifier and type information for all properties objects
* that link off of the asset and have a guid associated with them. This typically means it is
* represented by an entity in the metadata repository.
*/
public abstract class ElementHeader extends AssetPropertyBase
{
/*
* Common header for first class elements from a metadata repository
*/
protected ElementType type = null;
protected String guid = null;
protected String url = null;
/*
* Attached classifications
*/
protected Classifications classifications = null;
/**
* Typical Constructor
*
* @param parentAsset - descriptor for parent asset
* @param type - details of the metadata type for this properties object
* @param guid - String - unique id
* @param url - String - URL
* @param classifications - enumeration of classifications
*/
public ElementHeader(AssetDescriptor parentAsset,
ElementType type,
String guid,
String url,
Classifications classifications)
{
super(parentAsset);
this.type = type;
this.guid = guid;
this.url = url;
this.classifications = classifications;
}
/**
* Copy/clone constructor.
*
* @param parentAsset - descriptor for parent asset
* @param templateHeader - element to copy
*/
public ElementHeader(AssetDescriptor parentAsset, ElementHeader templateHeader)
{
/*
* Save the parent asset description.
*/
super(parentAsset, templateHeader);
if (templateHeader != null)
{
/*
* Copy the values from the supplied parameters.
*/
type = templateHeader.getType();
guid = templateHeader.getGUID();
url = templateHeader.getURL();
Classifications templateClassifications = templateHeader.getClassifications();
if (templateClassifications != null)
{
classifications = templateClassifications.cloneIterator(parentAsset);
}
}
}
/**
* Return the element type properties for this properties object. 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;
}
/**
* Return the unique id for the properties object. Null means no guid is assigned.
*
* @return String - unique id
*/
public String getGUID() {
return guid;
}
/**
* Returns the URL to access the properties object in the metadata repository.
* If no url is available then null is returned.
*
* @return String - URL
*/
public String getURL() {
return url;
}
/**
* 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 - enumeration of classifications
*/
public Classifications getClassifications()
{
if (classifications == null)
{
return classifications;
}
else
{
return classifications.cloneIterator(super.getParentAsset());
}
}
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "ElementHeader{" +
"type=" + type +
", guid='" + guid + '\'' +
", url='" + url + '\'' +
", classifications=" + classifications +
'}';
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
import 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;
/**
* ElementOrigin defines where the metadata comes from and, hence if it can be updated.
* <ul>
* <li>
* LOCAL_COHORT - the element is being maintained within the local cohort.
* The metadata collection id is for one of the repositories in the cohort.
* This metadata collection id identifies the home repository for this element.
* </li>
* <li>
* EXPORT_ARCHIVE - the element was created from an export archive.
* The metadata collection id for the element is the metadata collection id of the originating server.
* If the originating server later joins the cohort with the same metadata collection id then these
* elements will be refreshed from the originating server’s current repository.
* </li>
* <li>
* CONTENT_PACK - the element comes from an open metadata content pack.
* The metadata collection id of the elements is set to the GUID of the pack.
* </li>
* <li>
* DEREGISTERED_REPOSITORY - the element comes from a metadata repository that used to be a part
* of the repository cohort but has been deregistered. The metadata collection id remains the same.
* If the repository rejoins the cohort then these elements can be refreshed from the rejoining repository.
* </li>
* </ul>
*/
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
public enum ElementOrigin implements Serializable
{
LOCAL_COHORT(0, "Local to cohort", "The element is being maintained within one of the local cohort members. " +
"The metadata collection id is for one of the repositories in the cohort. " +
"This metadata collection id identifies the home repository for this element. "),
EXPORT_ARCHIVE(1, "Export Archive", "The element was created from an export archive. " +
"The metadata collection id for the element is the metadata collection id of the originating server. " +
"If the originating server later joins the cohort with the same metadata collection Id " +
"then these elements will be refreshed from the originating server’s current repository."),
CONTENT_PACK(2, "Content Pack", "The element comes from an open metadata content pack. " +
"The metadata collection id of the elements is set to the GUID of the pack."),
DEREGISTERED_REPOSITORY(3, "Deregistered Repository", "The element comes from a metadata repository that " +
"used to be a member of the one of the local repository's cohorts but it has been deregistered. " +
"The metadata collection id remains the same. If the repository rejoins the cohort " +
"then these elements can be refreshed from the rejoining repository."),
CONFIGURATION(4, "Configuration",
"The element is part of a service's configuration. The metadata collection id is null.");
private static final long serialVersionUID = 1L;
private int originCode;
private String originName;
private String originDescription;
/**
* Constructor for the enum.
*
* @param originCode - code number for origin
* @param originName - name for origin
* @param originDescription - description for origin
*/
ElementOrigin(int originCode, String originName, String originDescription)
{
this.originCode = originCode;
this.originName = originName;
this.originDescription = originDescription;
}
/**
* Return the code for metadata element.
*
* @return int code for the origin
*/
public int getOriginCode()
{
return originCode;
}
/**
* Return the name of the metadata element origin.
*
* @return String name
*/
public String getOriginName()
{
return originName;
}
/**
* Return the description of the metadata element origin.
*
* @return String description
*/
public String getOriginDescription()
{
return originDescription;
}
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "ElementOrigin{" +
"originCode=" + originCode +
", originName='" + originName + '\'' +
", originDescription='" + originDescription + '\'' +
'}';
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
/**
* The ElementType provide details of the type information associated with the element. Most consumers
* of the properties do not need this information. It is provided to asset consumers primarily as diagnostic
* information.
*/
public class ElementType extends PropertyBase
{
protected String elementTypeId = null;
protected String elementTypeName = null;
protected long elementTypeVersion = 0;
protected String elementTypeDescription = null;
protected String elementSourceServer = null;
protected ElementOrigin elementOrigin = null;
protected String elementHomeMetadataCollectionId = null;
/**
* Typical Constructor
*
* @param elementTypeId - identifier for the element's type
* @param elementTypeName - element type name
* @param elementTypeVersion - version number for the element type
* @param elementTypeDescription - description of element type
* @param elementSourceServer - url of the OMAS server
* @param elementOrigin - enum describing type of origin
* @param elementHomeMetadataCollectionId - metadata collection id
*/
public ElementType(String elementTypeId,
String elementTypeName,
long elementTypeVersion,
String elementTypeDescription,
String elementSourceServer,
ElementOrigin elementOrigin,
String elementHomeMetadataCollectionId)
{
super();
this.elementTypeId = elementTypeId;
this.elementTypeName = elementTypeName;
this.elementTypeVersion = elementTypeVersion;
this.elementTypeDescription = elementTypeDescription;
this.elementSourceServer = elementSourceServer;
this.elementOrigin = elementOrigin;
this.elementHomeMetadataCollectionId = elementHomeMetadataCollectionId;
}
/**
* Copy/clone constructor
*
* @param templateType - type to clone
*/
public ElementType(ElementType templateType)
{
super(templateType);
if (templateType != null)
{
/*
* Copy the properties from the supplied template
*/
this.elementTypeId = templateType.getElementTypeId();
this.elementTypeName = templateType.getElementTypeName();
this.elementTypeVersion = templateType.getElementTypeVersion();
this.elementTypeDescription = templateType.getElementTypeDescription();
this.elementSourceServer = templateType.getElementSourceServer();
this.elementOrigin = templateType.getElementOrigin();
this.elementHomeMetadataCollectionId = templateType.getElementHomeMetadataCollectionId();
}
}
/**
* Return unique identifier for the element's type.
*
* @return element type id
*/
public String getElementTypeId()
{
return elementTypeId;
}
/**
* Return name of element's type.
*
* @return - elementTypeName
*/
public String getElementTypeName()
{
return elementTypeName;
}
/**
* Return the version number for this element's type.
*
* @return elementTypeVersion - version number for the element type.
*/
public long getElementTypeVersion()
{
return elementTypeVersion;
}
/**
* Return the description for this element's type.
*
* @return elementTypeDescription - String description for the element type
*/
public String getElementTypeDescription()
{
return elementTypeDescription;
}
/**
* Return the URL of the server where the element was retrieved from. Typically this is
* a server where the OMAS interfaces are activated. If no URL is known for the server then null is returned.
*
* @return elementSourceServerURL - the url of the server where the element came from
*/
public String getElementSourceServer()
{
return elementSourceServer;
}
/**
* Return the origin of the metadata element.
*
* @return ElementOrigin enum
*/
public ElementOrigin getElementOrigin() { return elementOrigin; }
/**
* Returns the OMRS identifier for the metadata collection that is managed by the repository
* where the element originates (its home repository).
*
* @return String metadata collection id
*/
public String getElementHomeMetadataCollectionId()
{
return elementHomeMetadataCollectionId;
}
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "ElementType{" +
"elementTypeId='" + elementTypeId + '\'' +
", elementTypeName='" + elementTypeName + '\'' +
", elementTypeVersion=" + elementTypeVersion +
", elementTypeDescription='" + elementTypeDescription + '\'' +
", elementSourceServer='" + elementSourceServer + '\'' +
", elementOrigin=" + elementOrigin +
", elementHomeMetadataCollectionId='" + elementHomeMetadataCollectionId + '\'' +
'}';
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
/**
* The EmbeddedConnection is used within a VirtualConnection. It contains a connection and additional properties
* the VirtualConnection uses when working with the EmbeddedConnection.
*/
public class EmbeddedConnection extends AssetPropertyBase
{
/*
* Attributes of an embedded connection
*/
private AdditionalProperties embeddedConnectionProperties = null;
private Connection embeddedConnection = null;
/**
* Typical Constructor
*
* @param parentAsset - descriptor for parent asset
* @param embeddedConnectionProperties - Additional properties
* @param embeddedConnection - Connection
*/
public EmbeddedConnection(AssetDescriptor parentAsset,
AdditionalProperties embeddedConnectionProperties,
Connection embeddedConnection)
{
super(parentAsset);
this.embeddedConnectionProperties = embeddedConnectionProperties;
this.embeddedConnection = embeddedConnection;
}
/**
* Copy/clone constructor.
*
* @param parentAsset - descriptor for parent asset
* @param templateEmbeddedConnection - element to copy
*/
public EmbeddedConnection(AssetDescriptor parentAsset, EmbeddedConnection templateEmbeddedConnection)
{
/*
* Save the parent asset description.
*/
super(parentAsset, templateEmbeddedConnection);
if (templateEmbeddedConnection != null)
{
AdditionalProperties templateConnectionProperties = templateEmbeddedConnection.getEmbeddedConnectionProperties();
Connection templateConnection = templateEmbeddedConnection.getEmbeddedConnection();
if (templateConnectionProperties != null)
{
embeddedConnectionProperties = new AdditionalProperties(parentAsset, templateConnectionProperties);
}
if (templateConnection != null)
{
embeddedConnection = new Connection(parentAsset, templateConnection);
}
}
}
/**
* Return the properties for the embedded connection.
*
* @return AdditionalProperties
*/
public AdditionalProperties getEmbeddedConnectionProperties()
{
if (embeddedConnectionProperties == null)
{
return embeddedConnectionProperties;
}
else
{
return new AdditionalProperties(this.getParentAsset(), embeddedConnectionProperties);
}
}
/**
* Return the embedded connection.
*
* @return Connection object.
*/
public Connection getEmbeddedConnection()
{
if (embeddedConnection == null)
{
return embeddedConnection;
}
else
{
return new Connection(this.getParentAsset(), embeddedConnection);
}
}
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "EmbeddedConnection{" +
"embeddedConnectionProperties=" + embeddedConnectionProperties +
", embeddedConnection=" + embeddedConnection +
'}';
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
import java.util.Iterator;
/**
* EmbeddedConnections supports an iterator over a list of connections that are embedded in a virtual connection.
* Callers can use it to step through the list just once. If they want to parse the list again,
* they could use the copy/clone constructor to create a new iterator.
*/
public abstract class EmbeddedConnections extends AssetPropertyIteratorBase implements Iterator<EmbeddedConnection>
{
/**
* Typical Constructor creates an iterator with the supplied list of elements.
*
* @param parentAsset - descriptor of parent asset
* @param totalElementCount - the total number of elements to process. A negative value is converted to 0.
* @param maxCacheSize - maximum number of elements that should be retrieved from the property server and
* cached in the element list at any one time. If a number less than one is supplied, 1 is used.
*/
public EmbeddedConnections(AssetDescriptor parentAsset,
int totalElementCount,
int maxCacheSize)
{
super(parentAsset, totalElementCount, maxCacheSize);
}
/**
* Copy/clone constructor. Used to reset iterator element pointer to 0;
*
* @param parentAsset - descriptor of parent asset
* @param template - type-specific iterator to copy; null to create an empty iterator
*/
public EmbeddedConnections(AssetDescriptor parentAsset, EmbeddedConnections template)
{
super(parentAsset, template);
}
/**
* Provides a concrete implementation of cloneElement for the specific iterator type.
*
* @param parentAsset - descriptor of parent asset
* @param template - object to clone
* @return new cloned object.
*/
protected AssetPropertyBase cloneElement(AssetDescriptor parentAsset, AssetPropertyBase template)
{
return new EmbeddedConnection(parentAsset, (EmbeddedConnection)template);
}
/**
* Clones this iterator.
*
* @param parentAsset - descriptor of parent asset
* @return new cloned object.
*/
protected abstract EmbeddedConnections cloneIterator(AssetDescriptor parentAsset);
/**
* The iterator can only be used once to step through the elements. This method returns
* a boolean to indicate if it has got to the end of the list yet.
*
* @return boolean indicating whether there are more elements.
*/
@Override
public boolean hasNext()
{
return super.pagingIterator.hasNext();
}
/**
* Return the next element in the iteration.
*
* @return EmbeddedConnection - next element object that has been cloned.
*/
@Override
public EmbeddedConnection next()
{
return (EmbeddedConnection)super.pagingIterator.next();
}
/**
* Remove the current element in the iterator. (Null implementation since this iterator works off of cached
* elements from the property (metadata) server.)
*/
@Override
public void remove()
{
super.pagingIterator.remove();
}
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "EmbeddedConnections{" +
"pagingIterator=" + pagingIterator +
'}';
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
/**
* ExternalIdentifier stores information about an identifier for the asset that is used in an external system.
* This is used for correlating information about the asset across different systems.
*/
public class ExternalIdentifier extends Referenceable
{
/*
* Attributes of an external identifier
*/
private String identifier = null;
private String description = null;
private String usage = null;
private String source = null;
private KeyPattern keyPattern = null;
private Referenceable scope = null;
private String scopeDescription = null;
/**
* Typical Constructor
*
* @param parentAsset - descriptor for parent asset
* @param type - details of the metadata type for this properties object
* @param guid - String - unique id
* @param url - String - URL
* @param classifications - enumeration of classifications
* @param qualifiedName - unique name
* @param additionalProperties - additional properties for the referenceable object.
* @param meanings - list of glossary terms (summary)
* @param identifier - the external identifier for the asset.
* @param description - the description of the external identifier.
* @param usage - usage guidance for this external identifier.
* @param source - source description for this external identifier.
* @param keyPattern enum - name of the key pattern used for this external identifier.
* @param scope - Referenceable scope of this external identifier. This depends on the key pattern.
* It may be a server definition, a reference data set or glossary term.
* @param scopeDescription - description of the scope for this external identifier.
*/
public ExternalIdentifier(AssetDescriptor parentAsset,
ElementType type,
String guid,
String url,
Classifications classifications,
String qualifiedName,
AdditionalProperties additionalProperties,
Meanings meanings,
String identifier,
String description,
String usage,
String source,
KeyPattern keyPattern,
Referenceable scope,
String scopeDescription)
{
super(parentAsset, type, guid, url, classifications, qualifiedName, additionalProperties, meanings);
this.identifier = identifier;
this.description = description;
this.usage = usage;
this.source = source;
this.keyPattern = keyPattern;
this.scope = scope;
this.scopeDescription = scopeDescription;
}
/**
* Copy/clone constructor.
*
* @param parentAsset - descriptor for parent asset
* @param templateExternalIdentifier - element to copy
*/
public ExternalIdentifier(AssetDescriptor parentAsset, ExternalIdentifier templateExternalIdentifier)
{
/*
* Initialize the super class.
*/
super(parentAsset, templateExternalIdentifier);
if (templateExternalIdentifier != null)
{
/*
* Copy the values from the supplied template.
*/
identifier = templateExternalIdentifier.getIdentifier();
description = templateExternalIdentifier.getDescription();
usage = templateExternalIdentifier.getUsage();
source = templateExternalIdentifier.getSource();
keyPattern = templateExternalIdentifier.getKeyPattern();
Referenceable templateScope = templateExternalIdentifier.getScope();
if (templateScope != null)
{
/*
* Ensure comment replies has this object's parent asset, not the template's.
*/
scope = new Referenceable(parentAsset, templateScope);
}
scopeDescription = templateExternalIdentifier.getScopeDescription();
}
}
/**
* Return the external identifier for this asset.
*
* @return String identifier
*/
public String getIdentifier() { return identifier; }
/**
* Return the description of the external identifier.
*
* @return String description
*/
public String getDescription() { return description; }
/**
* Return details of how, where and when this external identifier is used.
*
* @return String usage
*/
public String getUsage() { return usage; }
/**
* Return details of the source system where this external identifier comes from.
*
* @return String server
*/
public String getSource() { return source; }
/**
* Return the key pattern that is used with this external identifier.
*
* @return KeyPattern enum
*/
public KeyPattern getKeyPattern() { return keyPattern; }
/**
* Return the scope of this external identifier. This depends on the key pattern. It may be a server definition,
* a reference data set or glossary term.
*
* @return Referenceable scope
*/
public Referenceable getScope()
{
if (scope == null)
{
return scope;
}
else
{
return new Referenceable(super.getParentAsset(), scope);
}
}
/**
* Return the text description of the scope for this external identifier.
*
* @return String scope description
*/
public String getScopeDescription() { return scopeDescription; }
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "ExternalIdentifier{" +
"identifier='" + identifier + '\'' +
", description='" + description + '\'' +
", usage='" + usage + '\'' +
", source='" + source + '\'' +
", keyPattern=" + keyPattern +
", scope=" + scope +
", scopeDescription='" + scopeDescription + '\'' +
", qualifiedName='" + qualifiedName + '\'' +
", additionalProperties=" + additionalProperties +
", meanings=" + meanings +
", type=" + type +
", guid='" + guid + '\'' +
", url='" + url + '\'' +
'}';
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
import java.util.Iterator;
/**
* ExternalIdentifiers supports an iterator over a list of external identifiers. Callers can use it to step through
* the list just once. If they want to parse the list again, they could use the copy/clone constructor to create
* a new iterator.
*/
public abstract class ExternalIdentifiers extends AssetPropertyIteratorBase implements Iterator<ExternalIdentifier>
{
/**
* Typical Constructor creates an iterator with the supplied list of elements.
*
* @param parentAsset - descriptor of parent asset
* @param totalElementCount - the total number of elements to process. A negative value is converted to 0.
* @param maxCacheSize - maximum number of elements that should be retrieved from the property server and
* cached in the element list at any one time. If a number less than one is supplied, 1 is used.
*/
public ExternalIdentifiers(AssetDescriptor parentAsset,
int totalElementCount,
int maxCacheSize)
{
super(parentAsset, totalElementCount, maxCacheSize);
}
/**
* Copy/clone constructor. Used to reset iterator element pointer to 0;
*
* @param parentAsset - descriptor of parent asset
* @param template - type-specific iterator to copy; null to create an empty iterator
*/
public ExternalIdentifiers(AssetDescriptor parentAsset, ExternalIdentifiers template)
{
super(parentAsset, template);
}
/**
* Provides a concrete implementation of cloneElement for the specific iterator type.
*
* @param parentAsset - descriptor of parent asset
* @param template - object to clone
* @return new cloned object.
*/
protected AssetPropertyBase cloneElement(AssetDescriptor parentAsset, AssetPropertyBase template)
{
return new ExternalIdentifier(parentAsset, (ExternalIdentifier)template);
}
/**
* Clones this iterator.
*
* @param parentAsset - descriptor of parent asset
* @return new cloned object.
*/
protected abstract ExternalIdentifiers cloneIterator(AssetDescriptor parentAsset);
/**
* The iterator can only be used once to step through the elements. This method returns
* a boolean to indicate if it has got to the end of the list yet.
*
* @return boolean indicating whether there are more elements.
*/
@Override
public boolean hasNext()
{
return super.pagingIterator.hasNext();
}
/**
* Return the next element in the iteration.
*
* @return ExternalIdentifier - next element object that has been cloned.
*/
@Override
public ExternalIdentifier next()
{
return (ExternalIdentifier)super.pagingIterator.next();
}
/**
* Remove the current element in the iterator. (Null implementation since this iterator works off of cached
* elements from the property (metadata) server.)
*/
@Override
public void remove()
{
super.pagingIterator.remove();
}
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "ExternalIdentifiers{" +
"pagingIterator=" + pagingIterator +
'}';
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.ocf.properties;
/**
* ExternalReference stores information about an link to an external resource that is relevant to this asset.
*/
public class ExternalReference extends Referenceable
{
/*
* Attributes of an external reference
*/
private String referenceId = null;
private String linkDescription = null;
private String displayName = null;
private String uri = null;
private String resourceDescription = null;
private String version = null;
private String organization = null;
/**
* Typical Constructor
*
* @param parentAsset - descriptor for parent asset
* @param type - details of the metadata type for this properties object
* @param guid - String - unique id
* @param url - String - URL
* @param classifications - enumeration of classifications
* @param qualifiedName - unique name
* @param additionalProperties - additional properties for the referenceable object.
* @param meanings - list of glossary terms (summary)
* @param referenceId the reference identifier for this asset's reference.
* @param linkDescription - description of the reference (with respect to this asset).
* @param displayName - display name for this external reference.
* @param uri - the URI used to retrieve the resource that this external reference represents.
* @param resourceDescription - the description of the resource that this external reference represents.
* @param version - the version of the resource that this external reference represents.
* @param organization - the name of the organization that owns the resource that this external reference represents.
*/
public ExternalReference(AssetDescriptor parentAsset,
ElementType type,
String guid,
String url,
Classifications classifications,
String qualifiedName,
AdditionalProperties additionalProperties,
Meanings meanings,
String referenceId,
String linkDescription,
String displayName,
String uri,
String resourceDescription,
String version,
String organization)
{
super(parentAsset, type, guid, url, classifications, qualifiedName, additionalProperties, meanings);
this.referenceId = referenceId;
this.linkDescription = linkDescription;
this.displayName = displayName;
this.uri = uri;
this.resourceDescription = resourceDescription;
this.version = version;
this.organization = organization;
}
/**
* Copy/clone constructor.
*
* @param parentAsset - descriptor for parent asset
* @param templateExternalReference - element to copy
*/
public ExternalReference(AssetDescriptor parentAsset, ExternalReference templateExternalReference)
{
/*
* Initialize the super class.
*/
super(parentAsset, templateExternalReference);
if (templateExternalReference != null)
{
/*
* Copy the values from the supplied template.
*/
referenceId = templateExternalReference.getReferenceId();
linkDescription = templateExternalReference.getLinkDescription();
displayName = templateExternalReference.getDisplayName();
uri = templateExternalReference.getURI();
resourceDescription = templateExternalReference.getResourceDescription();
version = templateExternalReference.getVersion();
organization = templateExternalReference.getOrganization();
}
}
/**
* Return the identifier given to this reference (with respect to this asset).
*
* @return String referenceId
*/
public String getReferenceId() { return referenceId; }
/**
* Return the description of the reference (with respect to this asset).
*
* @return String link description.
*/
public String getLinkDescription() { return linkDescription; }
/**
* Return the display name of this external reference.
*
* @return String display name.
*/
public String getDisplayName() { return displayName; }
/**
* Return the URI used to retrieve the resource that this external reference represents.
*
* @return String URI
*/
public String getURI() { return uri; }
/**
* Return the description of the resource that this external reference represents.
*
* @return String resource description
*/
public String getResourceDescription() { return resourceDescription; }
/**
* Return the version of the resource that this external reference represents.
*
* @return String version
*/
public String getVersion() { return version; }
/**
* Return the name of the organization that owns the resource that this external reference represents.
*
* @return String organization name
*/
public String getOrganization() { return organization; }
/**
* Standard toString method.
*
* @return print out of variables in a JSON-style
*/
@Override
public String toString()
{
return "ExternalReference{" +
"referenceId='" + referenceId + '\'' +
", linkDescription='" + linkDescription + '\'' +
", displayName='" + displayName + '\'' +
", uri='" + uri + '\'' +
", resourceDescription='" + resourceDescription + '\'' +
", version='" + version + '\'' +
", organization='" + organization + '\'' +
", qualifiedName='" + qualifiedName + '\'' +
", additionalProperties=" + additionalProperties +
", meanings=" + meanings +
", type=" + type +
", guid='" + guid + '\'' +
", url='" + url + '\'' +
'}';
}
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment