Search in sources :

Example 1 with InstanceProperties

use of org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties in project egeria-connector-sas-viya by odpi.

the class AttributeMapping method addPrimitivePropertyToInstance.

/**
 * Retrieves a simple Java object representation for the provided OMRS InstancePropertyValue.
 *
 * @param omrsValue the OMRS value to translate
 * @return Object
 *
 *    static Object getValueFromInstance(InstancePropertyValue omrsValue,
 *                                       String omrsTypeDefName,
 *                                       AttributeTypeDefStore attributeDefStore) {
 *
 *        Object value = null;
 *
 *        switch (omrsValue.getInstancePropertyCategory()) {
 *            case PRIMITIVE:
 *                PrimitivePropertyValue primitivePropertyValue = (PrimitivePropertyValue) omrsValue;
 *                value = primitivePropertyValue.getPrimitiveValue();
 *                break;
 *            case MAP:
 *                MapPropertyValue mapPropertyValue = (MapPropertyValue) omrsValue;
 *                InstanceProperties mapValues = mapPropertyValue.getMapValues();
 *                if (mapValues != null) {
 *                    Map<String, InstancePropertyValue> mapOfValues = mapValues.getInstanceProperties();
 *                    if (mapOfValues != null) {
 *                        Map<String, Object> mappedValues = new HashMap<>();
 *                        for (Map.Entry<String, InstancePropertyValue> entry : mapOfValues.entrySet()) {
 *                            String entryName = entry.getKey();
 *                            InstancePropertyValue entryValue = entry.getValue();
 *                            mappedValues.put(entryName, getValueFromInstance(entryValue, omrsTypeDefName, attributeDefStore));
 *                        }
 *                        value = mappedValues;
 *                    }
 *                }
 *                break;
 *            case ENUM:
 *                Map<String, String> enumElementMap = attributeDefStore.getElementMappingsForOMRSTypeDef(omrsTypeDefName);
 *                EnumPropertyValue enumPropertyValue = (EnumPropertyValue) omrsValue;
 *                value = enumElementMap.get(enumPropertyValue.getSymbolicName());
 *                break;
 *            case ARRAY:
 *                ArrayPropertyValue arrayPropertyValue = (ArrayPropertyValue) omrsValue;
 *                InstanceProperties arrayValues = arrayPropertyValue.getArrayValues();
 *                if (arrayValues != null) {
 *                    Map<String, InstancePropertyValue> arrayOfValues = arrayValues.getInstanceProperties();
 *                    if (arrayOfValues != null) {
 *                        List<Object> mappedValues = new ArrayList<>(arrayValues.getPropertyCount());
 *                        for (Map.Entry<String, InstancePropertyValue> entry : arrayOfValues.entrySet()) {
 *                            String entryKey = entry.getKey();
 *                            int entryIndex  = Integer.parseInt(entryKey);
 *                            InstancePropertyValue entryValue = entry.getValue();
 *                            mappedValues.set(entryIndex, getValueFromInstance(entryValue, omrsTypeDefName, attributeDefStore));
 *                        }
 *                        value = mappedValues;
 *                    }
 *                }
 *                break;
 *            default:
 *                log.warn("Unhandled type for mapping: {}", omrsValue);
 *                break;
 *        }
 *
 *        return value;
 *
 *    }
 */
/**
 * Add the supplied property to an instance properties object.  If the instance property object
 * supplied is null, a new instance properties object is created.
 *
 * @param omrsRepositoryHelper the OMRS repository helper
 * @param sourceName  name of caller
 * @param properties  properties object to add property to may be null.
 * @param property  the property
 * @param propertyValue  value of property
 * @param methodName  calling method name
 * @return instance properties object.
 */
