public static CdmOperationRenameAttributes FromData(CdmCorpusContext ctx, JToken obj)
        {
            if (obj == null)
            {
                return(null);
            }

            CdmOperationRenameAttributes renameAttributesOp = OperationBasePersistence.FromData <CdmOperationRenameAttributes>(ctx, CdmObjectType.OperationRenameAttributesDef, obj);

            renameAttributesOp.RenameFormat = obj["renameFormat"]?.ToString();

            if (obj["applyTo"] is JValue)
            {
                renameAttributesOp.ApplyTo = new List <string>
                {
                    (string)obj["applyTo"]
                };
            }
            else if (obj["applyTo"] is JArray applyToArray)
            {
                renameAttributesOp.ApplyTo = applyToArray.ToObject <List <string> >();
            }
            else if (obj["applyTo"] != null)
            {
                Logger.Error(nameof(OperationRenameAttributesPersistence), ctx, "Unsupported: applyTo property type should be string or List<string>.");
                return(null);
            }

            return(renameAttributesOp);
        }
Exemplo n.º 2
0
        public static CdmOperationRenameAttributes FromData(CdmCorpusContext ctx, JToken obj)
        {
            if (obj == null)
            {
                return(null);
            }

            CdmOperationRenameAttributes renameAttributesOp = OperationBasePersistence.FromData <CdmOperationRenameAttributes>(ctx, CdmObjectType.OperationRenameAttributesDef, obj);

            renameAttributesOp.RenameFormat = obj["renameFormat"]?.ToString();

            if (obj["applyTo"] is JValue)
            {
                renameAttributesOp.ApplyTo = new List <string>
                {
                    (string)obj["applyTo"]
                };
            }
            else if (obj["applyTo"] is JArray applyToArray)
            {
                renameAttributesOp.ApplyTo = applyToArray.ToObject <List <string> >();
            }
            else if (obj["applyTo"] != null)
            {
                Logger.Error((ResolveContext)ctx, Tag, nameof(FromData), null, CdmLogCode.ErrPersistProjUnsupportedProp);
                return(null);
            }

            return(renameAttributesOp);
        }
Exemplo n.º 3
0
        public static CdmOperationAlterTraits FromData(CdmCorpusContext ctx, JToken obj)
        {
            if (obj == null)
            {
                return(null);
            }

            CdmOperationAlterTraits alterTraitsOp = OperationBasePersistence.FromData <CdmOperationAlterTraits>(ctx, CdmObjectType.OperationAlterTraitsDef, obj);

            alterTraitsOp.TraitsToAdd               = Utils.CreateTraitReferenceList(ctx, obj["traitsToAdd"]);
            alterTraitsOp.TraitsToRemove            = Utils.CreateTraitReferenceList(ctx, obj["traitsToRemove"]);
            alterTraitsOp.ArgumentsContainWildcards = (bool?)obj["argumentsContainWildcards"];

            if (obj["applyTo"] is JValue)
            {
                alterTraitsOp.ApplyTo = new List <string>
                {
                    (string)obj["applyTo"]
                };
            }
            else if (obj["applyTo"] is JArray applyToArray)
            {
                alterTraitsOp.ApplyTo = applyToArray.ToObject <List <string> >();
            }
            else if (obj["applyTo"] != null)
            {
                Logger.Error((ResolveContext)ctx, Tag, nameof(FromData), null, CdmLogCode.ErrPersistProjUnsupportedProp, "applyTo", "string or list of strings");
                return(null);
            }

            return(alterTraitsOp);
        }
Exemplo n.º 4
0
        public static CdmOperationAddCountAttribute FromData(CdmCorpusContext ctx, JToken obj)
        {
            if (obj == null)
            {
                return(null);
            }

            CdmOperationAddCountAttribute addCountAttributeOp = OperationBasePersistence.FromData <CdmOperationAddCountAttribute>(ctx, CdmObjectType.OperationAddCountAttributeDef, obj);

            addCountAttributeOp.CountAttribute = Utils.CreateAttribute(ctx, obj["countAttribute"]) as CdmTypeAttributeDefinition;

            return(addCountAttributeOp);
        }
