private static ProjectionAttributeStateSet CreateNewProjectionAttributeStateSet( ProjectionContext projCtx, ProjectionAttributeStateSet projOutputSet, ResolvedAttribute newResAttrFK, string refAttrName) { List <ProjectionAttributeState> pasList = ProjectionResolutionCommonUtil.GetLeafList(projCtx, refAttrName); if (pasList != null) { // update the new foreign key resolved attribute with trait param with reference details ResolvedTrait reqdTrait = newResAttrFK.ResolvedTraits.Find(projCtx.ProjectionDirective.ResOpt, "is.linkedEntity.identifier"); if (reqdTrait != null) { CdmEntityReference traitParamEntRef = ProjectionResolutionCommonUtil.CreateForeignKeyLinkedEntityIdentifierTraitParameter(projCtx.ProjectionDirective, projOutputSet.Ctx.Corpus, pasList); reqdTrait.ParameterValues.SetParameterValue(projCtx.ProjectionDirective.ResOpt, "entityReferences", traitParamEntRef); } // Create new output projection attribute state set for FK and add prevPas as previous state set ProjectionAttributeState newProjAttrStateFK = new ProjectionAttributeState(projOutputSet.Ctx) { CurrentResolvedAttribute = newResAttrFK, PreviousStateList = pasList }; projOutputSet.Add(newProjAttrStateFK); } else { // Log error & return projOutputSet without any change Logger.Error(TAG, projOutputSet.Ctx, $"Unable to locate state for reference attribute \"{refAttrName}\".", nameof(CreateNewProjectionAttributeStateSet)); } return(projOutputSet); }
private static ProjectionAttributeStateSet CreateNewProjectionAttributeStateSet( ProjectionContext projCtx, ProjectionAttributeStateSet projOutputSet, ResolvedAttribute newResAttrFK, string refAttrName) { List <ProjectionAttributeState> pasList = ProjectionResolutionCommonUtil.GetLeafList(projCtx, refAttrName); string sourceEntity = projCtx.ProjectionDirective.OriginalSourceAttributeName; if (sourceEntity == null) { Logger.Warning(projOutputSet.Ctx, Tag, nameof(CreateNewProjectionAttributeStateSet), null, CdmLogCode.WarnProjFKWithoutSourceEntity, refAttrName); } if (pasList != null) { // update the new foreign key resolved attribute with trait param with reference details ResolvedTrait reqdTrait = newResAttrFK.ResolvedTraits.Find(projCtx.ProjectionDirective.ResOpt, "is.linkedEntity.identifier"); if (reqdTrait != null && sourceEntity != null) { CdmEntityReference traitParamEntRef = ProjectionResolutionCommonUtil.CreateForeignKeyLinkedEntityIdentifierTraitParameter(projCtx.ProjectionDirective, projOutputSet.Ctx.Corpus, pasList); reqdTrait.ParameterValues.SetParameterValue(projCtx.ProjectionDirective.ResOpt, "entityReferences", traitParamEntRef); } // Create new output projection attribute state set for FK and add prevPas as previous state set ProjectionAttributeState newProjAttrStateFK = new ProjectionAttributeState(projOutputSet.Ctx) { CurrentResolvedAttribute = newResAttrFK, PreviousStateList = pasList }; projOutputSet.Add(newProjAttrStateFK); } else { // Log error & return projOutputSet without any change Logger.Error(projOutputSet.Ctx, Tag, nameof(CreateNewProjectionAttributeStateSet), null, CdmLogCode.ErrProjRefAttrStateFailure, refAttrName); } return(projOutputSet); }