private static InstanceProperties addPrimitivePropertyToInstance(OMRSRepositoryHelper omrsRepositoryHelper, String sourceName, InstanceProperties properties, TypeDefAttribute property, Object propertyValue, String methodName) {
    InstanceProperties resultingProperties = properties;
    if (propertyValue != null) {
        String propertyName = property.getAttributeName();
        log.debug("Adding property {} for {}", propertyName, methodName);
        if (property.getAttributeType().getCategory() == AttributeTypeDefCategory.PRIMITIVE) {
            try {
                PrimitiveDef primitiveDef = (PrimitiveDef) property.getAttributeType();
                switch(primitiveDef.getPrimitiveDefCategory()) {
                    case OM_PRIMITIVE_TYPE_BOOLEAN:
                        boolean booleanValue;
                        if (propertyValue instanceof Boolean) {
                            booleanValue = (Boolean) propertyValue;
                        } else {
                            booleanValue = Boolean.valueOf(propertyValue.toString());
                        }
                        resultingProperties = omrsRepositoryHelper.addBooleanPropertyToInstance(sourceName, properties, propertyName, booleanValue, methodName);
                        break;
                    case OM_PRIMITIVE_TYPE_INT:
                        int intValue;
                        if (propertyValue instanceof Integer) {
                            intValue = (Integer) propertyValue;
                        } else if (propertyValue instanceof Number) {
                            intValue = ((Number) propertyValue).intValue();
                        } else {
                            intValue = Integer.valueOf(propertyValue.toString());
                        }
                        resultingProperties = omrsRepositoryHelper.addIntPropertyToInstance(sourceName, properties, propertyName, intValue, methodName);
                        break;
                    case OM_PRIMITIVE_TYPE_LONG:
                        long longValue;
                        if (propertyValue instanceof Long) {
                            longValue = (Long) propertyValue;
                        } else if (propertyValue instanceof Number) {
                            longValue = ((Number) propertyValue).longValue();
                        } else {
                            longValue = Long.valueOf(propertyValue.toString());
                        }
                        resultingProperties = omrsRepositoryHelper.addLongPropertyToInstance(sourceName, properties, propertyName, longValue, methodName);
                        break;
                    case OM_PRIMITIVE_TYPE_FLOAT:
                        float floatValue;
                        if (propertyValue instanceof Float) {
                            floatValue = (Float) propertyValue;
                        } else if (propertyValue instanceof Number) {
                            floatValue = ((Number) propertyValue).floatValue();
                        } else {
                            floatValue = Float.valueOf(propertyValue.toString());
                        }
                        resultingProperties = omrsRepositoryHelper.addFloatPropertyToInstance(sourceName, properties, propertyName, floatValue, methodName);
                        break;
                    case OM_PRIMITIVE_TYPE_STRING:
                        String stringValue;
                        if (propertyValue instanceof String) {
                            stringValue = (String) propertyValue;
                        } else {
                            stringValue = propertyValue.toString();
                        }
                        resultingProperties = omrsRepositoryHelper.addStringPropertyToInstance(sourceName, properties, propertyName, stringValue, methodName);
                        break;
                    case OM_PRIMITIVE_TYPE_DATE:
                        Date date;
                        if (propertyValue instanceof Date) {
                            date = (Date) propertyValue;
                        } else if (propertyValue instanceof String && ((String) propertyValue).matches("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{2,3}Z")) {
                            // Timestamp is ISO-8601
                            // https://stackoverflow.com/a/60214805
                            TemporalAccessor ta = DateTimeFormatter.ISO_INSTANT.parse((String) propertyValue);
                            date = Date.from(Instant.from(ta));
                        } else {
                            date = new Date((Long) propertyValue);
                        }
                        resultingProperties = omrsRepositoryHelper.addDatePropertyToInstance(sourceName, properties, propertyName, date, methodName);
                        break;
                    default:
                        log.error("Unhandled primitive type {} for {}", primitiveDef.getPrimitiveDefCategory(), propertyName);
                }
            } catch (ClassCastException e) {
                log.error("Unable to cast {} to {} for {}", propertyValue, property.getAttributeType(), propertyName);
            } catch (NumberFormatException e) {
                log.warn("Unable to convert {} to {} for {}", propertyValue, property.getAttributeType(), propertyName);
            }
        } else {
            log.error("Cannot translate non-primitive property {} this way.", propertyName);
        }
    } else {
        log.debug("Null property");
    }
    return resultingProperties;
}
Also used : TemporalAccessor(java.time.temporal.TemporalAccessor) InstanceProperties(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties) Date(java.util.Date) BigInteger(java.math.BigInteger) PrimitiveDef(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.PrimitiveDef)

