You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2018/05/25 20:08:19 UTC
[26/51] [partial] atlas git commit: ATLAS-2722: moved unused code
from branch-1.0
http://git-wip-us.apache.org/repos/asf/atlas/blob/b0ecc36a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/OMRSArchiveHelper.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/OMRSArchiveHelper.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/OMRSArchiveHelper.java
deleted file mode 100644
index 7994b08..0000000
--- a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/OMRSArchiveHelper.java
+++ /dev/null
@@ -1,619 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * <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.omrs.archivemanager;
-
-import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceStatus;
-import org.apache.atlas.omrs.metadatacollection.properties.typedefs.*;
-
-import java.util.ArrayList;
-import java.util.Date;
-
-/**
- * OMRSArchiveHelper provides utility methods to help in the construction of open metadata archives.
- */
-public class OMRSArchiveHelper
-{
- private OMRSArchiveBuilder archiveBuilder;
- private String archiveGUID;
- private String originatorName;
- private Date creationDate;
- private long versionNumber;
- private String versionName;
-
-
- /**
- * Constructor receives information about the archive being built.
- *
- * @param archiveBuilder - archive builder with the archive contents in it.
- * @param archiveGUID - unique identifier for the archive.
- * @param originatorName - name of the person / process creating the archive.
- * @param creationDate - date that the archive was first built.
- * @param versionNumber - version number of the archive.
- * @param versionName - version name for the archive.
- */
- public OMRSArchiveHelper(OMRSArchiveBuilder archiveBuilder,
- String archiveGUID,
- String originatorName,
- Date creationDate,
- long versionNumber,
- String versionName)
- {
- this.archiveBuilder = archiveBuilder;
- this.archiveGUID = archiveGUID;
- this.originatorName = originatorName;
- this.creationDate = creationDate;
- this.versionNumber = versionNumber;
- this.versionName = versionName;
- }
-
-
- /**
- * Set up an individual primitive definition
- *
- * @param primitiveDefCategory - category of the primitive def defines the unique
- * information about this primitive type.
- * @return initialized PrimitiveDef object ready for the archive
- */
- public PrimitiveDef getPrimitiveDef(PrimitiveDefCategory primitiveDefCategory)
- {
- PrimitiveDef primitiveDef = new PrimitiveDef(primitiveDefCategory);
-
- primitiveDef.setGUID(primitiveDefCategory.getGUID());
- primitiveDef.setName(primitiveDefCategory.getName());
- primitiveDef.setVersion(versionNumber);
- primitiveDef.setVersionName(versionName);
-
- return primitiveDef;
- }
-
-
- /**
- * Create a CollectionDef for an Array. A new CollectionDef is required for each combination of primitive types
- * used to initialize the collection. Each CollectionDef has its own unique identifier (guid) and
- * its name is a combination of the collection type and the primitives use to initialize it.
- *
- * @param guid - unique identifier for the CollectionDef
- * @param description - short default description of the enum type
- * @param descriptionGUID - guid of the glossary term describing this collection type
- * @param arrayType - type of the array.
- * @return Filled out CollectionDef
- */
- public CollectionDef getArrayCollectionDef(String guid,
- String description,
- String descriptionGUID,
- PrimitiveDefCategory arrayType)
- {
- CollectionDef collectionDef = new CollectionDef(CollectionDefCategory.OM_COLLECTION_ARRAY);
-
- collectionDef.setGUID(guid);
- collectionDef.setName("array<" + arrayType.getName() + ">");
- collectionDef.setDescription(description);
- collectionDef.setDescriptionGUID(descriptionGUID);
-
- ArrayList<PrimitiveDefCategory> argumentList = new ArrayList<>();
- argumentList.add(arrayType);
- collectionDef.setArgumentTypes(argumentList);
-
- return collectionDef;
- }
-
-
- /**
- * Create a CollectionDef for a map. A new CollectionDef is required for each combination of primitive types
- * used to initialize the collection. Each CollectionDef has its own unique identifier (guid) and
- * its name is a combination of the collection type and the primitives use to initialize it.
- *
- * @param guid - unique identifier for the CollectionDef
- * @param description - short default description of the enum type
- * @param descriptionGUID - guid of the glossary term describing this collection type
- * @param propertyKeyType - type of the key for the map.
- * @param propertyValueType - type of map value.
- * @return Filled out CollectionDef
- */
- public CollectionDef getMapCollectionDef(String guid,
- String description,
- String descriptionGUID,
- PrimitiveDefCategory propertyKeyType,
- PrimitiveDefCategory propertyValueType)
- {
- CollectionDef collectionDef = new CollectionDef(CollectionDefCategory.OM_COLLECTION_MAP);
-
- collectionDef.setGUID(guid);
- collectionDef.setName("map<" + propertyKeyType.getName() + "," + propertyValueType.getName() + ">");
- collectionDef.setDescription(description);
- collectionDef.setDescriptionGUID(descriptionGUID);
- collectionDef.setVersion(versionNumber);
- collectionDef.setVersionName(versionName);
-
- ArrayList<PrimitiveDefCategory> argumentList = new ArrayList<>();
- argumentList.add(propertyKeyType);
- argumentList.add(propertyValueType);
- collectionDef.setArgumentTypes(argumentList);
-
- return collectionDef;
- }
-
-
- /**
- * Create an EnumDef that has no valid values defined. These are added by the caller.
- *
- * @param guid - unique identifier for the CollectionDef
- * @param name - unique name for the CollectionDef
- * @param description - short default description of the enum type
- * @param descriptionGUID - guid of the glossary term describing this enum type
- * @return basic EnumDef without valid values
- */
- public EnumDef getEmptyEnumDef(String guid,
- String name,
- String description,
- String descriptionGUID)
- {
- EnumDef enumDef = new EnumDef();
-
- enumDef.setGUID(guid);
- enumDef.setName(name);
- enumDef.setDescription(description);
- enumDef.setDescriptionGUID(descriptionGUID);
- enumDef.setDefaultValue(null);
- enumDef.setVersion(versionNumber);
- enumDef.setVersionName(versionName);
-
- return enumDef;
- }
-
-
- /**
- * Create an EnumElementDef that carries one of the valid values for an Enum.
- *
- * @param ordinal - code number
- * @param value - name
- * @param description - short description
- * @param descriptionGUID - guid of the glossary term describing this enum element
- * @return Fully filled out EnumElementDef
- */
- public EnumElementDef getEnumElementDef(int ordinal,
- String value,
- String description,
- String descriptionGUID)
- {
- EnumElementDef enumElementDef = new EnumElementDef();
-
- enumElementDef.setOrdinal(ordinal);
- enumElementDef.setValue(value);
- enumElementDef.setDescription(description);
- enumElementDef.setDescriptionGUID(descriptionGUID);
-
- return enumElementDef;
- }
-
-
- /**
- * Sets up a default EntityDef. Calling methods can override the default values. This EntityDef
- * has no attribute defined.
- *
- * @param guid - unique identifier for the entity
- * @param name - name of the entity
- * @param superType - Super type for this entity (null for top-level)
- * @param description - short description of the entity
- * @param descriptionGUID - guid of the glossary term describing this entity type
- * @return Initialized EntityDef
- */
- public EntityDef getDefaultEntityDef(String guid,
- String name,
- TypeDefLink superType,
- String description,
- String descriptionGUID)
- {
- EntityDef entityDef = new EntityDef();
-
- /*
- * Set up the parameters supplied by the caller.
- */
- entityDef.setGUID(guid);
- entityDef.setName(name);
- entityDef.setSuperType(superType);
- entityDef.setDescription(description);
- entityDef.setDescriptionGUID(descriptionGUID);
-
- /*
- * Set up the defaults
- */
- entityDef.setOrigin(archiveGUID);
- entityDef.setCreatedBy(originatorName);
- entityDef.setCreateTime(creationDate);
- entityDef.setVersion(versionNumber);
- entityDef.setVersionName(versionName);
-
- /*
- * Set default valid instance statuses
- */
- ArrayList<InstanceStatus> validInstanceStatusList = new ArrayList<>();
- validInstanceStatusList.add(InstanceStatus.ACTIVE);
- validInstanceStatusList.add(InstanceStatus.DELETED);
- entityDef.setValidInstanceStatusList(validInstanceStatusList);
-
- return entityDef;
- }
-
-
- /**
- * Return an attribute with the supplied name and description that is of type String. It is set up to be optional,
- * indexable (useful for searches) but the value does not need to be unique.
- * These are the typical values used for most open metadata attribute.
- * They can be changed by the caller once the TypeDefAttribute is returned.
- *
- * @param attributeName - name of the attribute
- * @param attributeDescription - short description for the attribute
- * @param attributeDescriptionGUID - guid of the glossary term that describes this attribute.
- * @return TypeDefAttribute of type string
- */
- public TypeDefAttribute getStringTypeDefAttribute(String attributeName,
- String attributeDescription,
- String attributeDescriptionGUID)
- {
- TypeDefAttribute attribute = new TypeDefAttribute();
-
- attribute.setAttributeName(attributeName);
- attribute.setAttributeDescription(attributeDescription);
- attribute.setAttributeDescriptionGUID(attributeDescriptionGUID);
- attribute.setAttributeType(this.archiveBuilder.getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING.getName()));
- attribute.setAttributeCardinality(AttributeCardinality.AT_MOST_ONE);
- attribute.setValuesMinCount(0);
- attribute.setValuesMaxCount(1);
- attribute.setIndexable(true);
- attribute.setUnique(false);
- attribute.setDefaultValue(null);
- attribute.setExternalStandardMappings(null);
-
- return attribute;
- }
-
-
- /**
- * Return an attribute with the supplied name and description that is of type int. It is set up to be optional,
- * indexable (useful for searches) but the value does not need to be unique.
- * These are the typical values used for most open metadata attribute.
- * They can be changed by the caller once the TypeDefAttribute is returned.
- *
- * @param attributeName - name of the attribute
- * @param attributeDescription - short description for the attribute
- * @param attributeDescriptionGUID - guid of the glossary term that describes this attribute.
- * @return TypeDefAttribute of type string
- */
- public TypeDefAttribute getIntTypeDefAttribute(String attributeName,
- String attributeDescription,
- String attributeDescriptionGUID)
- {
- TypeDefAttribute attribute = new TypeDefAttribute();
-
- attribute.setAttributeName(attributeName);
- attribute.setAttributeDescription(attributeDescription);
- attribute.setAttributeDescriptionGUID(attributeDescriptionGUID);
- attribute.setAttributeType(this.archiveBuilder.getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_INT.getName()));
- attribute.setAttributeCardinality(AttributeCardinality.AT_MOST_ONE);
- attribute.setValuesMinCount(0);
- attribute.setValuesMaxCount(1);
- attribute.setIndexable(true);
- attribute.setUnique(false);
- attribute.setDefaultValue(null);
- attribute.setExternalStandardMappings(null);
-
- return attribute;
- }
-
-
- /**
- * Return an attribute with the supplied name and description that is of type date. It is set up to be optional,
- * indexable (useful for searches) but the value does not need to be unique.
- * These are the typical values used for most open metadata attribute.
- * They can be changed by the caller once the TypeDefAttribute is returned.
- *
- * @param attributeName - name of the attribute
- * @param attributeDescription - short description for the attribute
- * @param attributeDescriptionGUID - guid of the glossary term that describes this attribute.
- * @return TypeDefAttribute of type string
- */
- public TypeDefAttribute getDateTypeDefAttribute(String attributeName,
- String attributeDescription,
- String attributeDescriptionGUID)
- {
- TypeDefAttribute attribute = new TypeDefAttribute();
-
- attribute.setAttributeName(attributeName);
- attribute.setAttributeDescription(attributeDescription);
- attribute.setAttributeDescriptionGUID(attributeDescriptionGUID);
- attribute.setAttributeType(this.archiveBuilder.getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_DATE.getName()));
- attribute.setAttributeCardinality(AttributeCardinality.AT_MOST_ONE);
- attribute.setValuesMinCount(0);
- attribute.setValuesMaxCount(1);
- attribute.setIndexable(true);
- attribute.setUnique(false);
- attribute.setDefaultValue(null);
- attribute.setExternalStandardMappings(null);
-
- return attribute;
- }
-
-
- /**
- * Return an attribute with the supplied name and description that is an array of strings.
- * It is set up to be optional,
- * indexable (useful for searches) but the value does not need to be unique.
- * These are the typical values used for most open metadata attribute.
- * They can be changed by the caller once the TypeDefAttribute is returned.
- *
- * @param attributeName - name of the attribute
- * @param attributeDescription - short description for the attribute
- * @param attributeDescriptionGUID - guid of the glossary term that describes this attribute.
- * @return TypeDefAttribute of type string
- */
- public TypeDefAttribute getArrayStringTypeDefAttribute(String attributeName,
- String attributeDescription,
- String attributeDescriptionGUID)
- {
- TypeDefAttribute attribute = new TypeDefAttribute();
-
- attribute.setAttributeName(attributeName);
- attribute.setAttributeDescription(attributeDescription);
- attribute.setAttributeDescriptionGUID(attributeDescriptionGUID);
- attribute.setAttributeType(this.archiveBuilder.getCollectionDef("array<string>"));
- attribute.setAttributeCardinality(AttributeCardinality.AT_MOST_ONE);
- attribute.setValuesMinCount(0);
- attribute.setValuesMaxCount(1);
- attribute.setIndexable(true);
- attribute.setUnique(false);
- attribute.setDefaultValue(null);
- attribute.setExternalStandardMappings(null);
-
- return attribute;
- }
-
-
- /**
- * Return an attribute with the supplied name and description that is of a map from string to string.
- * It is set up to be optional,
- * indexable (useful for searches) but the value does not need to be unique.
- * These are the typical values used for most open metadata attribute.
- * They can be changed by the caller once the TypeDefAttribute is returned.
- *
- * @param attributeName - name of the attribute
- * @param attributeDescription - short description for the attribute
- * @param attributeDescriptionGUID - guid of the glossary term that describes this attribute.
- * @return TypeDefAttribute of type string
- */
- public TypeDefAttribute getMapStringStringTypeDefAttribute(String attributeName,
- String attributeDescription,
- String attributeDescriptionGUID)
- {
- TypeDefAttribute attribute = new TypeDefAttribute();
-
- attribute.setAttributeName(attributeName);
- attribute.setAttributeDescription(attributeDescription);
- attribute.setAttributeDescriptionGUID(attributeDescriptionGUID);
- attribute.setAttributeType(this.archiveBuilder.getCollectionDef("map<string,string>"));
- attribute.setAttributeCardinality(AttributeCardinality.AT_MOST_ONE);
- attribute.setValuesMinCount(0);
- attribute.setValuesMaxCount(1);
- attribute.setIndexable(true);
- attribute.setUnique(false);
- attribute.setDefaultValue(null);
- attribute.setExternalStandardMappings(null);
-
- return attribute;
- }
-
-
- /**
- * Return an attribute with the supplied name, type and description. It is set up to be optional,
- * indexable (useful for searches) but the value does not need to be unique.
- * These are the typical values used for most open metadata attribute.
- * They can be changed by the caller once the TypeDefAttribute is returned.
- *
- * @param enumTypeName - name of the enum type for this attribute
- * @param attributeName - name of the attribute
- * @param attributeDescription - short description for the attribute
- * @param attributeDescriptionGUID - guid of the glossary term that describes this attribute.
- * @return TypeDefAttribute of type string
- */
- public TypeDefAttribute getEnumTypeDefAttribute(String enumTypeName,
- String attributeName,
- String attributeDescription,
- String attributeDescriptionGUID)
- {
- TypeDefAttribute attribute = new TypeDefAttribute();
-
- attribute.setAttributeName(attributeName);
- attribute.setAttributeDescription(attributeDescription);
- attribute.setAttributeDescriptionGUID(attributeDescriptionGUID);
- attribute.setAttributeType(this.archiveBuilder.getEnumDef(enumTypeName));
- attribute.setAttributeCardinality(AttributeCardinality.AT_MOST_ONE);
- attribute.setValuesMinCount(0);
- attribute.setValuesMaxCount(1);
- attribute.setIndexable(true);
- attribute.setUnique(false);
- attribute.setDefaultValue(null);
- attribute.setExternalStandardMappings(null);
-
- return attribute;
- }
-
-
- /**
- * Returns a basic RelationshipDef without any attributes or ends set up.
- * The caller is responsible for adding the attributes and ends definition.
- *
- * @param guid - unique identifier for the relationship
- * @param name - name of the relationship
- * @param superType - Super type for this relationship (null for top-level)
- * @param description - short default description of the relationship
- * @param descriptionGUID - guid of the glossary term that describes this relationship
- * @param relationshipCategory - is this an association, aggregation or composition?
- * @param propagationRule - should classifications propagate over this relationship?
- * @return RelationshipDef with no ends defined.
- */
- public RelationshipDef getBasicRelationshipDef(String guid,
- String name,
- TypeDefLink superType,
- String description,
- String descriptionGUID,
- RelationshipCategory relationshipCategory,
- ClassificationPropagationRule propagationRule)
- {
- RelationshipDef relationshipDef = new RelationshipDef();
-
- /*
- * Set up the parameters supplied by the caller.
- */
- relationshipDef.setGUID(guid);
- relationshipDef.setName(name);
- relationshipDef.setSuperType(superType);
- relationshipDef.setDescription(description);
- relationshipDef.setDescriptionGUID(descriptionGUID);
-
- /*
- * Set up the defaults
- */
- relationshipDef.setOrigin(archiveGUID);
- relationshipDef.setCreatedBy(originatorName);
- relationshipDef.setCreateTime(creationDate);
- relationshipDef.setVersion(versionNumber);
- relationshipDef.setVersionName(versionName);
-
- /*
- * Set default valid instance statuses
- */
- ArrayList<InstanceStatus> validInstanceStatusList = new ArrayList<>();
- validInstanceStatusList.add(InstanceStatus.ACTIVE);
- validInstanceStatusList.add(InstanceStatus.DELETED);
- relationshipDef.setValidInstanceStatusList(validInstanceStatusList);
-
- /*
- * Set up the category of relationship
- */
- relationshipDef.setRelationshipCategory(relationshipCategory);
-
- if ((relationshipCategory == RelationshipCategory.AGGREGATION) ||
- (relationshipCategory == RelationshipCategory.COMPOSITION))
- {
- /*
- * By convention, end 1 is the container end in the open metadata model.
- */
- relationshipDef.setRelationshipContainerEnd(RelationshipContainerEnd.END1);
- }
- else
- {
- relationshipDef.setRelationshipContainerEnd(RelationshipContainerEnd.NOT_APPLICABLE);
- }
-
- /*
- * Use the supplied propagation rule.
- */
- relationshipDef.setPropagationRule(propagationRule);
-
- return relationshipDef;
- }
-
-
- /**
- * Returns a RelationshipEndDef object that sets up details of an entity at one end of a relationship.
- *
- * @param entityType - details of the type of entity connected to this end.
- * @param attributeName - name of the attribute that the entity at the other end uses to refer to this entity.
- * @param attributeDescription - description of this attribute
- * @param attributeDescriptionGUID - unique identifier of the glossary term describing this attribute.
- * @param attributeCardinality - cardinality of this end of the relationship.
- * @return the definition of one end of a Relationship.
- */
- public RelationshipEndDef getRelationshipEndDef(TypeDefLink entityType,
- String attributeName,
- String attributeDescription,
- String attributeDescriptionGUID,
- AttributeCardinality attributeCardinality)
- {
- RelationshipEndDef relationshipEndDef = new RelationshipEndDef();
-
- relationshipEndDef.setEntityType(entityType);
- relationshipEndDef.setAttributeName(attributeName);
- relationshipEndDef.setAttributeDescription(attributeDescription);
- relationshipEndDef.setAttributeDescriptionGUID(attributeDescriptionGUID);
- relationshipEndDef.setAttributeCardinality(attributeCardinality);
-
- return relationshipEndDef;
- }
-
-
- /**
- * Returns a basic ClassificationDef without any attributes. The caller is responsible for adding the
- * attribute definitions.
- *
- * @param guid - unique identifier for the classification
- * @param name - name of the classification
- * @param superType - Super type for this classification (null for top-level)
- * @param description - short description of the classification
- * @param descriptionGUID - unique identifier of the glossary term that describes this classification.
- * @param validEntityDef - which entities can this classification be linked to.
- * @param propagatable - can the classification propagate over relationships?
- * @return ClassificationDef with no attributes defined.
- */
- public ClassificationDef getClassificationDef(String guid,
- String name,
- TypeDefLink superType,
- String description,
- String descriptionGUID,
- TypeDefLink validEntityDef,
- boolean propagatable)
- {
- ClassificationDef classificationDef = new ClassificationDef();
-
- /*
- * Set up the parameters supplied by the caller.
- */
- classificationDef.setGUID(guid);
- classificationDef.setName(name);
- classificationDef.setSuperType(superType);
- classificationDef.setDescription(description);
- classificationDef.setDescriptionGUID(descriptionGUID);
-
- /*
- * Set up the defaults
- */
- classificationDef.setOrigin(archiveGUID);
- classificationDef.setCreatedBy(originatorName);
- classificationDef.setCreateTime(creationDate);
- classificationDef.setVersion(versionNumber);
- classificationDef.setVersionName(versionName);
-
- /*
- * Set default valid instance statuses
- */
- ArrayList<InstanceStatus> validInstanceStatusList = new ArrayList<>();
- validInstanceStatusList.add(InstanceStatus.ACTIVE);
- validInstanceStatusList.add(InstanceStatus.DELETED);
- classificationDef.setValidInstanceStatusList(validInstanceStatusList);
-
- /*
- * Set up the supplied validEntityTypes and propagatable flag.
- */
- ArrayList<TypeDefLink> validEntityDefs = new ArrayList<>();
- validEntityDefs.add(validEntityDef);
- classificationDef.setValidEntityDefs(validEntityDefs);
- classificationDef.setPropagatable(propagatable);
-
- return classificationDef;
- }
-}
http://git-wip-us.apache.org/repos/asf/atlas/blob/b0ecc36a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/OMRSArchiveManager.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/OMRSArchiveManager.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/OMRSArchiveManager.java
deleted file mode 100644
index c640928..0000000
--- a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/OMRSArchiveManager.java
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * <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.omrs.archivemanager;
-
-import org.apache.atlas.omrs.archivemanager.opentypes.OpenMetadataTypesArchive;
-import org.apache.atlas.omrs.archivemanager.properties.OpenMetadataArchive;
-import org.apache.atlas.omrs.archivemanager.properties.OpenMetadataArchiveInstanceStore;
-import org.apache.atlas.omrs.archivemanager.properties.OpenMetadataArchiveProperties;
-import org.apache.atlas.omrs.archivemanager.properties.OpenMetadataArchiveTypeStore;
-import org.apache.atlas.omrs.archivemanager.store.OpenMetadataArchiveStoreConnector;
-import org.apache.atlas.omrs.auditlog.OMRSAuditCode;
-import org.apache.atlas.omrs.auditlog.OMRSAuditLog;
-import org.apache.atlas.omrs.auditlog.OMRSAuditingComponent;
-import org.apache.atlas.omrs.eventmanagement.events.OMRSInstanceEventProcessor;
-import org.apache.atlas.omrs.eventmanagement.events.OMRSTypeDefEventProcessor;
-import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryContentManager;
-import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail;
-import org.apache.atlas.omrs.metadatacollection.properties.instances.Relationship;
-import org.apache.atlas.omrs.metadatacollection.properties.typedefs.AttributeTypeDef;
-import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDef;
-import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefPatch;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * OMRSArchiveManager manages the loading and unloading of open metadata archives from the local OMRS repository.
- * An open metadata archive provides pre-built definitions for types and metadata instances.
- */
-public class OMRSArchiveManager
-{
- private List<OpenMetadataArchiveStoreConnector> openMetadataArchiveStores = new ArrayList<>();
- private OMRSRepositoryContentManager repositoryContentManager = null;
- private OMRSInstanceEventProcessor localInstanceEventProcessor = null;
-
-
- /*
- * The audit log provides a verifiable record of the open metadata archives that have been loaded into
- * the open metadata repository. The Logger is for standard debug.
- */
- private static final OMRSAuditLog auditLog = new OMRSAuditLog(OMRSAuditingComponent.ARCHIVE_MANAGER);
-
- /**
- * Constructor to save the initial list of open metadata archives from the server startup configuration.
- * These will be processed as soon as the event processors are supplied from the local repository.
- *
- * @param startUpOpenMetadataArchives - initial list of open metadata archives provided in startup configuration
- */
- public OMRSArchiveManager(List<OpenMetadataArchiveStoreConnector> startUpOpenMetadataArchives)
- {
- if (startUpOpenMetadataArchives != null)
- {
- this.openMetadataArchiveStores = new ArrayList<>(startUpOpenMetadataArchives);
- }
- }
-
-
- /**
- * Close down any open archives.
- */
- public void close()
- {
- for (OpenMetadataArchiveStoreConnector archiveStore : openMetadataArchiveStores)
- {
- if (archiveStore != null)
- {
- try
- {
- archiveStore.disconnect();
- }
- catch (Throwable error)
- {
- /*
- * nothing to do
- */
- }
- }
- }
- }
-
-
- /**
- * The local repository is accessed through its inbound event processors. A server will always have
- * the local Content Manager and TypeDef Processor but the local Instance Processor is only available
- * if the local server has a metadata repository defined.
- *
- * @param repositoryContentManager - typeDef processor for the local repository
- * @param instanceProcessor - instance processor for the local repository
- */
- public void setLocalRepository(OMRSRepositoryContentManager repositoryContentManager,
- OMRSInstanceEventProcessor instanceProcessor)
- {
- this.repositoryContentManager = repositoryContentManager;
- this.localInstanceEventProcessor = instanceProcessor;
-
- /*
- * The repository content manager is seeded with all of the open metadata types.
- */
- processOpenMetadataTypes();
-
- /*
- * Once the open metadata types are in place, the archive stores are processed.
- */
- for (OpenMetadataArchiveStoreConnector archiveStore : this.openMetadataArchiveStores)
- {
- processOpenMetadataArchiveStore(archiveStore, repositoryContentManager, instanceProcessor);
- }
- }
-
-
- /**
- * Add a new archive to the local repository. If there are problems processing the archive, an exception is thrown.
- * This method allows archives to be loaded into a running server.
- *
- * @param archiveStore - new open metadata archive to process
- */
- public void addOpenMetadataArchive(OpenMetadataArchiveStoreConnector archiveStore)
- {
- this.processOpenMetadataArchiveStore(archiveStore, repositoryContentManager, localInstanceEventProcessor);
- this.openMetadataArchiveStores.add(archiveStore);
- }
-
-
- /**
- * Unpack and process the contents an open metadata archive store, passing its contents to the local
- * repository (if it exists).
- */
- private void processOpenMetadataTypes()
- {
- OpenMetadataTypesArchive openMetadataTypesArchive = new OpenMetadataTypesArchive();
- OpenMetadataArchive openMetadataTypes = openMetadataTypesArchive.getOpenMetadataArchive();
-
- repositoryContentManager.setOpenMetadataTypesOriginGUID(openMetadataTypesArchive.getArchiveGUID());
- processOpenMetadataArchive(openMetadataTypes, repositoryContentManager, localInstanceEventProcessor);
- }
-
- /**
- * Unpack and process the contents an open metadata archive store, passing its contents to the local
- * repository (if it exists).
- *
- * @param archiveStore - open metadata archive store to process
- */
- private void processOpenMetadataArchiveStore(OpenMetadataArchiveStoreConnector archiveStore,
- OMRSTypeDefEventProcessor typeDefProcessor,
- OMRSInstanceEventProcessor instanceProcessor)
- {
- if (archiveStore != null)
- {
- /*
- * Each archive store has a header, a section of new type definitions (TypeDefs) and a section of
- * metadata instances.
- */
- OpenMetadataArchive archiveContent = archiveStore.getArchiveContents();
-
- if (archiveContent == null)
- {
- final String actionDescription = "Process Open Metadata Archive";
-
- OMRSAuditCode auditCode = OMRSAuditCode.EMPTY_ARCHIVE;
- auditLog.logRecord(actionDescription,
- auditCode.getLogMessageId(),
- auditCode.getSeverity(),
- auditCode.getFormattedLogMessage(),
- null,
- auditCode.getSystemAction(),
- auditCode.getUserAction());
- }
- else
- {
- processOpenMetadataArchive(archiveContent, typeDefProcessor, instanceProcessor);
- }
- }
- }
-
-
- /**
- * Step through the content of an open metadata archive, passing its contents to the local repository (if it
- * exists).
- *
- * @param archiveContent - open metadata archive to process
- */
- private void processOpenMetadataArchive(OpenMetadataArchive archiveContent,
- OMRSTypeDefEventProcessor typeDefProcessor,
- OMRSInstanceEventProcessor instanceProcessor)
- {
- OMRSAuditCode auditCode;
- final String actionDescription = "Process Open Metadata Archive";
-
- OpenMetadataArchiveProperties archiveProperties = archiveContent.getArchiveProperties();
-
- if (archiveProperties != null)
- {
- auditCode = OMRSAuditCode.PROCESSING_ARCHIVE;
- auditLog.logRecord(actionDescription,
- auditCode.getLogMessageId(),
- auditCode.getSeverity(),
- auditCode.getFormattedLogMessage(archiveProperties.getArchiveName()),
- null,
- auditCode.getSystemAction(),
- auditCode.getUserAction());
-
-
- OpenMetadataArchiveTypeStore archiveTypeStore = archiveContent.getArchiveTypeStore();
- OpenMetadataArchiveInstanceStore archiveInstanceStore = archiveContent.getArchiveInstanceStore();
-
- int typeCount = 0;
- int instanceCount = 0;
-
-
- if (archiveTypeStore != null)
- {
- typeCount = this.processTypeDefStore(archiveProperties, archiveTypeStore, typeDefProcessor);
- }
-
- if (archiveInstanceStore != null)
- {
- instanceCount = this.processInstanceStore(archiveProperties, archiveInstanceStore, instanceProcessor);
- }
-
- auditCode = OMRSAuditCode.COMPLETED_ARCHIVE;
- auditLog.logRecord(actionDescription,
- auditCode.getLogMessageId(),
- auditCode.getSeverity(),
- auditCode.getFormattedLogMessage(Integer.toString(typeCount),
- Integer.toString(instanceCount),
- archiveProperties.getArchiveName()),
- null,
- auditCode.getSystemAction(),
- auditCode.getUserAction());
- }
- else
- {
- auditCode = OMRSAuditCode.NULL_PROPERTIES_IN_ARCHIVE;
- auditLog.logRecord(actionDescription,
- auditCode.getLogMessageId(),
- auditCode.getSeverity(),
- auditCode.getFormattedLogMessage(),
- null,
- auditCode.getSystemAction(),
- auditCode.getUserAction());
- }
- }
-
-
- /**
- * The TypeStore is in two parts. First there is an optional list of patches to existing TypeDefs.
- * Then an optional list of new TypeDefs. It is possible that this archive has been processed before
- * and so any duplicates detected are ignored. However, conflicting TypeDefs are detected.
- * Any problems found in applying the archive contents are recorded on the audit log.
- *
- * @param archiveProperties - properties of the archive used for logging
- * @param archiveTypeStore - TypeStore from the archive
- * @return type count
- */
- private int processTypeDefStore(OpenMetadataArchiveProperties archiveProperties,
- OpenMetadataArchiveTypeStore archiveTypeStore,
- OMRSTypeDefEventProcessor typeDefProcessor)
- {
- List<TypeDefPatch> typeDefPatches = archiveTypeStore.getTypeDefPatches();
- List<AttributeTypeDef> newAttributeTypeDefs = archiveTypeStore.getAttributeTypeDefs();
- List<TypeDef> newTypeDefs = archiveTypeStore.getNewTypeDefs();
- int typeCount = 0;
-
- if (typeDefProcessor != null)
- {
- String sourceName = OMRSAuditingComponent.ARCHIVE_MANAGER.getComponentName();
- String originatorMetadataCollectionId = archiveProperties.getArchiveGUID();
- String originatorServerName = archiveProperties.getArchiveName();
- String originatorServerType = null;
- String originatorName = archiveProperties.getOriginatorName();
- String originatorOrganizationName = archiveProperties.getOriginatorOrganization();
-
- /*
- * Originator name can not be null since it is used as the userId for calls to the repository
- */
- if (originatorName == null)
- {
- originatorName = sourceName;
- }
-
- if (archiveProperties.getArchiveType() != null)
- {
- originatorServerType = archiveProperties.getArchiveType().getArchiveTypeName();
- }
-
- if (typeDefPatches != null)
- {
- for (TypeDefPatch typeDefPatch : typeDefPatches)
- {
- if (typeDefPatch != null)
- {
- typeDefProcessor.processUpdatedTypeDefEvent(originatorName,
- originatorMetadataCollectionId,
- originatorServerName,
- originatorServerType,
- originatorOrganizationName,
- typeDefPatch);
- typeCount ++;
- }
- }
- }
-
- if (newAttributeTypeDefs != null)
- {
- for (AttributeTypeDef newAttributeTypeDef : newAttributeTypeDefs)
- {
- if (newAttributeTypeDef != null)
- {
- typeDefProcessor.processNewAttributeTypeDefEvent(originatorName,
- originatorMetadataCollectionId,
- originatorServerName,
- originatorServerType,
- originatorOrganizationName,
- newAttributeTypeDef);
-
- typeCount ++;
- }
- }
- }
-
- if (newTypeDefs != null)
- {
- for (TypeDef newTypeDef : newTypeDefs)
- {
- if (newTypeDef != null)
- {
- typeDefProcessor.processNewTypeDefEvent(originatorName,
- originatorMetadataCollectionId,
- originatorServerName,
- originatorServerType,
- originatorOrganizationName,
- newTypeDef);
- typeCount ++;
- }
- }
- }
- }
-
- return typeCount;
- }
-
-
- /**
- * The InstanceStore is in two parts - an optional list of entities followed by an optional list
- * of relationships. It is possible that this archive has been processed before
- * and so any duplicates detected are ignored. However, conflicting instances are detected.
- * Any problems found in applying the archive contents are recorded on the audit log.
- *
- * @param archiveProperties - properties describing the archive used in logging
- * @param archiveInstanceStore - the instance store to process
- * @param instanceProcessor - the processor to add the instances to the local repository. It may be null
- * if there is no local repository configured for this server.
- * @return instance count
- */
- private int processInstanceStore(OpenMetadataArchiveProperties archiveProperties,
- OpenMetadataArchiveInstanceStore archiveInstanceStore,
- OMRSInstanceEventProcessor instanceProcessor)
- {
- List<EntityDetail> entities = archiveInstanceStore.getEntities();
- List<Relationship> relationships = archiveInstanceStore.getRelationships();
- int instanceCount = 0;
-
- if (instanceProcessor != null)
- {
- String sourceName = OMRSAuditingComponent.ARCHIVE_MANAGER.getComponentName();
- String originatorMetadataCollectionId = archiveProperties.getArchiveGUID();
- String originatorServerName = archiveProperties.getArchiveName();
- String originatorServerType = null;
- String originatorOrganizationName = archiveProperties.getOriginatorName();
-
- if (archiveProperties.getArchiveType() != null)
- {
- originatorServerType = archiveProperties.getArchiveType().getArchiveTypeName();
- }
-
- if (entities != null)
- {
- for (EntityDetail entity : entities)
- {
- if (entity != null)
- {
- instanceProcessor.processNewEntityEvent(sourceName,
- originatorMetadataCollectionId,
- originatorServerName,
- originatorServerType,
- originatorOrganizationName,
- entity);
-
- instanceCount ++;
- }
- }
- }
-
-
- if (relationships != null)
- {
- for (Relationship relationship : relationships)
- {
- if (relationship != null)
- {
- instanceProcessor.processNewRelationshipEvent(sourceName,
- originatorMetadataCollectionId,
- originatorServerName,
- originatorServerType,
- originatorOrganizationName,
- relationship);
-
- instanceCount ++;
- }
- }
- }
- }
-
- return instanceCount;
- }
-}
http://git-wip-us.apache.org/repos/asf/atlas/blob/b0ecc36a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/OMRSArchiveWriter.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/OMRSArchiveWriter.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/OMRSArchiveWriter.java
deleted file mode 100644
index ea9fbfe..0000000
--- a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/OMRSArchiveWriter.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * <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.omrs.archivemanager;
-
-
-import org.apache.atlas.ocf.Connector;
-import org.apache.atlas.ocf.ConnectorBroker;
-import org.apache.atlas.ocf.properties.Connection;
-import org.apache.atlas.omrs.admin.OMRSConfigurationFactory;
-import org.apache.atlas.omrs.archivemanager.opentypes.OpenMetadataTypesArchive;
-import org.apache.atlas.omrs.archivemanager.properties.OpenMetadataArchive;
-import org.apache.atlas.omrs.archivemanager.store.OpenMetadataArchiveStore;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * OMRSArchiveWriter creates physical open metadata archive files for the supplied open metadata archives
- * encoded in OMRS.
- */
-public class OMRSArchiveWriter
-{
- private static final Logger log = LoggerFactory.getLogger(OMRSArchiveWriter.class);
-
- /**
- * Default constructor
- */
- public OMRSArchiveWriter()
- {
- }
-
-
- /**
- * Opens up an open metadata archive store connector.
- *
- * @param connection - connection information for the open metadata archive.
- * @return open metadata archive store connector
- */
- private OpenMetadataArchiveStore getOpenMetadataArchive(Connection connection)
- {
- OpenMetadataArchiveStore openMetadataArchiveStore = null;
-
- try
- {
- ConnectorBroker connectorBroker = new ConnectorBroker();
- Connector connector = connectorBroker.getConnector(connection);
-
- openMetadataArchiveStore = (OpenMetadataArchiveStore)connector;
-
- log.debug("Created connector to open metadata archive store");
-
- }
- catch (Throwable error)
- {
- log.error("Unexpected exception occurred: " + error.getMessage());
- log.error("Exception: " + error.toString());
- }
-
- return openMetadataArchiveStore;
- }
-
-
- /**
- * Generates and writes out an open metadata archive containing all of the open metadata types.
- */
- private void writeOpenMetadataArchiveTypes()
- {
- OMRSConfigurationFactory configurationFactory = new OMRSConfigurationFactory();
- Connection connection = configurationFactory.getOpenMetadataTypesConnection();
-
- OpenMetadataArchiveStore openMetadataArchiveStore = this.getOpenMetadataArchive(connection);
- OpenMetadataTypesArchive openMetadataTypesArchive = new OpenMetadataTypesArchive();
- OpenMetadataArchive openMetadataArchive = openMetadataTypesArchive.getOpenMetadataArchive();
-
- openMetadataArchiveStore.setArchiveContents(openMetadataArchive);
- }
-
-
- /**
- * Main program to control the archive writer.
- *
- * @param args - ignored arguments
- */
- public static void main(String[] args)
- {
- OMRSArchiveWriter archiveWriter = new OMRSArchiveWriter();
-
- archiveWriter.writeOpenMetadataArchiveTypes();
-
- /*
- * Calls to create other standard archives will go here.
- */
- }
-}