Search in sources :

Example 1 with SoftFieldRef

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

the class PermissionValidationRule method getFieldMetadata.

private FieldMetadata getFieldMetadata(Element appInfo, String fieldName) {
    FieldMetadata fieldMetadata = new SoftFieldRef(null, fieldName, "");
    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) ContainedTypeFieldMetadata(org.talend.mdm.commmon.metadata.ContainedTypeFieldMetadata)

Example 2 with SoftFieldRef

use of org.talend.mdm.commmon.metadata.SoftFieldRef 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)2 SoftFieldRef (org.talend.mdm.commmon.metadata.SoftFieldRef)2 ContainedTypeFieldMetadata (org.talend.mdm.commmon.metadata.ContainedTypeFieldMetadata)1 SoftIdFieldRef (org.talend.mdm.commmon.metadata.SoftIdFieldRef)1