http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSMetadataStore.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSMetadataStore.java b/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSMetadataStore.java new file mode 100644 index 0000000..6b9bfd5 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSMetadataStore.java @@ -0,0 +1,634 @@ +/* + * 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.adapters.inmemory.repositoryconnector; + +import org.apache.atlas.omrs.ffdc.OMRSErrorCode; +import org.apache.atlas.omrs.ffdc.exception.InvalidParameterException; +import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail; +import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityProxy; +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 java.util.*; + +/** + * InMemoryOMRSMetadataStore provides the in memory stores for the InMemoryRepositoryConnector + */ +public class InMemoryOMRSMetadataStore +{ + private String repositoryName = null; + private HashMap<String, TypeDef> typeDefStore = new HashMap<>(); + private HashMap<String, AttributeTypeDef> attributeTypeDefStore = new HashMap<>(); + private HashMap<String, EntityDetail> entityStore = new HashMap<>(); + private HashMap<String, EntityProxy> entityProxyStore = new HashMap<>(); + private List<EntityDetail> entityHistoryStore = new ArrayList<>(); + private HashMap<String, Relationship> relationshipStore = new HashMap<>(); + private List<Relationship> relationshipHistoryStore = new ArrayList<>(); + + + /** + * Default constructor + */ + public InMemoryOMRSMetadataStore() + { + } + + + /** + * Set up the name of the repository for logging. + * + * @param repositoryName - String name + */ + protected void setRepositoryName(String repositoryName) + { + this.repositoryName = repositoryName; + } + + + /** + * Return a list of all of the defined AttributeTypeDefs. + * + * @return list of attribute type definitions + */ + protected List<AttributeTypeDef> getAttributeTypeDefs() + { + return new ArrayList<>(attributeTypeDefStore.values()); + } + + + /** + * Return the AttributeTypeDef identified by the supplied guid. + * + * @param guid - unique identifier for the AttributeTypeDef + * @return attribute type definition + */ + protected AttributeTypeDef getAttributeTypeDef(String guid) + { + return attributeTypeDefStore.get(guid); + } + + + /** + * Add an AttributeDefType to the store. + * + * @param attributeTypeDef - type to add + */ + protected void putAttributeTypeDef(AttributeTypeDef attributeTypeDef) + { + attributeTypeDefStore.put(attributeTypeDef.getGUID(), attributeTypeDef); + } + + + /** + * Return a list of all of the defined TypeDefs. + * + * @return list of type definitions + */ + protected List<TypeDef> getTypeDefs() + { + return new ArrayList<>(typeDefStore.values()); + } + + + /** + * Return the type definition identified by the guid. + * + * @param guid - unique identifier for type definition + * @return type definition + */ + protected TypeDef getTypeDef(String guid) + { + return typeDefStore.get(guid); + } + + + /** + * Add a type definition (TypeDef) to the store. + * + * @param typeDef - type definition + */ + protected void putTypeDef(TypeDef typeDef) + { + typeDefStore.put(typeDef.getGUID(), typeDef); + } + + + /** + * Return a list of entities from the store that are at the latest level. + * + * @return + */ + protected List<EntityDetail> getEntities() + { + return new ArrayList<>(entityStore.values()); + } + + + /** + * Return the entity identified by the guid. + * + * @param guid - unique identifier for the entity + * @return entity object + */ + protected EntityDetail getEntity(String guid) + { + return entityStore.get(guid); + } + + + /** + * Return the entity proxy identified by the guid. + * + * @param guid - unique identifier + * @return entity proxy object + */ + protected EntityProxy getEntityProxy(String guid) + { + return entityProxyStore.get(guid); + } + + + /** + * Return an entity store that contains entities as they were at the time supplied in the asOfTime + * parameter + * + * @param methodName - name of the method requesting the store + * @param asOfTime - time for the store (or null means now) + * @return entity store for the requested time + * @throws InvalidParameterException - asOfTime is for the future. + */ + protected HashMap<String, EntityDetail> timeWarpEntityStore(String methodName, + Date asOfTime) throws InvalidParameterException + { + final String asOfTimeParameterName = "asOfTime"; + + if (asOfTime == null) + { + return entityStore; + } + + Date now = new Date(); + + if (asOfTime.after(now)) + { + OMRSErrorCode errorCode = OMRSErrorCode.REPOSITORY_NOT_CRYSTAL_BALL; + String errorMessage = errorCode.getErrorMessageId() + + errorCode.getFormattedErrorMessage(asOfTime.toString(), + asOfTimeParameterName, + methodName, + repositoryName); + + throw new InvalidParameterException(errorCode.getHTTPErrorCode(), + this.getClass().getName(), + methodName, + errorMessage, + errorCode.getSystemAction(), + errorCode.getUserAction()); + } + + + HashMap<String, EntityDetail> timeWarpedEntityStore = new HashMap<>(); + + /* + * First step through the current relationship store and extract all of the relationships that were + * last updated before the asOfTime. + */ + for (EntityDetail entity : entityStore.values()) + { + if (entity != null) + { + if (entity.getUpdateTime() != null) + { + String entityGUID = entity.getGUID(); + + if (entityGUID != null) + { + if (! entity.getUpdateTime().after(asOfTime)) + { + timeWarpedEntityStore.put(entityGUID, entity); + } + } + } + else if (entity.getCreateTime() != null) + { + if (! entity.getCreateTime().after(asOfTime)) + { + timeWarpedEntityStore.put(entity.getGUID(), entity); + } + } + } + } + + /* + * Now step through the history store picking up the versions of other entities that were active + * at the time of the asOfTime. + */ + for (EntityDetail oldEntity : entityHistoryStore) + { + if (oldEntity != null) + { + String entityGUID = oldEntity.getGUID(); + + if (oldEntity.getUpdateTime() != null) + { + if (! oldEntity.getUpdateTime().after(asOfTime)) + { + EntityDetail newerEntity = timeWarpedEntityStore.put(entityGUID, oldEntity); + + if (newerEntity != null) + { + timeWarpedEntityStore.put(entityGUID, newerEntity); + } + break; + } + } + else if (oldEntity.getCreateTime() != null) + { + if (! oldEntity.getCreateTime().after(asOfTime)) + { + timeWarpedEntityStore.put(entityGUID, oldEntity); + break; + } + } + } + } + + return timeWarpedEntityStore; + } + + + /** + * Return the list of relationships at their current level. + * + * @return list of relationships + */ + protected List<Relationship> getRelationships() + { + return new ArrayList<>(relationshipStore.values()); + } + + + /** + * Return the relationship identified by the guid. + * + * @param guid - unique identifier for the relationship + * @return relationship object + */ + protected Relationship getRelationship(String guid) + { + return relationshipStore.get(guid); + } + + /** + * Return a relationship store that contains relationships as they were at the time supplied in the asOfTime + * parameter + * + * @param methodName - name of the method requesting the store + * @param asOfTime - time for the store (or null means now) + * @return relationship store for the requested time + * @throws InvalidParameterException - asOfTime is for the future. + */ + protected HashMap<String, Relationship> timeWarpRelationshipStore(String methodName, + Date asOfTime) throws InvalidParameterException + { + final String asOfTimeParameterName = "asOfTime"; + + if (asOfTime == null) + { + return relationshipStore; + } + + Date now = new Date(); + + if (asOfTime.after(now)) + { + OMRSErrorCode errorCode = OMRSErrorCode.REPOSITORY_NOT_CRYSTAL_BALL; + String errorMessage = errorCode.getErrorMessageId() + + errorCode.getFormattedErrorMessage(asOfTime.toString(), + asOfTimeParameterName, + methodName, + repositoryName); + + throw new InvalidParameterException(errorCode.getHTTPErrorCode(), + this.getClass().getName(), + methodName, + errorMessage, + errorCode.getSystemAction(), + errorCode.getUserAction()); + } + + + HashMap<String, Relationship> timeWarpedRelationshipStore = new HashMap<>(); + + /* + * First step through the current relationship store and extract all of the relationships that were + * last updated before the asOfTime. + */ + for (Relationship relationship : relationshipStore.values()) + { + if (relationship != null) + { + if (relationship.getUpdateTime() != null) + { + String relationshipGUID = relationship.getGUID(); + + if (relationshipGUID != null) + { + if (! relationship.getUpdateTime().after(asOfTime)) + { + timeWarpedRelationshipStore.put(relationshipGUID, relationship); + } + } + } + else if (relationship.getCreateTime() != null) + { + if (! relationship.getCreateTime().after(asOfTime)) + { + timeWarpedRelationshipStore.put(relationship.getGUID(), relationship); + } + } + } + } + + /* + * Now step through the history store picking up the versions of other relationships that were active + * at the time of the asOfTime. + */ + for (Relationship oldRelationship : relationshipHistoryStore) + { + if (oldRelationship != null) + { + String relationshipGUID = oldRelationship.getGUID(); + + if (oldRelationship.getUpdateTime() != null) + { + if (! oldRelationship.getUpdateTime().after(asOfTime)) + { + Relationship newerRelationship = timeWarpedRelationshipStore.put(relationshipGUID, oldRelationship); + + if (newerRelationship != null) + { + timeWarpedRelationshipStore.put(relationshipGUID, newerRelationship); + } + break; + } + } + else if (oldRelationship.getCreateTime() != null) + { + if (! oldRelationship.getCreateTime().after(asOfTime)) + { + timeWarpedRelationshipStore.put(relationshipGUID, oldRelationship); + break; + } + } + } + } + + return timeWarpedRelationshipStore; + } + + /** + * Create a new entity in the entity store. + * + * @param entity - new version of the entity + * @return entity with potentially updated GUID + */ + protected EntityDetail createEntityInStore(EntityDetail entity) + { + /* + * There is a small chance the randomly generated GUID will clash with an existing relationship. + * If this happens a new GUID is generated for the relationship and the process repeats. + */ + EntityDetail existingEntity = entityStore.put(entity.getGUID(), entity); + + while (existingEntity != null) + { + entity.setGUID(UUID.randomUUID().toString()); + existingEntity = entityStore.put(entity.getGUID(), entity); + } + + return entity; + } + + + /** + * Create a new relationship in the relationship store. + * + * @param relationship - new version of the relationship + * @return relationship with potentially updated GUID + */ + protected Relationship createRelationshipInStore(Relationship relationship) + { + /* + * There is a small chance the randomly generated GUID will clash with an existing relationship. + * If this happens a new GUID is generated for the relationship and the process repeats. + */ + Relationship existingRelationship = relationshipStore.put(relationship.getGUID(), relationship); + + while (existingRelationship != null) + { + relationship.setGUID(UUID.randomUUID().toString()); + existingRelationship = relationshipStore.put(relationship.getGUID(), relationship); + } + + return relationship; + } + + + /** + * Save an entity proxy to the entity store. + * + * @param entityProxy - entity proxy object to add + */ + protected void addEntityProxyToStore(EntityProxy entityProxy) + { + entityProxyStore.put(entityProxy.getGUID(), entityProxy); + } + + + /** + * Maintain a history of entities as they are stored into the entity store to ensure old version can be restored. + * The history is maintained with the latest changes first in the list. + * + * @param entity - new version of the entity + */ + protected void updateEntityInStore(EntityDetail entity) + { + EntityDetail oldEntity = entityStore.put(entity.getGUID(), entity); + + if (oldEntity != null) + { + entityHistoryStore.add(0, oldEntity); + } + } + + + /** + * Update an entity proxy in the proxy store. + * + * @param entityProxy - entity proxy object to add + */ + protected void updateEntityProxyInStore(EntityProxy entityProxy) + { + entityProxyStore.put(entityProxy.getGUID(), entityProxy); + } + + + + /** + * Maintain a history of relationships as they are stored into the relationship store to ensure old version + * can be restored. The history is maintained with the latest changes first in the list. + * + * @param relationship - new version of the relationship + */ + protected void updateRelationshipInStore(Relationship relationship) + { + Relationship oldRelationship = relationshipStore.put(relationship.getGUID(), relationship); + + if (oldRelationship != null) + { + relationshipHistoryStore.add(0, oldRelationship); + } + } + + + /** + * Save a reference copy of an entity to the active store. Reference copies are not maintained in the + * history store. + * + * @param entity - object to save + */ + protected void saveReferenceEntityToStore(EntityDetail entity) + { + entityStore.put(entity.getGUID(), entity); + } + + + /** + * Save a reference copy of a relationship to the active store. Reference copies are not maintained in the + * history store. + * + * @param relationship - object to save + */ + protected void saveReferenceRelationshipToStore(Relationship relationship) + { + relationshipStore.put(relationship.getGUID(), relationship); + } + + + /** + * Retrieve the previous version of a Relationship. This is the first instance of this element that + * appears in the history. + * + * @param guid - unique identifier for the required element + * @return - previous version of this relationship - or null if not found + */ + protected Relationship retrievePreviousVersionOfRelationship(String guid) + { + if (guid != null) + { + int elementPosition = 0; + + for (Relationship relationship : relationshipHistoryStore) + { + if (relationship != null) + { + if (guid.equals(relationship.getGUID())) + { + relationshipHistoryStore.remove(elementPosition); + relationshipStore.put(guid, relationship); + return relationship; + } + } + + elementPosition ++; + } + } + + return null; + } + + + /** + * Retrieve the previous version of an Entity from the history store and restore it in the entity store. + * This is the first instance of this element that appears in the history. + * + * @param guid - unique identifier for the required element + * @return - previous version of this Entity - or null if not found + */ + protected EntityDetail retrievePreviousVersionOfEntity(String guid) + { + if (guid != null) + { + int elementPosition = 0; + + for (EntityDetail entity : entityHistoryStore) + { + if (entity != null) + { + if (guid.equals(entity.getGUID())) + { + entityHistoryStore.remove(elementPosition); + entityStore.put(guid, entity); + return entity; + } + } + + elementPosition ++; + } + } + + return null; + } + + + /** + * Remove an entity from the active store and add it to the history store. + * + * @param entity - entity to remove + */ + protected void removeEntityFromStore(EntityDetail entity) + { + entityStore.remove(entity.getGUID()); + entityHistoryStore.add(0, entity); + } + + /** + * Remove an entity from the active store and add it to the history store. + * + * @param guid - entity proxy to remove + */ + protected void removeEntityProxyFromStore(String guid) + { + entityProxyStore.remove(guid); + } + + + /** + * Remove a relationship from the active store and add it to the history store. + * + * @param relationship - relationship to remove + */ + protected void removeRelationshipFromStore(Relationship relationship) + { + relationshipStore.remove(relationship.getGUID()); + relationshipHistoryStore.add(0, relationship); + } + +}
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSRepositoryConnector.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSRepositoryConnector.java b/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSRepositoryConnector.java new file mode 100644 index 0000000..56dbb96 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSRepositoryConnector.java @@ -0,0 +1,58 @@ +/* + * 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.adapters.inmemory.repositoryconnector; + +import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector; + +/** + * The InMemoryOMRSRepositoryConnector is a connector to a local in memory repository. It is used for test, + * small scale fixed or temporary repositories where the initial content comes from open metadata archives and + * other members of connected open metadata repository cohorts. + */ +public class InMemoryOMRSRepositoryConnector extends OMRSRepositoryConnector +{ + /** + * Default constructor used by the OCF Connector Provider. + */ + public InMemoryOMRSRepositoryConnector() + { + /* + * Nothing to do. + */ + } + + + /** + * Set up the unique Id for this metadata collection. + * + * @param metadataCollectionId - String unique Id + */ + public void setMetadataCollectionId(String metadataCollectionId) + { + super.metadataCollectionId = metadataCollectionId; + + /* + * Initialize the metadata collection only once the connector is properly set up. + */ + super.metadataCollection = new InMemoryOMRSMetadataCollection(this, + super.serverName, + repositoryHelper, + repositoryValidator, + metadataCollectionId); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSRepositoryConnectorProvider.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSRepositoryConnectorProvider.java b/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSRepositoryConnectorProvider.java new file mode 100644 index 0000000..0b727e9 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSRepositoryConnectorProvider.java @@ -0,0 +1,45 @@ +/* + * 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.adapters.inmemory.repositoryconnector; + +import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnectorProviderBase; + +/** + * In the Open Connector Framework (OCF), a ConnectorProvider is a factory for a specific type of connector. + * The InMemoryOMRSRepositoryConnectorProvider is the connector provider for the InMemoryOMRSRepositoryConnector. + * It extends OMRSRepositoryConnectorProviderBase which in turn extends the OCF ConnectorProviderBase. + * ConnectorProviderBase supports the creation of connector instances. + * + * The InMemoryOMRSRepositoryConnectorProvider must initialize ConnectorProviderBase with the Java class + * name of the OMRS Connector implementation (by calling super.setConnectorClassName(className)). + * Then the connector provider will work. + */ +public class InMemoryOMRSRepositoryConnectorProvider + extends OMRSRepositoryConnectorProviderBase +{ + /** + * Constructor used to initialize the ConnectorProviderBase with the Java class name of the specific + * OMRS Connector implementation. + */ + public InMemoryOMRSRepositoryConnectorProvider() + { + Class connectorClass = InMemoryOMRSRepositoryConnector.class; + + super.setConnectorClassName(connectorClass.getName()); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSConfigurationFactory.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSConfigurationFactory.java b/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSConfigurationFactory.java index c626fa0..0f7bd01 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSConfigurationFactory.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSConfigurationFactory.java @@ -17,173 +17,636 @@ */ package org.apache.atlas.omrs.admin; -import org.apache.atlas.ocf.properties.*; +import org.apache.atlas.ocf.properties.ElementOrigin; +import org.apache.atlas.ocf.properties.beans.Connection; +import org.apache.atlas.ocf.properties.beans.ConnectorType; +import org.apache.atlas.ocf.properties.beans.Endpoint; +import org.apache.atlas.ocf.properties.beans.ElementType; + + +import org.apache.atlas.omrs.adapters.atlas.repositoryconnector.LocalAtlasOMRSRepositoryConnectorProvider; +import org.apache.atlas.omrs.adapters.inmemory.repositoryconnector.InMemoryOMRSRepositoryConnectorProvider; import org.apache.atlas.omrs.admin.properties.*; +import org.apache.atlas.omrs.archivemanager.store.file.FileBasedOpenMetadataArchiveStoreProvider; +import org.apache.atlas.omrs.auditlog.store.file.FileBasedAuditLogStoreProvider; import org.apache.atlas.omrs.metadatahighway.cohortregistry.store.file.FileBasedRegistryStoreProvider; import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary; +import org.apache.atlas.omrs.rest.repositoryconnector.OMRSRESTRepositoryConnectorProvider; import org.apache.atlas.omrs.topicconnectors.kafka.KafkaOMRSTopicProvider; import java.util.ArrayList; +import java.util.List; import java.util.UUID; /** - * OMRSConfigurationFactory sets up default configuration for the OMRS components and manages the changes made - * by the server administrator. + * OMRSConfigurationFactory sets up default configuration for the OMRS components. It is used by the OMAG server + * while it manages the changes made to the server configuration by the server administrator. The aim is to + * build up the RepositoryServicesConfig object that is used to initialize the OMRSOperationalServices. */ public class OMRSConfigurationFactory { /* * Default property fillers */ - private static final String defaultEnterpriseMetadataCollectionName = "Enterprise Metadata Collection"; + private static final String defaultEnterpriseMetadataCollectionName = " Enterprise Metadata Collection"; + + private static final String defaultTopicRootName = "omag/omrs/"; + private static final String defaultTopicLeafName = "/OMRSTopic"; + + private static final String defaultEnterpriseTopicConnectorRootName = "enterprise/"; + private static final String defaultCohortTopicConnectorRootName = "cohort/"; + + private static final String defaultCohortName = "defaultCohort"; + + private static final String defaultOpenMetadataArchiveFileName = "OpenMetadataTypes.json"; + + /** + * Default constructor + */ + public OMRSConfigurationFactory() + { + } + + + /** + * Return the connection for the default audit log. + * By default, the Audit log is stored in a directory called localServerName.auditlog. + * + * @param localServerName - name of the local server + * @return OCF Connection used to create the file-based audit logger + */ + private Connection getDefaultAuditLogConnection(String localServerName) + { + final String endpointGUID = "836efeae-ab34-4425-89f0-6adf2faa1f2e"; + final String connectorTypeGUID = "f8a24f09-9183-4d5c-8408-aa1c8852a7d6"; + final String connectionGUID = "5390bf3e-6b38-4eda-b34a-de55ac4252a7"; + + final String endpointDescription = "OMRS default audit log endpoint."; + + String endpointAddress = localServerName + ".auditlog"; + String endpointName = "DefaultAuditLog.Endpoint." + endpointAddress; - private static final String defaultTopicRootName = "omag"; - private static final String defaultTopicLeafName = "OMRSTopic"; + Endpoint endpoint = new Endpoint(); - private static final String defaultTopicConnectorLeafName = "OMRS Topic Connector"; - private static final String defaultEnterpriseTopicConnectorRootName = "Enterprise"; + endpoint.setType(this.getEndpointType()); + endpoint.setGUID(endpointGUID); + endpoint.setQualifiedName(endpointName); + endpoint.setDisplayName(endpointName); + endpoint.setDescription(endpointDescription); + endpoint.setAddress(endpointAddress); - private static final String defaultTopicConnectorName = "OMRS Kafka Topic Connector"; - private static final String defaultTopicConnectorDescription = "Kafka Topic used to exchange event between members of an open metadata repository cluster."; - private static final String defaultTopicConnectorProviderClassName = KafkaOMRSTopicProvider.class.getName(); + final String connectorTypeDescription = "OMRS default audit log connector type."; + final String connectorTypeJavaClassName = FileBasedAuditLogStoreProvider.class.getName(); - private static final String defaultCohortName = "defaultCohort"; + String connectorTypeName = "DefaultAuditLog.ConnectorType." + localServerName; - private static final String defaultRegistryStoreFQName = "OMRS Cohort Registry Store: cohort.registry"; - private static final String defaultRegistryStoreDisplayName = "Cohort Registry Store"; - private static final String defaultRegistryStoreDescription = "File-based Store use by the cohort registry to store information about the members of the open metadata repository cluster."; - private static final String defaultRegistryStoreAddress = "cohort.registry"; - private static final String defaultRegistryStoreProviderClassName = FileBasedRegistryStoreProvider.class.getName(); + ConnectorType connectorType = new ConnectorType(); + connectorType.setType(this.getConnectorTypeType()); + connectorType.setGUID(connectorTypeGUID); + connectorType.setQualifiedName(connectorTypeName); + connectorType.setDisplayName(connectorTypeName); + connectorType.setDescription(connectorTypeDescription); + connectorType.setConnectorProviderClassName(connectorTypeJavaClassName); + final String connectionDescription = "OMRS default audit log connection."; - private String localServerName = null; - private String localServerType = null; - private String localServerURL = null; - private String localOrganizationName = null; - private RepositoryServicesConfig repositoryServicesConfig = null; + String connectionName = "DefaultAuditLog.Connection." + localServerName; + + Connection connection = new Connection(); + + connection.setType(this.getConnectionType()); + connection.setGUID(connectionGUID); + connection.setQualifiedName(connectionName); + connection.setDisplayName(connectionName); + connection.setDescription(connectionDescription); + connection.setEndpoint(endpoint); + connection.setConnectorType(connectorType); + + return connection; + } /** - * Constructor used when the server is being configured. Any parameter may be null. + * Return the connection for the default audit log. + * By default, the open metadata is stored in a file called localServerName.auditlog. * - * @param localServerName - name of the local server - * @param localServerType - type of the local server - * @param localServerURL - URL of the local server - * @param localOrganizationName - name of the organization that owns the local server + * @return OCF Connection used to create the file-based open metadata archive */ - public OMRSConfigurationFactory(String localServerName, - String localServerType, - String localServerURL, - String localOrganizationName) + public Connection getOpenMetadataTypesConnection() { - this.localServerName = localServerName; - this.localServerType = localServerType; - this.localServerURL = localServerURL; - this.localOrganizationName = localOrganizationName; + final String endpointGUID = "45877b9c-9192-44ba-a2b7-6817bc753969"; + final String connectorTypeGUID = "86f52a17-5d3c-47fd-9cac-0b5a45d150a9"; + final String connectionGUID = "447bbb33-84f9-4a56-a712-addeebdcd764"; + + final String endpointDescription = "Open metadata types archive endpoint."; + + String endpointAddress = defaultOpenMetadataArchiveFileName; + String endpointName = "OpenMetadataTypes.Endpoint" + endpointAddress; + + Endpoint endpoint = new Endpoint(); + + endpoint.setType(this.getEndpointType()); + endpoint.setGUID(endpointGUID); + endpoint.setQualifiedName(endpointName); + endpoint.setDisplayName(endpointName); + endpoint.setDescription(endpointDescription); + endpoint.setAddress(endpointAddress); + + final String connectorTypeDescription = "Open metadata types archive connector type."; + final String connectorTypeJavaClassName = FileBasedOpenMetadataArchiveStoreProvider.class.getName(); + + String connectorTypeName = "OpenMetadataTypes.ConnectorType"; + + ConnectorType connectorType = new ConnectorType(); + + connectorType.setType(this.getConnectorTypeType()); + connectorType.setGUID(connectorTypeGUID); + connectorType.setQualifiedName(connectorTypeName); + connectorType.setDisplayName(connectorTypeName); + connectorType.setDescription(connectorTypeDescription); + connectorType.setConnectorProviderClassName(connectorTypeJavaClassName); + + final String connectionDescription = "Open metadata types archive connection."; + + String connectionName = "OpenMetadataTypes.Connection"; + + Connection connection = new Connection(); + + connection.setType(this.getConnectionType()); + connection.setGUID(connectionGUID); + connection.setQualifiedName(connectionName); + connection.setDisplayName(connectionName); + connection.setDescription(connectionDescription); + connection.setEndpoint(endpoint); + connection.setConnectorType(connectorType); + + return connection; } - public Connection getGenericConnection() + + /** + * Return the default local repository's local connection. This is set to null which means use the remote + * connection. + * + * @return null Connection object + */ + private Connection getDefaultLocalRepositoryLocalConnection() { return null; } - public Connection getDefaultAuditLogConnection() + + /** + * Return the local graph repository's connection. This is using the LocalAtlasOMRSRepositoryConnector. + * + * @param localServerName - name of the local server + * @return Connection object + */ + private Connection getLocalGraphRepositoryLocalConnection(String localServerName) { - return null; + final String connectorTypeGUID = "18530415-44a2-4bd0-95bb-8efd333e53fb"; + final String connectionGUID = "3f1fd4fc-90f9-436a-8e2c-2120d590f5e4"; + + final String connectorTypeDescription = "OMRS default graph local repository connector type."; + final String connectorTypeJavaClassName = LocalAtlasOMRSRepositoryConnectorProvider.class.getName(); + + String connectorTypeName = "DefaultLocalGraphRepository.ConnectorType." + localServerName; + + ConnectorType connectorType = new ConnectorType(); + + connectorType.setType(this.getConnectorTypeType()); + connectorType.setGUID(connectorTypeGUID); + connectorType.setQualifiedName(connectorTypeName); + connectorType.setDisplayName(connectorTypeName); + connectorType.setDescription(connectorTypeDescription); + connectorType.setConnectorProviderClassName(connectorTypeJavaClassName); + + + final String connectionDescription = "OMRS default local graph repository connection."; + + String connectionName = "DefaultLocalGraphRepository.Connection." + localServerName; + + Connection connection = new Connection(); + + connection.setType(this.getConnectionType()); + connection.setGUID(connectionGUID); + connection.setQualifiedName(connectionName); + connection.setDisplayName(connectionName); + connection.setDescription(connectionDescription); + connection.setConnectorType(connectorType); + + return connection; } - public Connection getDefaultOpenMetadataTypesArchiveConnection() + + /** + * Return the in-memory local repository connection. This is using the InMemoryOMRSRepositoryConnector. + * + * @param localServerName - name of the local server + * @return Connection object + */ + private Connection getInMemoryLocalRepositoryLocalConnection(String localServerName) { - return null; + final String connectorTypeGUID = "21422eb9-c6c1-4071-b96b-0572c9680260"; + final String connectionGUID = "6a3c07b0-0e04-42dc-bcc6-392609bf1d02"; + + final String connectorTypeDescription = "OMRS default in memory local repository connector type."; + final String connectorTypeJavaClassName = InMemoryOMRSRepositoryConnectorProvider.class.getName(); + + String connectorTypeName = "DefaultInMemoryRepository.ConnectorType." + localServerName; + + ConnectorType connectorType = new ConnectorType(); + + connectorType.setType(this.getConnectorTypeType()); + connectorType.setGUID(connectorTypeGUID); + connectorType.setQualifiedName(connectorTypeName); + connectorType.setDisplayName(connectorTypeName); + connectorType.setDescription(connectorTypeDescription); + connectorType.setConnectorProviderClassName(connectorTypeJavaClassName); + + + final String connectionDescription = "OMRS default in memory local repository connection."; + + String connectionName = "DefaultInMemoryRepository.Connection." + localServerName; + + Connection connection = new Connection(); + + connection.setType(this.getConnectionType()); + connection.setGUID(connectionGUID); + connection.setQualifiedName(connectionName); + connection.setDisplayName(connectionName); + connection.setDescription(connectionDescription); + connection.setConnectorType(connectorType); + + return connection; } - private Connection getGenericArchiveConnection() + + /** + * Return the Connection for this server's OMRS Repository REST API. If the localServerURL is + * something like localhost:8080/omag/localServerName and the REST API URL would be + * localhost:8080/omag/localServerName/omrs/metadatacollection. + * + * @param localServerName - name of the local server + * @param localServerURL - root of the local server's URL + * @return Connection object + */ + private Connection getDefaultLocalRepositoryRemoteConnection(String localServerName, + String localServerURL) { - return null; + final String endpointGUID = "cee85898-43aa-4af5-9bbd-2bed809d1acb"; + final String connectorTypeGUID = "64e67923-8190-45ea-8f96-39320d638c02"; + final String connectionGUID = "858be98b-49d2-4ccf-9b23-01085a5f473f"; + + final String endpointDescription = "OMRS default repository REST API endpoint."; + + String endpointAddress = localServerURL + "/omag/omrs/"; + String endpointName = "DefaultRepositoryRESTAPI.Endpoint." + localServerName; + + Endpoint endpoint = new Endpoint(); + + endpoint.setType(this.getEndpointType()); + endpoint.setGUID(endpointGUID); + endpoint.setQualifiedName(endpointName); + endpoint.setDisplayName(endpointName); + endpoint.setDescription(endpointDescription); + endpoint.setAddress(endpointAddress); + + final String connectorTypeDescription = "OMRS default repository REST API connector type."; + final String connectorTypeJavaClassName = OMRSRESTRepositoryConnectorProvider.class.getName(); + + String connectorTypeName = "DefaultRepositoryRESTAPI.ConnectorType." + localServerName; + + ConnectorType connectorType = new ConnectorType(); + + connectorType.setType(this.getConnectorTypeType()); + connectorType.setGUID(connectorTypeGUID); + connectorType.setQualifiedName(connectorTypeName); + connectorType.setDisplayName(connectorTypeName); + connectorType.setDescription(connectorTypeDescription); + connectorType.setConnectorProviderClassName(connectorTypeJavaClassName); + + + final String connectionDescription = "OMRS default repository REST API connection."; + + String connectionName = "DefaultRepositoryRESTAPI.Connection." + localServerName; + + Connection connection = new Connection(); + + connection.setType(this.getConnectionType()); + connection.setGUID(connectionGUID); + connection.setQualifiedName(connectionName); + connection.setDisplayName(connectionName); + connection.setDescription(connectionDescription); + connection.setEndpoint(endpoint); + connection.setConnectorType(connectorType); + + return connection; } - private Connection getGenericRepositoryConnection() + + /** + * Return the default local repository event mapper. This is null since the use of, or need for, the event mapper + * is determined by the type of local repository. + * + * @return null Connection object + */ + private Connection getDefaultEventMapperConnection() { return null; } - private Connection getDefaultLocalRepositoryLocalConnection() + + /** + * Return the default connection for the enterprise OMRS topic. This uses a Kafka topic called + * omag/omrs/enterprise/localServerName/OMRSTopic. + * + * @param localServerName - name of local server + * @return Connection object + */ + private Connection getDefaultEnterpriseOMRSTopicConnection(String localServerName) { - return null; + final String endpointGUID = "e0d88035-8522-42bc-b57f-06df05f15825"; + final String connectorTypeGUID = "6536cb46-61f0-4f2d-abb4-2dadede30520"; + final String connectionGUID = "2084ee90-717b-49a1-938e-8f9d49567b8e"; + + final String endpointDescription = "OMRS default enterprise topic endpoint."; + + String endpointAddress = defaultTopicRootName + defaultEnterpriseTopicConnectorRootName + localServerName + defaultTopicLeafName; + String endpointName = "DefaultEnterpriseTopic.Endpoint." + endpointAddress; + + Endpoint endpoint = new Endpoint(); + + endpoint.setType(this.getEndpointType()); + endpoint.setGUID(endpointGUID); + endpoint.setQualifiedName(endpointName); + endpoint.setDisplayName(endpointName); + endpoint.setDescription(endpointDescription); + endpoint.setAddress(endpointAddress); + + + final String connectorTypeDescription = "OMRS default enterprise connector type."; + final String connectorTypeJavaClassName = KafkaOMRSTopicProvider.class.getName(); + + String connectorTypeName = "DefaultEnterpriseTopic.ConnectorType." + localServerName; + + ConnectorType connectorType = new ConnectorType(); + + connectorType.setType(this.getConnectorTypeType()); + connectorType.setGUID(connectorTypeGUID); + connectorType.setQualifiedName(connectorTypeName); + connectorType.setDisplayName(connectorTypeName); + connectorType.setDescription(connectorTypeDescription); + connectorType.setConnectorProviderClassName(connectorTypeJavaClassName); + + + final String connectionDescription = "OMRS default enterprise topic connection."; + + String connectionName = "DefaultEnterpriseTopic.Connection." + localServerName; + + Connection connection = new Connection(); + + connection.setType(this.getConnectionType()); + connection.setGUID(connectionGUID); + connection.setQualifiedName(connectionName); + connection.setDisplayName(connectionName); + connection.setDescription(connectionDescription); + connection.setEndpoint(endpoint); + connection.setConnectorType(connectorType); + + return connection; } - private Connection getAtlasLocalRepositoryLocalConnection() + + /** + * Return the connection for the OMRS topic for the named cohort. + * + * @param cohortName - name of the cohort + * @return Connection object + */ + private Connection getDefaultCohortOMRSTopicConnection(String cohortName) { - return null; + final String endpointGUID = "dca783a1-d5f9-44a8-b838-4de4d016303d"; + final String connectorTypeGUID = "32843dd8-2597-4296-831c-674af0d8b837"; + final String connectionGUID = "023bb1f3-03dd-47ae-b3bc-dce62e9c11cb"; + + final String endpointDescription = "OMRS default cohort topic endpoint."; + + String endpointAddress = defaultTopicRootName + defaultCohortTopicConnectorRootName + cohortName + defaultTopicLeafName; + String endpointName = "DefaultCohortTopic.Endpoint." + endpointAddress; + + Endpoint endpoint = new Endpoint(); + + endpoint.setType(this.getEndpointType()); + endpoint.setGUID(endpointGUID); + endpoint.setQualifiedName(endpointName); + endpoint.setDisplayName(endpointName); + endpoint.setDescription(endpointDescription); + endpoint.setAddress(endpointAddress); + + + final String connectorTypeDescription = "OMRS default cohort topic connector type."; + final String connectorTypeJavaClassName = KafkaOMRSTopicProvider.class.getName(); + + String connectorTypeName = "DefaultCohortTopic.ConnectorType." + cohortName; + + ConnectorType connectorType = new ConnectorType(); + + connectorType.setType(this.getConnectorTypeType()); + connectorType.setGUID(connectorTypeGUID); + connectorType.setQualifiedName(connectorTypeName); + connectorType.setDisplayName(connectorTypeName); + connectorType.setDescription(connectorTypeDescription); + connectorType.setConnectorProviderClassName(connectorTypeJavaClassName); + + + final String connectionDescription = "OMRS default cohort topic connection."; + + String connectionName = "DefaultCohortTopic.Connection." + cohortName; + + Connection connection = new Connection(); + + connection.setType(this.getConnectionType()); + connection.setGUID(connectionGUID); + connection.setQualifiedName(connectionName); + connection.setDisplayName(connectionName); + connection.setDescription(connectionDescription); + connection.setEndpoint(endpoint); + connection.setConnectorType(connectorType); + + return connection; } - private Connection getDefaultLocalRepositoryRemoteConnection(String localServerURL) + + /** + * Return the connection to the default registry store called localServerName.cohortName.registrystore. + * + * @param localServerName - name of the local server + * @param cohortName - name of the cohort + * @return Connection object + */ + private Connection getDefaultCohortRegistryConnection(String localServerName, String cohortName) { - return null; + final String endpointGUID = "8bf8f5fa-b5d8-40e1-a00e-e4a0c59fd6c0"; + final String connectorTypeGUID = "2e1556a3-908f-4303-812d-d81b48b19bab"; + final String connectionGUID = "b9af734f-f005-4085-9975-bf46c67a099a"; + + final String endpointDescription = "OMRS default cohort registry endpoint."; + + String endpointAddress = localServerName + "." + cohortName + ".registrystore"; + String endpointName = "DefaultCohortRegistry.Endpoint." + endpointAddress; + + Endpoint endpoint = new Endpoint(); + + endpoint.setType(this.getEndpointType()); + endpoint.setGUID(endpointGUID); + endpoint.setQualifiedName(endpointName); + endpoint.setDisplayName(endpointName); + endpoint.setDescription(endpointDescription); + endpoint.setAddress(endpointAddress); + + + final String connectorTypeDescription = "OMRS default cohort registry connector type."; + final String connectorTypeJavaClassName = FileBasedRegistryStoreProvider.class.getName(); + + String connectorTypeName = "DefaultCohortRegistry.ConnectorType." + localServerName + "." + cohortName; + + ConnectorType connectorType = new ConnectorType(); + + connectorType.setType(this.getConnectorTypeType()); + connectorType.setGUID(connectorTypeGUID); + connectorType.setQualifiedName(connectorTypeName); + connectorType.setDisplayName(connectorTypeName); + connectorType.setDescription(connectorTypeDescription); + connectorType.setConnectorProviderClassName(connectorTypeJavaClassName); + + + final String connectionDescription = "OMRS default cohort registry connection."; + + String connectionName = "DefaultCohortRegistry.Connection." + localServerName + "." + cohortName; + + Connection connection = new Connection(); + + connection.setType(this.getConnectionType()); + connection.setGUID(connectionGUID); + connection.setQualifiedName(connectionName); + connection.setDisplayName(connectionName); + connection.setDescription(connectionDescription); + connection.setEndpoint(endpoint); + connection.setConnectorType(connectorType); + + return connection; } - private Connection getDefaultEventMapperConnection() + + /** + * Return the protocol level to use for communications with local open metadata access services through the open metadata + * enterprise repository services. + * + * @return protocol version + */ + private OpenMetadataEventProtocolVersion getDefaultEnterpriseOMRSTopicProtocolVersion() { - return null; + return OpenMetadataEventProtocolVersion.V1; } - public Connection getGenericEventMapperConnection() + + /** + * Return the protocol level to use for communications with other members of the open metadata repository cohort. + * + * @return protocol version + */ + private OpenMetadataEventProtocolVersion getDefaultCohortOMRSTopicProtocolVersion() { - return null; + return OpenMetadataEventProtocolVersion.V1; } - private Connection getDefaultEnterpriseOMRSTopicConnection() { return null; } - private Connection getDefaultCohortOMRSTopicConnection () { return null; } + /** + * Return the exchange rule set so that events for all local repository changes are sent. + * + * @return exchange rule + */ + private OpenMetadataExchangeRule getDefaultEventsToSendRule() + { + return OpenMetadataExchangeRule.ALL; + } + - private Connection getDefaultCohortRegistryConnection () + /** + * Return the default list of types to send as a null because the exchange rule above is set to ALL. + * + * @return null array list + */ + private ArrayList<TypeDefSummary> getDefaultSelectedTypesToSend() { return null; } - private OpenMetadataEventProtocolVersion getDefaultEnterpriseOMRSTopicProtocolVersion() { return OpenMetadataEventProtocolVersion.V1; } - private OpenMetadataEventProtocolVersion getDefaultCohortOMRSTopicProtocolVersion() { return OpenMetadataEventProtocolVersion.V1; } - - private OpenMetadataExchangeRule getDefaultEventsToSendRule() + /** + * Return the exchange rule set so that all received events are saved. + * + * @return exchange rule + */ + private OpenMetadataExchangeRule getDefaultEventsToSaveRule() { return OpenMetadataExchangeRule.ALL; } - private ArrayList<TypeDefSummary> getDefaultSelectedTypesToSend() { return null; } - private OpenMetadataExchangeRule getDefaultEventsToSaveRule() + /** + * Return the default list of types to save as a null because the exchange rule above is set to ALL. + * + * @return null array list + */ + private ArrayList<TypeDefSummary> getDefaultSelectedTypesToSave() { - return OpenMetadataExchangeRule.ALL; + return null; } - private ArrayList<TypeDefSummary> getDefaultSelectedTypesToSave() { return null; } + /** + * Return the exchange rule set so that all incoming events are processed. + * + * @return exchange rule + */ private OpenMetadataExchangeRule getDefaultEventsToProcessRule() { return OpenMetadataExchangeRule.ALL; } - private ArrayList<TypeDefSummary> getDefaultSelectedTypesToProcess() { return null; } - private ArrayList<Connection> getDefaultOpenMetadataArchiveList() + /** + * Return the default list of types to process as a null because the exchange rule above is set to ALL. + * + * @return null array list + */ + private ArrayList<TypeDefSummary> getDefaultSelectedTypesToProcess() { - ArrayList<Connection> openMetadataArchiveList = new ArrayList<>(); - - openMetadataArchiveList.add(this.getDefaultOpenMetadataTypesArchiveConnection()); - - return openMetadataArchiveList; + return null; } - public LocalRepositoryConfig getDefaultLocalRepositoryConfig(String localServerURL) + + /** + * Returns the basic configuration for a local repository. + * + * @param localServerName - name of the local server + * @param localServerURL - URL root of local server used for REST calls + * @return LocalRepositoryConfig object + */ + private LocalRepositoryConfig getDefaultLocalRepositoryConfig(String localServerName, + String localServerURL) { - LocalRepositoryConfig localRepositoryConfig = new LocalRepositoryConfig(); + LocalRepositoryConfig localRepositoryConfig = new LocalRepositoryConfig(); localRepositoryConfig.setMetadataCollectionId(UUID.randomUUID().toString()); localRepositoryConfig.setLocalRepositoryLocalConnection(this.getDefaultLocalRepositoryLocalConnection()); - localRepositoryConfig.setLocalRepositoryRemoteConnection(this.getDefaultLocalRepositoryRemoteConnection(localServerURL)); + localRepositoryConfig.setLocalRepositoryRemoteConnection(this.getDefaultLocalRepositoryRemoteConnection( + localServerName, + localServerURL)); localRepositoryConfig.setEventsToSaveRule(this.getDefaultEventsToSaveRule()); localRepositoryConfig.setSelectedTypesToSave(this.getDefaultSelectedTypesToSave()); localRepositoryConfig.setEventsToSendRule(this.getDefaultEventsToSendRule()); @@ -193,13 +656,75 @@ public class OMRSConfigurationFactory return localRepositoryConfig; } - public EnterpriseAccessConfig getDefaultEnterpriseAccessConfig() + + /** + * Return the configuration for an in-memory local repository. + * + * @param localServerName - name of the local server + * @param localServerURL - URL root of local server used for REST calls + * @return LocalRepositoryConfig object + */ + public LocalRepositoryConfig getInMemoryLocalRepositoryConfig(String localServerName, String localServerURL) + { + LocalRepositoryConfig localRepositoryConfig = this.getDefaultLocalRepositoryConfig(localServerName, + localServerURL); + + localRepositoryConfig.setLocalRepositoryLocalConnection(this.getInMemoryLocalRepositoryLocalConnection( + localServerName)); + + return localRepositoryConfig; + } + + + /** + * Return the configuration for a local repository that is using the built-in graph repository. + * + * @param localServerName - name of local server + * @param localServerURL - URL root of local server used for REST calls + * @return LocalRepositoryConfig object + */ + public LocalRepositoryConfig getLocalGraphLocalRepositoryConfig(String localServerName, String localServerURL) + { + LocalRepositoryConfig localRepositoryConfig = this.getDefaultLocalRepositoryConfig(localServerName, + localServerURL); + + localRepositoryConfig.setLocalRepositoryLocalConnection(this.getLocalGraphRepositoryLocalConnection( + localServerName)); + + return localRepositoryConfig; + } + + + /** + * Return the local repository configuration for a repository proxy. + * + * @return LocalRepositoryConfig object + */ + public LocalRepositoryConfig getRepositoryProxyLocalRepositoryConfig(String localServerName, String localServerURL) + { + LocalRepositoryConfig localRepositoryConfig = this.getDefaultLocalRepositoryConfig(localServerName, + localServerURL); + + localRepositoryConfig.setLocalRepositoryLocalConnection(null); + + return localRepositoryConfig; + } + + + /** + * Return the default settings for the enterprise repository services' configuration. + * + * @param localServerName - name of the local server + * @return EnterpriseAccessConfig parameters + */ + public EnterpriseAccessConfig getDefaultEnterpriseAccessConfig(String localServerName) { - EnterpriseAccessConfig enterpriseAccessConfig = new EnterpriseAccessConfig(); + EnterpriseAccessConfig enterpriseAccessConfig = new EnterpriseAccessConfig(); enterpriseAccessConfig.setEnterpriseMetadataCollectionId(UUID.randomUUID().toString()); - enterpriseAccessConfig.setEnterpriseMetadataCollectionName(defaultEnterpriseMetadataCollectionName); - enterpriseAccessConfig.setEnterpriseOMRSTopicConnection(this.getDefaultEnterpriseOMRSTopicConnection()); + enterpriseAccessConfig.setEnterpriseMetadataCollectionName(localServerName + defaultEnterpriseMetadataCollectionName); + enterpriseAccessConfig.setEnterpriseOMRSTopicConnection(this.getDefaultEnterpriseOMRSTopicConnection( + localServerName)); enterpriseAccessConfig.setEnterpriseOMRSTopicProtocolVersion(this.getDefaultEnterpriseOMRSTopicProtocolVersion()); return enterpriseAccessConfig; @@ -209,15 +734,23 @@ public class OMRSConfigurationFactory /** * Return a CohortConfig object that is pre-configured with default values. * + * @param localServerName - name of the local server + * @param cohortName - name of the cohort * @return default values in a CohortConfig object */ - public CohortConfig getDefaultCohortConfig() + public CohortConfig getDefaultCohortConfig(String localServerName, String cohortName) { - CohortConfig cohortConfig = new CohortConfig(); + CohortConfig cohortConfig = new CohortConfig(); + String newCohortName = defaultCohortName; + + if (cohortName != null) + { + newCohortName = cohortName; + } - cohortConfig.setCohortName(defaultCohortName); - cohortConfig.setCohortRegistryConnection(this.getDefaultCohortRegistryConnection()); - cohortConfig.setCohortOMRSTopicConnection(this.getDefaultCohortOMRSTopicConnection()); + cohortConfig.setCohortName(newCohortName); + cohortConfig.setCohortRegistryConnection(this.getDefaultCohortRegistryConnection(localServerName, newCohortName)); + cohortConfig.setCohortOMRSTopicConnection(this.getDefaultCohortOMRSTopicConnection(newCohortName)); cohortConfig.setCohortOMRSTopicProtocolVersion(this.getDefaultCohortOMRSTopicProtocolVersion()); cohortConfig.setEventsToProcessRule(this.getDefaultEventsToProcessRule()); cohortConfig.setSelectedTypesToProcess(this.getDefaultSelectedTypesToProcess()); @@ -225,4 +758,110 @@ public class OMRSConfigurationFactory return cohortConfig; } + + /** + * Returns a repository services config with the audit log set up. + * + * @param localServerName - name of the local server + * @return minimally configured repository services config + */ + public RepositoryServicesConfig getDefaultRepositoryServicesConfig(String localServerName) + { + RepositoryServicesConfig repositoryServicesConfig = new RepositoryServicesConfig(); + + List<Connection> auditLogStoreConnections = new ArrayList<>(); + + auditLogStoreConnections.add(this.getDefaultAuditLogConnection(localServerName)); + + repositoryServicesConfig.setAuditLogConnections(auditLogStoreConnections); + + return repositoryServicesConfig; + } + + + /** + * Return the standard type for an endpoint. + * + * @return ElementType object + */ + public ElementType getEndpointType() + { + final String elementTypeId = "dbc20663-d705-4ff0-8424-80c262c6b8e7"; + final String elementTypeName = "Endpoint"; + final long elementTypeVersion = 1; + final String elementTypeDescription = "Description of the network address and related information needed to call a software service."; + final String elementAccessServiceURL = null; + final ElementOrigin elementOrigin = ElementOrigin.LOCAL_COHORT; + final String elementHomeMetadataCollectionId = null; + + ElementType elementType = new ElementType(); + + elementType.setElementTypeId(elementTypeId); + elementType.setElementTypeName(elementTypeName); + elementType.setElementTypeVersion(elementTypeVersion); + elementType.setElementTypeDescription(elementTypeDescription); + elementType.setElementAccessServiceURL(elementAccessServiceURL); + elementType.setElementOrigin(elementOrigin); + elementType.setElementHomeMetadataCollectionId(elementHomeMetadataCollectionId); + + return elementType; + } + + + /** + * Return the standard type for a connector type. + * + * @return ElementType object + */ + public ElementType getConnectorTypeType() + { + final String elementTypeId = "954421eb-33a6-462d-a8ca-b5709a1bd0d4"; + final String elementTypeName = "ConnectorType"; + final long elementTypeVersion = 1; + final String elementTypeDescription = "A set of properties describing a type of connector."; + final String elementAccessServiceURL = null; + final ElementOrigin elementOrigin = ElementOrigin.LOCAL_COHORT; + final String elementHomeMetadataCollectionId = null; + + ElementType elementType = new ElementType(); + + elementType.setElementTypeId(elementTypeId); + elementType.setElementTypeName(elementTypeName); + elementType.setElementTypeVersion(elementTypeVersion); + elementType.setElementTypeDescription(elementTypeDescription); + elementType.setElementAccessServiceURL(elementAccessServiceURL); + elementType.setElementOrigin(elementOrigin); + elementType.setElementHomeMetadataCollectionId(elementHomeMetadataCollectionId); + + return elementType; + } + + + /** + * Return the standard type for a connection type. + * + * @return ElementType object + */ + public ElementType getConnectionType() + { + final String elementTypeId = "114e9f8f-5ff3-4c32-bd37-a7eb42712253"; + final String elementTypeName = "Connection"; + final long elementTypeVersion = 1; + final String elementTypeDescription = "A set of properties to identify and configure a connector instance."; + final String elementAccessServiceURL = null; + final ElementOrigin elementOrigin = ElementOrigin.LOCAL_COHORT; + final String elementHomeMetadataCollectionId = null; + + ElementType elementType = new ElementType(); + + elementType.setElementTypeId(elementTypeId); + elementType.setElementTypeName(elementTypeName); + elementType.setElementTypeVersion(elementTypeVersion); + elementType.setElementTypeDescription(elementTypeDescription); + elementType.setElementAccessServiceURL(elementAccessServiceURL); + elementType.setElementOrigin(elementOrigin); + elementType.setElementHomeMetadataCollectionId(elementHomeMetadataCollectionId); + + return elementType; + } }