CreateDataAttribute() публичный Метод

public CreateDataAttribute ( string shortName, string name, string description, bool isMultiValue, bool isBuiltIn, string scope, MeasurementScale measurementScale, DataContainerType containerType, string entitySelectionPredicate, DataType dataType, Unit unit, Methodology methodology, Classifier classifier, ICollection functions, ICollection globalizationInfos, ICollection constraints, ICollection extendedProperies ) : DataAttribute
shortName string
name string
description string
isMultiValue bool
isBuiltIn bool
scope string
measurementScale MeasurementScale
containerType DataContainerType
entitySelectionPredicate string
dataType BExIS.Dlm.Entities.DataStructure.DataType
unit BExIS.Dlm.Entities.DataStructure.Unit
methodology BExIS.Dlm.Entities.DataStructure.Methodology
classifier BExIS.Dlm.Entities.DataStructure.Classifier
functions ICollection
globalizationInfos ICollection
constraints ICollection
extendedProperies ICollection
Результат BExIS.Dlm.Entities.DataStructure.DataAttribute
Пример #1
0
        public MessageModel storeAtttribute(long Id, string Name, long unitId, long dataTypeId, string Description = "", string cssId = "", bool inUse = false)
        {
            Name = Server.UrlDecode(Name);
            Description = Server.UrlDecode(Description);
            MessageModel DataStructureValidation = MessageModel.validateAttributeInUse(Id);
            if (DataStructureValidation.hasMessage && inUse == false)
            {
                return DataStructureValidation;
            }
            else
            {
                DataStructureValidation = MessageModel.validateAttributeName(Id, Name, cssId);
                if (DataStructureValidation.hasMessage)
                {
                    return DataStructureValidation;
                }
                else
                {
                    DataContainerManager dataAttributeManager = new DataContainerManager();
                    DataAttribute dataAttribute;

                    if (Id == 0)
                    {
                        Unit unit = new UnitManager().Repo.Get(unitId);
                        DataType dataType = new DataTypeManager().Repo.Get(dataTypeId);
                        dataAttribute = dataAttributeManager.CreateDataAttribute(Name, Name, Description, false, false, "", MeasurementScale.Categorial, DataContainerType.ReferenceType, "", dataType, unit, null, null, null, null, null, null);
                        return new MessageModel()
                        {
                            Message = dataAttribute.Id.ToString(),
                            hasMessage = false,
                            CssId = "refresh"
                        };
                    }
                    else
                    {
                        dataAttribute = dataAttributeManager.DataAttributeRepo.Get(Id);
                        dataAttribute.Name = Name;
                        dataAttribute.Description = Description;
                        dataAttribute = dataAttributeManager.UpdateDataAttribute(dataAttribute);
                        return new MessageModel()
                        {
                            Message = Id.ToString(),
                            hasMessage = false,
                            CssId = "refresh"
                        };
                    }
                }
            }
        }