Exemplo n.º 5
0
        public static CdmOperationExcludeAttributes FromData(CdmCorpusContext ctx, JToken obj)
        {
            if (obj == null)
            {
                return(null);
            }

            CdmOperationExcludeAttributes excludeAttributesOp = OperationBasePersistence.FromData <CdmOperationExcludeAttributes>(ctx, CdmObjectType.OperationExcludeAttributesDef, obj);

            excludeAttributesOp.ExcludeAttributes = obj["excludeAttributes"]?.ToObject <List <string> >();

            return(excludeAttributesOp);
        }
        public static CdmOperationAddAttributeGroup FromData(CdmCorpusContext ctx, JToken obj)
        {
            if (obj == null)
            {
                return(null);
            }

            CdmOperationAddAttributeGroup addAttributeGroupOp = OperationBasePersistence.FromData <CdmOperationAddAttributeGroup>(ctx, CdmObjectType.OperationAddAttributeGroupDef, obj);

            addAttributeGroupOp.AttributeGroupName = obj["attributeGroupName"]?.ToString();

            return(addAttributeGroupOp);
        }
Exemplo n.º 7
0
        public static CdmOperationCombineAttributes FromData(CdmCorpusContext ctx, JToken obj)
        {
            if (obj == null)
            {
                return(null);
            }

            CdmOperationCombineAttributes combineAttributesOp = OperationBasePersistence.FromData <CdmOperationCombineAttributes>(ctx, CdmObjectType.OperationCombineAttributesDef, obj);

            combineAttributesOp.Select    = obj["select"]?.ToObject <List <string> >();
            combineAttributesOp.MergeInto = Utils.CreateAttribute(ctx, obj["mergeInto"]) as CdmTypeAttributeDefinition;

            return(combineAttributesOp);
        }
        public static CdmOperationArrayExpansion FromData(CdmCorpusContext ctx, JToken obj)
        {
            if (obj == null)
            {
                return(null);
            }

            CdmOperationArrayExpansion arrayExpansionOp = OperationBasePersistence.FromData <CdmOperationArrayExpansion>(ctx, CdmObjectType.OperationArrayExpansionDef, obj);

            arrayExpansionOp.StartOrdinal = (int?)obj["startOrdinal"];
            arrayExpansionOp.EndOrdinal   = (int?)obj["endOrdinal"];

            return(arrayExpansionOp);
        }
Exemplo n.º 9
0
        public static CdmOperationAddArtifactAttribute FromData(CdmCorpusContext ctx, JToken obj)
        {
            if (obj == null)
            {
                return(null);
            }

            CdmOperationAddArtifactAttribute addArtifactAttributeOp = OperationBasePersistence.FromData <CdmOperationAddArtifactAttribute>(ctx, CdmObjectType.OperationAddArtifactAttributeDef, obj);

            addArtifactAttributeOp.NewAttribute = Utils.CreateAttribute(ctx, obj["newAttribute"]);
            addArtifactAttributeOp.InsertAtTop  = (bool?)obj["insertAtTop"];

            return(addArtifactAttributeOp);
        }
        public static CdmOperationReplaceAsForeignKey FromData(CdmCorpusContext ctx, JToken obj)
        {
            if (obj == null)
            {
                return(null);
            }

            CdmOperationReplaceAsForeignKey replaceAsForeignKeyOp = OperationBasePersistence.FromData <CdmOperationReplaceAsForeignKey>(ctx, CdmObjectType.OperationReplaceAsForeignKeyDef, obj);

            replaceAsForeignKeyOp.Reference   = obj["reference"]?.ToString();
            replaceAsForeignKeyOp.ReplaceWith = Utils.CreateAttribute(ctx, obj["replaceWith"]) as CdmTypeAttributeDefinition;

            return(replaceAsForeignKeyOp);
        }