All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.odpi.openmetadata.commonservices.generichandlers.PortBuilder Maven / Gradle / Ivy

Go to download

Common services for managing OMAS bean mappings to OMRS API objects as well as asset visibility through supported zones and calls to the Open Metadata Security Verifier.

There is a newer version: 5.1
Show newest version
/* SPDX-License-Identifier: Apache-2.0 */
/* Copyright Contributors to the ODPi Egeria project. */
package org.odpi.openmetadata.commonservices.generichandlers;

import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper;
import org.odpi.openmetadata.repositoryservices.ffdc.exception.TypeErrorException;

import java.util.Map;


/**
 * PortBuilder is able to build the properties for a Port entity.
 */
public class PortBuilder extends ReferenceableBuilder
{
    private final String displayName;
    private final int    portType;


    /**
     * Constructor used for constructing search arguments.
     *
     * @param qualifiedName unique name
     * @param displayName short name of the port
     * @param portType direction of data flow
     * @param additionalProperties additional properties
     * @param typeGUID unique identifier of the specific type for the port (should always be set)
     * @param typeName unique name of the specific type for the port (should always be set)
     * @param extendedProperties  properties from the subtype
     * @param repositoryHelper helper methods
     * @param serviceName name of this OMAS
     * @param serverName name of local server
     */
    public PortBuilder(String               qualifiedName,
                       String               displayName,
                       int                  portType,
                       Map  additionalProperties,
                       String               typeGUID,
                       String               typeName,
                       Map  extendedProperties,
                       OMRSRepositoryHelper repositoryHelper,
                       String               serviceName,
                       String               serverName)
    {
        super(qualifiedName,
              additionalProperties,
              typeGUID,
              typeName,
              extendedProperties,
              repositoryHelper,
              serviceName,
              serverName);

        this.displayName = displayName;
        this.portType = portType;
    }


    /**
     * Return the supplied bean properties in an InstanceProperties object.
     *
     * @param methodName name of the calling method
     * @return InstanceProperties object
     * @throws InvalidParameterException there is a problem with the properties
     */
    @Override
    public InstanceProperties getInstanceProperties(String  methodName) throws InvalidParameterException
    {
        InstanceProperties properties = super.getInstanceProperties(methodName);

        properties = repositoryHelper.addStringPropertyToInstance(serviceName,
                                                                  properties,
                                                                  OpenMetadataAPIMapper.DISPLAY_NAME_PROPERTY_NAME,
                                                                  displayName,
                                                                  methodName);


        try
        {
            properties = repositoryHelper.addEnumPropertyToInstance(serviceName,
                                                                    properties,
                                                                    OpenMetadataAPIMapper.PORT_TYPE_PROPERTY_NAME,
                                                                    OpenMetadataAPIMapper.PORT_TYPE_ENUM_TYPE_GUID,
                                                                    OpenMetadataAPIMapper.PORT_TYPE_ENUM_TYPE_NAME,
                                                                    portType,
                                                                    methodName);
        }
        catch (TypeErrorException error)
        {
            errorHandler.handleUnsupportedType(error, methodName, OpenMetadataAPIMapper.PORT_TYPE_ENUM_TYPE_NAME);
        }

        return properties;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy