Search in sources :

Example 1 with SoftIdFieldRef

use of org.talend.mdm.commmon.metadata.SoftIdFieldRef in project tmdm-common by Talend.

the class ForeignKeyProcessor method getFieldMetadata.

private static FieldMetadata getFieldMetadata(MetadataRepository repository, ComplexTypeMetadata type, Element appInfo, String path, boolean isFKInfo) {
    String typeName = getTypeName(type, path);
    // $NON-NLS-1$
    String fieldPath = StringUtils.substringAfter(path, "/").trim();
    FieldMetadata fieldMetadata;
    if (!fieldPath.isEmpty() && isFKInfo) {
        fieldMetadata = new SoftFieldRef(repository, fieldPath, typeName);
    } else {
        if (!fieldPath.isEmpty() && (repository.getComplexType(typeName) == null || repository.getComplexType(typeName).getKeyFields().size() == 1)) {
            fieldMetadata = new SoftFieldRef(repository, fieldPath, typeName);
        } else {
            // If the reference entity has composite key, the foreign key field should be set as entity not its ID.
            fieldMetadata = new SoftIdFieldRef(repository, typeName);
        }
    }
    fieldMetadata.setData(MetadataRepository.XSD_LINE_NUMBER, XSDParser.getStartLine(appInfo));
    fieldMetadata.setData(MetadataRepository.XSD_COLUMN_NUMBER, XSDParser.getStartColumn(appInfo));
    fieldMetadata.setData(MetadataRepository.XSD_DOM_ELEMENT, appInfo);
    return fieldMetadata;
}
Also used : SoftFieldRef(org.talend.mdm.commmon.metadata.SoftFieldRef) FieldMetadata(org.talend.mdm.commmon.metadata.FieldMetadata) SoftIdFieldRef(org.talend.mdm.commmon.metadata.SoftIdFieldRef)

Aggregations

FieldMetadata (org.talend.mdm.commmon.metadata.FieldMetadata)1 SoftFieldRef (org.talend.mdm.commmon.metadata.SoftFieldRef)1 SoftIdFieldRef (org.talend.mdm.commmon.metadata.SoftIdFieldRef)1