Пример #2
0
        public ActionResult editAttribute(DataAttributeModel Model)
        {
            ViewBag.Title = PresentationModel.GetViewTitleForTenant( "Manage Data Attributes", this.Session.GetTenant());
            DataContainerManager dataAttributeManager = new DataContainerManager();
            IList<DataAttribute> DataAttributeList = dataAttributeManager.DataAttributeRepo.Get();
            long tempUnitId = Convert.ToInt64(Model.Unit.Id);
            long tempDataTypeId = Convert.ToInt64(Model.DataType.Id);

            Model.Id = Model.Id;
            Model.ShortName = cutSpaces(Model.ShortName);
            Model.Name = cutSpaces(Model.Name);
            Model.Description = cutSpaces(Model.Description);

            //if (Model.DomainConstraints.Count > 0)
            //{
            //    if (Model.DomainConstraints. != null && Model.DomainItems.Count > 0)
            //    {
            //        Model.DomainConstraints.FirstOrDefault().DomainItems = clearEmptyItems(Model.DomainItems);
            //    }
            //}

            if (Model.Name == "" | Model.Name == null)
            {
                Session["nameMsg"] = "invalid Name";
                Session["Window"] = true;
                return View("AttributeManager", new DataAttributeManagerModel(Model));
            }
            else
            {
                bool nameNotExist = DataAttributeList.Where(p => p.Name.ToLower().Equals(Model.Name.ToLower())).Count().Equals(0);

                if (Model.Id == 0)
                {
                    if (nameNotExist)
                    {
                        UnitManager UM = new UnitManager();
                        Unit unit = new Unit();
                        DataTypeManager DTM = new DataTypeManager();
                        DataType dataType = new DataType();
                        DataContainerManager DAM = new DataContainerManager();

                        DataAttribute temp = new DataAttribute();

                        if(UM.Repo.Get(tempUnitId)!= null)
                            unit = UM.Repo.Get(tempUnitId);
                        else
                            unit = UM.Repo.Get().Where(u => u.Name.ToLower() == "none").FirstOrDefault();

                        if (DTM.Repo.Get(tempDataTypeId) != null)
                            dataType = DTM.Repo.Get(tempDataTypeId);
                        else
                            dataType = DTM.Repo.Get().ToList().FirstOrDefault();

                        temp = DAM.CreateDataAttribute(Model.ShortName, Model.Name, Model.Description, false, false, "", MeasurementScale.Categorial, DataContainerType.ReferenceType, "", dataType, unit, null, null, null, null, null, null);

                        #region store constraint

                        if (Model.RangeConstraints.Count > 0 && (Model.RangeConstraints.FirstOrDefault().Min !=null || Model.RangeConstraints.FirstOrDefault().Max !=null)
                            && (Model.RangeConstraints.FirstOrDefault().Min != 0.0 || Model.RangeConstraints.FirstOrDefault().Max != 0.0 ))
                            temp = storeConstraint(Model.RangeConstraints.First(), temp);

                        if (Model.PatternConstraints.Count > 0 && !String.IsNullOrEmpty(Model.PatternConstraints.FirstOrDefault().MatchingPhrase))
                            temp = storeConstraint(Model.PatternConstraints.First(), temp);

                        if (Model.DomainConstraints.Count > 0)
                        {
                            foreach (DomainConstraintModel d in Model.DomainConstraints)
                            {
                                temp = storeConstraint(d, temp);
                            }
                        }

                        #endregion

                        temp = DAM.UpdateDataAttribute(temp);
                    }
                    else
                    {
                        Session["nameMsg"] = "Name already exist";
                        Session["Window"] = true;
                        return View("AttributeManager", new DataAttributeManagerModel(Model));
                    }
                }
                else
                {
                    if (nameNotExist || DataAttributeList.Where(p => p.Name.Equals(Model.Name)).ToList().First().Id == Model.Id)
                    {
                        DataAttribute dataAttribute = DataAttributeList.Where(p => p.Id.Equals(Model.Id)).ToList().First();
                        if (!attributeInUse(dataAttribute))
                        {
                            DataContainerManager DAM = new DataContainerManager();
                            dataAttribute.Name = cutSpaces(Model.Name);
                            dataAttribute.ShortName = Model.ShortName;
                            dataAttribute.Description = Model.Description;
                            UnitManager UM = new UnitManager();

                            if (UM.Repo.Get(tempUnitId) != null)
                                dataAttribute.Unit = UM.Repo.Get(tempUnitId);
                            else
                                dataAttribute.Unit = UM.Repo.Get().Where(u => u.Name.ToLower() == "none").FirstOrDefault();

                            DataTypeManager DTM = new DataTypeManager();

                            if (DTM.Repo.Get(tempDataTypeId) != null)
                                dataAttribute.DataType = DTM.Repo.Get(tempDataTypeId);
                            else
                                dataAttribute.DataType = DTM.Repo.Get().ToList().FirstOrDefault();

                            #region store constraint

                            if (Model.RangeConstraints.Count > 0 && (Model.RangeConstraints.FirstOrDefault().Min != null || Model.RangeConstraints.FirstOrDefault().Max != null)
                                && (Model.RangeConstraints.FirstOrDefault().Min != 0.0 || Model.RangeConstraints.FirstOrDefault().Max != 0.0))
                                dataAttribute = storeConstraint(Model.RangeConstraints.First(), dataAttribute);
                            else
                                dataAttribute = deletConstraint(Model.RangeConstraints.First().Id, dataAttribute);

                            if (Model.PatternConstraints.Count > 0 && !String.IsNullOrEmpty(Model.PatternConstraints.FirstOrDefault().MatchingPhrase))
                                dataAttribute = storeConstraint(Model.PatternConstraints.First(), dataAttribute);
                            else
                                dataAttribute = deletConstraint(Model.PatternConstraints.First().Id, dataAttribute);

                            if (Model.PatternConstraints.Count > 0 && !String.IsNullOrEmpty(Model.DomainConstraints.FirstOrDefault().Terms))
                                dataAttribute = storeConstraint(Model.DomainConstraints.First(), dataAttribute);
                            else
                                dataAttribute = deletConstraint(Model.DomainConstraints.First().Id, dataAttribute);

                            #endregion
                            DAM.UpdateDataAttribute(dataAttribute);
                        }
                    }
                    else
                    {
                        Session["nameMsg"] = "Name already exist";
                        Session["Window"] = true;
                        return View("AttributeManager", new DataAttributeManagerModel(Model));
                    }
                }
            }

            Session["Window"] = false;
            return RedirectToAction("AttributeManager");
        }