Example 2 with InstanceProperties

use of org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties in project egeria-connector-sas-viya by odpi.

the class EntityMappingSASCatalog2OMRS method getEntityDetail.

/**
 * Retrieve the mapped OMRS EntityDetail from the sas EntityInstance used to
 * construct this mapping object.
 *
 * @return EntityDetail
 * @throws RepositoryErrorException when unable to retrieve the EntityDetail
 */
public EntityDetail getEntityDetail() throws RepositoryErrorException {
    final String attribute = "attribute";
    final String methodName = "getEntityDetail";
    String sasTypeDefName = sasEntity.getTypeName();
    String omrsTypeDefName = typeDefStore.getMappedOMRSTypeDefName(sasTypeDefName, prefix);
    log.info("Found mapped type for Sas type '{}' with prefix '{}': {}", sasTypeDefName, prefix, omrsTypeDefName);
    EntityDetail detail = null;
    if (omrsTypeDefName != null) {
        // Create the basic skeleton
        detail = getSkeletonEntityDetail(omrsTypeDefName, prefix);
        // Then apply the instance-specific mapping
        if (detail != null) {
            InstanceProperties instanceProperties = new InstanceProperties();
            Map<String, String> additionalProperties = new HashMap<>();
            OMRSRepositoryHelper omrsRepositoryHelper = sasRepositoryConnector.getRepositoryHelper();
            String repositoryName = sasRepositoryConnector.getRepositoryName();
            Map<String, TypeDefAttribute> omrsAttributeMap = typeDefStore.getAllTypeDefAttributesForName(omrsTypeDefName);
            // Iterate through the provided mappings to set an OMRS instance property for
            // each one
            Map<String, String> sasToOmrsProperties = typeDefStore.getPropertyMappingsForCatalogTypeDef(sasTypeDefName, prefix);
            if (sasEntity != null) {
                Set<String> alreadyMapped = new HashSet<>();
                for (Map.Entry<String, String> property : sasToOmrsProperties.entrySet()) {
                    String sasProperty = property.getKey();
                    String omrsProperty = property.getValue();
                    // If omrsProperty is of the form "additionalProperties.xxxxx" then extract
                    // "xxxxx" as the
                    // name of the property to add under additionalProperties (and extract value and
                    // actually
                    // add the entry in the following IF block
                    String additionalPropertyName = "";
                    if (omrsProperty.startsWith(OMRSPROPERTY_ADDITIONALPROPERTIES_PREFIX)) {
                        additionalPropertyName = omrsProperty.substring(OMRSPROPERTY_ADDITIONALPROPERTIES_PREFIX.length());
                    }
                    if (sasProperty.startsWith(SASPROPERTY_CONSTANT_PREFIX)) {
                        String constantVal = sasProperty.substring(SASPROPERTY_CONSTANT_PREFIX.length());
                        log.info("Adding constant value: '" + constantVal + "' for property " + omrsProperty);
                        if (StringUtils.isNotEmpty(additionalPropertyName)) {
                            additionalProperties.put(additionalPropertyName, constantVal);
                        } else {
                            instanceProperties = omrsRepositoryHelper.addStringPropertyToInstance(repositoryName, instanceProperties, omrsProperty, constantVal, methodName);
                        }
                    } else if (StringUtils.isNotEmpty(additionalPropertyName)) {
                        log.info("Mapping {} to additionalProperties '{}'", sasProperty, omrsProperty);
                        Object propertyValue = sasEntity.get(sasProperty);
                        if (propertyValue != null) {
                            additionalProperties.put(additionalPropertyName, propertyValue.toString());
                        } else {
                            log.warn("Null property value for SAS property '{}'.", sasProperty);
                        }
                    } else if (omrsAttributeMap.containsKey(omrsProperty)) {
                        log.info("Mapping {} to {}", sasProperty, omrsProperty);
                        TypeDefAttribute typeDefAttribute = omrsAttributeMap.get(omrsProperty);
                        instanceProperties = AttributeMapping.addPropertyToInstance(omrsRepositoryHelper, repositoryName, typeDefAttribute, instanceProperties, sasEntity.get(sasProperty), methodName);
                        if (instanceProperties.getPropertyValue(omrsProperty) != null) {
                            if (sasProperty.startsWith(attribute)) {
                                sasProperty = sasProperty.substring(attribute.length());
                            }
                            alreadyMapped.add(sasProperty);
                        }
                    } else {
                        log.warn("No OMRS attribute {} defined for asset type {} -- skipping mapping.", omrsProperty, omrsTypeDefName);
                    }
                }
                // And map any other simple (non-relationship) properties that are not otherwise
                // mapped into 'additionalProperties'
                Set<String> nonRelationshipSet = sasEntity.getAttributes().keySet();
                // Remove all of the already-mapped properties from our list of non-relationship
                // properties
                nonRelationshipSet.removeAll(alreadyMapped);
                // to strings (even arrays of values, we'll concatenate into a single string)
                for (String propertyName : nonRelationshipSet) {
                    Object propertyValue = sasEntity.getAttributes().get(propertyName);
                    if (propertyValue != null) {
                        additionalProperties.put(propertyName, propertyValue.toString());
                    }
                }
                // and finally setup the 'additionalProperties' attribute using this map
                instanceProperties = omrsRepositoryHelper.addStringMapPropertyToInstance(repositoryName, instanceProperties, "additionalProperties", additionalProperties, methodName);
            }
            detail.setProperties(instanceProperties);
            // TODO: detail.setReplicatedBy();
            addClassifications(detail);
        }
    } else {
        log.warn("No mapping defined from Sas type '{}' with prefix '{}'", sasTypeDefName, prefix);
    }
    return detail;
}
Also used : TypeDefAttribute(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefAttribute) InstanceProperties(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties) HashMap(java.util.HashMap) OMRSRepositoryHelper(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper) EntityDetail(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 3 with InstanceProperties

use of org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties in project egeria-connector-sas-viya by odpi.

the class RelationshipMapping method getRelationship.

/**
 * Create a mapped relationship based on the provided criteria
 *
 * @param SASRelationshipType the type of the SAS relationship to map
 * @param ep1 the proxy to map to endpoint 1
 * @param ep2 the proxy to map to endpoint 2
 * @return Relationship
 * @throws RepositoryErrorException when unable to map the Relationship
 */
private Relationship getRelationship(String SASRelationshipType, EntityProxy ep1, EntityProxy ep2) throws RepositoryErrorException {
    final String methodName = "getRelationship";
    OMRSRepositoryHelper omrsRepositoryHelper = SASRepositoryConnector.getRepositoryHelper();
    String repositoryName = SASRepositoryConnector.getRepositoryName();
    // String omrsRelationshipType = typeDefStore.getMappedOMRSTypeDefName(SASRelationshipType, sasCatalogGuid.getGeneratedPrefix());
    Map<String, String> relPrefixes = typeDefStore.getMappedOMRSTypeDefNameWithPrefixes(SASRelationshipType);
    // My understanding is for Entity types there should be just one mapping
    // This understanding may need to be revisited.
    String omrsRelationshipType = null;
    for (Map.Entry<String, String> entry : relPrefixes.entrySet()) {
        omrsRelationshipType = entry.getValue();
    }
    InstanceStatus omrsRelationshipStatus = InstanceStatus.ACTIVE;
    Map<String, Object> SASRelationshipProperties = relationship.getAttributes();
    InstanceProperties omrsRelationshipProperties = new InstanceProperties();
    if (SASRelationshipProperties != null) {
        Map<String, TypeDefAttribute> relationshipAttributeMap = typeDefStore.getAllTypeDefAttributesForName(omrsRelationshipType);
        Map<String, String> SASToOmrsProperties = typeDefStore.getPropertyMappingsForCatalogTypeDef(SASRelationshipType, sasCatalogGuid.getGeneratedPrefix());
        if (SASToOmrsProperties != null) {
            for (Map.Entry<String, String> property : SASToOmrsProperties.entrySet()) {
                String SASProperty = property.getKey();
                String omrsProperty = property.getValue();
                if (relationshipAttributeMap.containsKey(omrsProperty)) {
                    TypeDefAttribute typeDefAttribute = relationshipAttributeMap.get(omrsProperty);
                    omrsRelationshipProperties = AttributeMapping.addPropertyToInstance(omrsRepositoryHelper, repositoryName, typeDefAttribute, omrsRelationshipProperties, /*attributeDefStore,*/
                    SASRelationshipProperties.get(SASProperty), methodName);
                } else {
                    log.warn("No OMRS attribute {} defined for asset type {} -- skipping mapping.", omrsProperty, omrsRelationshipType);
                }
            }
        }
    }
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'");
    try {
        return RelationshipMapping.getRelationship(SASRepositoryConnector, typeDefStore, omrsRelationshipType, sasCatalogGuid, omrsRelationshipStatus, ep1, ep2, (String) relationship.get("instance.createdBy"), (String) relationship.get("instance.modifiedBy"), format.parse((String) relationship.get("instance.creationTimeStamp")), format.parse((String) relationship.get("instance.modifiedTimeStamp")), omrsRelationshipProperties);
    } catch (ParseException e) {
        log.error("Could not parse relationship timestamp");
        return null;
    }
}
Also used : TypeDefAttribute(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefAttribute) InstanceProperties(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties) OMRSRepositoryHelper(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper) InstanceStatus(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceStatus) ParseException(java.text.ParseException) Map(java.util.Map) SimpleDateFormat(java.text.SimpleDateFormat)

Example 4 with InstanceProperties

use of org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties in project egeria-connector-sas-viya by odpi.

the class SequencingUtils method getEntityDetailComparator.

public static Comparator<EntityDetail> getEntityDetailComparator(SequencingOrder sequencingOrder, String sequencingProperty) {
    Comparator<EntityDetail> comparator = null;
    if (sequencingOrder != null) {
        switch(sequencingOrder) {
            case GUID:
                comparator = Comparator.comparing(EntityDetail::getGUID);
                break;
            case LAST_UPDATE_OLDEST:
                comparator = Comparator.comparing(EntityDetail::getUpdateTime);
                break;
            case LAST_UPDATE_RECENT:
                comparator = Comparator.comparing(EntityDetail::getUpdateTime).reversed();
                break;
            case CREATION_DATE_OLDEST:
                comparator = Comparator.comparing(EntityDetail::getCreateTime);
                break;
            case CREATION_DATE_RECENT:
                comparator = Comparator.comparing(EntityDetail::getCreateTime).reversed();
                break;
            case PROPERTY_ASCENDING:
                if (sequencingProperty != null) {
                    comparator = (a, b) -> {
                        InstanceProperties p1 = a.getProperties();
                        InstanceProperties p2 = b.getProperties();
                        InstancePropertyValue v1 = null;
                        InstancePropertyValue v2 = null;
                        if (p1 != null) {
                            v1 = p1.getPropertyValue(sequencingProperty);
                        }
                        if (p2 != null) {
                            v2 = p2.getPropertyValue(sequencingProperty);
                        }
                        return AttributeMapping.compareInstanceProperty(v1, v2);
                    };
                }
                break;
            case PROPERTY_DESCENDING:
                if (sequencingProperty != null) {
                    comparator = (b, a) -> {
                        InstanceProperties p1 = a.getProperties();
                        InstanceProperties p2 = b.getProperties();
                        InstancePropertyValue v1 = null;
                        InstancePropertyValue v2 = null;
                        if (p1 != null) {
                            v1 = p1.getPropertyValue(sequencingProperty);
                        }
                        if (p2 != null) {
                            v2 = p2.getPropertyValue(sequencingProperty);
                        }
                        return AttributeMapping.compareInstanceProperty(v1, v2);
                    };
                }
                break;
            default:
                // Do nothing -- no sorting
                break;
        }
    }
    return comparator;
}
Also used : InstancePropertyValue(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstancePropertyValue) InstanceProperties(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties) EntityDetail(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail)

Example 5 with InstanceProperties

use of org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties in project egeria-connector-sas-viya by odpi.

the class MetadataCollection method findEntitiesByPropertyValue.

@Override
public List<EntityDetail> findEntitiesByPropertyValue(String userId, String entityTypeGUID, String searchCriteria, int fromEntityElement, List<InstanceStatus> limitResultsByStatus, List<String> limitResultsByClassification, Date asOfTime, String sequencingProperty, SequencingOrder sequencingOrder, int pageSize) throws InvalidParameterException, TypeErrorException, RepositoryErrorException, PropertyErrorException, PagingErrorException, FunctionNotSupportedException, UserNotAuthorizedException {
    final String methodName = "findEntitiesByPropertyValue";
    findEntitiesByPropertyValueParameterValidation(userId, entityTypeGUID, searchCriteria, fromEntityElement, limitResultsByStatus, limitResultsByClassification, asOfTime, sequencingProperty, sequencingOrder, pageSize);
    List<Instance> results = new ArrayList<Instance>();
    // Immediately throw unimplemented exception if trying to retrieve historical view
    if (asOfTime != null) {
        raiseFunctionNotSupportedException(ErrorCode.NO_HISTORY, methodName, repositoryName);
    }
    // Search criteria is not allowed to be empty for this method, so cannot be null or empty string.
    if (!searchCriteria.isEmpty()) {
        // Otherwise we need to do an OR-based search across all string properties in Atlas, using whatever the
        // regex of searchCriteria contains for each property
        // Add all textual properties of the provided entity as matchProperties,
        // for an OR-based search of their values
        Map<String, Map<String, String>> mappingsToSearch = new HashMap<>();
        if (entityTypeGUID != null) {
            // We are searching for a particular entity type, get the associated mappings
            mappingsToSearch = getMappingsToSearch(entityTypeGUID, userId);
        } else {
            // We are searching across all entity types, get all mappings
            // We will need to send the request only once, so we'll only use the first mapping
            mappingsToSearch = typeDefStore.getAllOmrsNameToCatalogNameMappings();
        }
        for (Map.Entry<String, Map<String, String>> entryToSearch : mappingsToSearch.entrySet()) {
            InstanceProperties matchProperties = new InstanceProperties();
            String omrsTypeName = entryToSearch.getKey();
            String omrsTypeGUID = typeDefStore.getTypeDefByName(omrsTypeName).getGUID();
            Map<String, TypeDefAttribute> typeDefAttributeMap = typeDefStore.getAllTypeDefAttributesForName(omrsTypeName);
            if (typeDefAttributeMap != null) {
                // This will look at all OMRS attributes, but buildAndRunDSLSearch (later) should limit to only those mapped to catalog
                for (Map.Entry<String, TypeDefAttribute> attributeEntry : typeDefAttributeMap.entrySet()) {
                    String attributeName = attributeEntry.getKey();
                    // Only supporting search by name value for now
                    if (attributeName.equals("qualifiedName")) {
                        TypeDefAttribute typeDefAttribute = attributeEntry.getValue();
                        // Only need to retain string-based attributes for the full text search
                        AttributeTypeDef attributeTypeDef = typeDefAttribute.getAttributeType();
                        if (attributeTypeDef.getCategory().equals(AttributeTypeDefCategory.PRIMITIVE)) {
                            PrimitiveDefCategory primitiveDefCategory = ((PrimitiveDef) attributeTypeDef).getPrimitiveDefCategory();
                            if (primitiveDefCategory.equals(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING) || primitiveDefCategory.equals(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_BYTE) || primitiveDefCategory.equals(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_CHAR)) {
                                matchProperties = repositoryHelper.addStringPropertyToInstance(repositoryName, matchProperties, attributeName, searchCriteria, methodName);
                            } else {
                                log.debug("Skipping inclusion of non-string attribute: {}", attributeName);
                            }
                        } else {
                            log.debug("Skipping inclusion of non-string attribute: {}", attributeName);
                        }
                    }
                }
            }
            List<Instance> innerResults = new ArrayList<Instance>();
            try {
                innerResults = buildAndRunDSLSearch(methodName, entityTypeGUID, omrsTypeGUID, limitResultsByClassification, matchProperties, MatchCriteria.ANY, fromEntityElement, limitResultsByStatus, sequencingProperty, sequencingOrder, pageSize, userId);
            } catch (Exception e) {
                log.error("Exception from findEntitiesByPropertyValue inner search for omrsTypeName {}: {}", omrsTypeName, e.getMessage());
            }
            if (innerResults != null) {
                results.addAll(innerResults);
            }
            // so can break out of the loop
            if (entityTypeGUID == null) {
                break;
            }
        }
    }
    List<EntityDetail> entityDetails = null;
    if (results != null) {
        entityDetails = sortAndLimitFinalResults(results, entityTypeGUID, fromEntityElement, sequencingProperty, sequencingOrder, pageSize, userId);
    }
    return (entityDetails == null || entityDetails.isEmpty()) ? null : entityDetails;
}
Also used : InstanceProperties(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties) Instance(org.odpi.openmetadata.connector.sas.event.model.catalog.instance.Instance) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TypeDefNotSupportedException(org.odpi.openmetadata.repositoryservices.ffdc.exception.TypeDefNotSupportedException) FunctionNotSupportedException(org.odpi.openmetadata.repositoryservices.ffdc.exception.FunctionNotSupportedException) TypeDefConflictException(org.odpi.openmetadata.repositoryservices.ffdc.exception.TypeDefConflictException) TypeDefKnownException(org.odpi.openmetadata.repositoryservices.ffdc.exception.TypeDefKnownException) PagingErrorException(org.odpi.openmetadata.repositoryservices.ffdc.exception.PagingErrorException) RelationshipNotKnownException(org.odpi.openmetadata.repositoryservices.ffdc.exception.RelationshipNotKnownException) PropertyErrorException(org.odpi.openmetadata.repositoryservices.ffdc.exception.PropertyErrorException) InvalidTypeDefException(org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidTypeDefException) EntityNotKnownException(org.odpi.openmetadata.repositoryservices.ffdc.exception.EntityNotKnownException) TypeErrorException(org.odpi.openmetadata.repositoryservices.ffdc.exception.TypeErrorException) UserNotAuthorizedException(org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException) RepositoryErrorException(org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException) InvalidParameterException(org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException) EntityDetail(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

InstanceProperties (org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties)8 ParseException (java.text.ParseException)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Map (java.util.Map)3 EntityDetail (org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail)3 OMRSRepositoryHelper (org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper)3 HashMap (java.util.HashMap)2 EntityProxy (org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityProxy)2 InstancePropertyValue (org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstancePropertyValue)2 Relationship (org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship)2 TypeDefAttribute (org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefAttribute)2 TypeErrorException (org.odpi.openmetadata.repositoryservices.ffdc.exception.TypeErrorException)2 BigInteger (java.math.BigInteger)1 TemporalAccessor (java.time.temporal.TemporalAccessor)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 Instance (org.odpi.openmetadata.connector.sas.event.model.catalog.instance.Instance)1 SASCatalogGuid (org.odpi.openmetadata.connector.sas.repository.connector.model.SASCatalogGuid)1 AttributeTypeDefStore (org.odpi.openmetadata.connector.sas.repository.connector.stores.AttributeTypeDefStore)1