Пример #3
0
        // create read attributes in bpp
        public void CreateAttributes(ref DataTable mappedAttributes)
        {
            foreach (DataRow mapAttributesRow in mappedAttributes.Rows)
            {
                DataContainerManager attributeManager = new DataContainerManager();
                DataTypeManager dataTypeManager = new DataTypeManager();
                UnitManager unitManager = new UnitManager();
                DataAttribute attribute = new DataAttribute();

                // values of the attribute
                attribute.ShortName = mapAttributesRow["ShortName"].ToString();
                attribute.Name = mapAttributesRow["Name"].ToString();
                attribute.Description = mapAttributesRow["Description"].ToString();
                attribute.IsMultiValue = false;
                attribute.IsBuiltIn = false;
                //attribute.Owner = "BMM";
                attribute.Scope = "";
                attribute.MeasurementScale = MeasurementScale.Categorial; ////////!!!!!!!!fromMapping??????????????????
                attribute.ContainerType = DataContainerType.ReferenceType;
                attribute.EntitySelectionPredicate = "";
                attribute.DataType = dataTypeManager.Repo.Get(Convert.ToInt64(mapAttributesRow["DataTypeId"]));
                attribute.Unit = unitManager.Repo.Get(Convert.ToInt64(mapAttributesRow["UnitId"]));
                attribute.Methodology = null;
                attribute.Classification = null;
                attribute.AggregateFunctions = null;
                attribute.GlobalizationInfos = null;
                attribute.Constraints = null;
                attribute.ExtendedProperties = null;

                DataAttribute dataAttribute = new DataAttribute();
                DataAttribute existAttribute = attributeManager.DataAttributeRepo.Get(a =>
                    attribute.Name.Equals(a.Name) &&
                    attribute.ShortName.Equals(a.ShortName) &&
                    attribute.Unit.Id.Equals(a.Unit.Id) &&
                    attribute.DataType.Id.Equals(a.DataType.Id)
                    ).FirstOrDefault();

                // if attribute not exists (name, shortName) then create
                if (existAttribute == null)
                {
                    dataAttribute = attributeManager.CreateDataAttribute(
                        attribute.ShortName,
                        attribute.Name,
                        attribute.Description,
                        attribute.IsMultiValue,
                        attribute.IsBuiltIn,
                        attribute.Scope,
                        attribute.MeasurementScale,
                        attribute.ContainerType,
                        attribute.EntitySelectionPredicate,
                        attribute.DataType,
                        attribute.Unit,
                        attribute.Methodology,
                        attribute.Classification,
                        attribute.AggregateFunctions,
                        attribute.GlobalizationInfos,
                        attribute.Constraints,
                        attribute.ExtendedProperties
                        );
                }
                else
                {
                    dataAttribute = existAttribute;
                }

                // add attributeId to the mappedAttributes Table
                mapAttributesRow["AttributeId"] = dataAttribute.Id;
            }
        }