Example #1
0
        public static void SetMatchingCategories(this CobieObject retType, IEnumerable <Category> matchingCategories)
        {
            var categories = matchingCategories as Category[] ?? matchingCategories.ToArray();

            retType.SetMatchingClassifications(categories.Select(x => x.Classification));
            retType.SetMatchingCodes(categories.Select(x => x.Code));
        }
Example #2
0
        private DataRow GetRow(CobieObject parentAssetType, CobieObject runningAsset)
        {
            var r = AttributesGrid.NewRow();

            var isInserting = FillRow(parentAssetType.Attributes, r);

            if (!isInserting)
            {
                return(null);
            }

            isInserting = FillRow(runningAsset.Attributes, r);
            if (!isInserting)
            {
                return(null);
            }

            r[DpowAssetNameColumnName]           = runningAsset.Name;
            r[DpowAssetExternalSystemColumnName] = runningAsset.ExternalSystem;
            r[DpowAssetExternalIdColumnName]     = runningAsset.ExternalId;

            r[DpowAssetTypeNameColumnName]           = parentAssetType.Name;
            r[DpowAssetTypeExternalSystemColumnName] = parentAssetType.ExternalSystem;
            r[DpowAssetTypeExternalIdColumnName]     = parentAssetType.ExternalId;
            return(r);
        }
Example #3
0
        private static void SetIntegerValue(CobieObject retType, int value, string propertyName, string propertyDescription)
        {
            if (retType.Attributes == null)
            {
                retType.Attributes = new List <Attribute>();
            }

            var existingAttribute =
                retType.Attributes.FirstOrDefault(
                    a => a.Name == propertyName && a.PropertySetName == AttributesPropertySetName);

            if (existingAttribute != null)
            {
                existingAttribute.Value = new IntegerAttributeValue {
                    Value = value
                };
            }
            else
            {
                var matchingClassAttribute = new Attribute
                {
                    Name            = propertyName,
                    PropertySetName = AttributesPropertySetName,
                    Description     = propertyDescription,
                    Value           = new IntegerAttributeValue {
                        Value = value
                    },
                    Categories = new List <Category> {
                        DpowValidatedAttributeClass
                    }
                };
                retType.Attributes.Add(matchingClassAttribute);
            }
        }
Example #4
0
 static public void SetRequirementExternalSystem(this CobieObject retType, string value)
 {
     if (retType == null)
     {
         return;
     }
     SetStringValue(retType, value, RequirementExternalSystemAttributeName, "ExternalSystem of the requirement group.");
 }
Example #5
0
 static public void SetValidChildrenCount(this CobieObject retType, int value)
 {
     if (retType == null)
     {
         return;
     }
     SetIntegerValue(retType, value, ValidChildrenAttributeName, "Count of submitted items that satisfy requirements.");
 }
Example #6
0
 static public void SetRequirementName(this CobieObject retType, string value)
 {
     if (retType == null)
     {
         return;
     }
     SetStringValue(retType, value, RequirementNameAttributeName, "Name of the requirement group.");
 }
Example #7
0
 static public void SetSubmittedChildrenCount(this CobieObject retType, int value)
 {
     if (retType == null)
     {
         return;
     }
     SetIntegerValue(retType, value, SubmittedChildrenAttributeName, "Count of submitted items.");
 }
Example #8
0
        internal override void WriteToCobie(IWorkbook workbook, TextWriter loger, CobieObject parent,
                                            Dictionary <Type, int> rowNumCache, List <string> pickValuesCache, Dictionary <string, int> headerCache, string version = "UK2012")
        {
            base.WriteToCobie(workbook, loger, parent, rowNumCache, pickValuesCache, headerCache, version);

            //write metadata out
            if (Metadata != null)
            {
                Metadata.WriteToCobie(workbook, loger, version);
            }
        }
Example #9
0
        public static List <T> GetChildObjects <T>(this CobieObject obj)
        {
            if (obj.GetType() == typeof(AssetType))
            {
                return(((AssetType)obj).Assets as List <T>);
            }
            if (obj.GetType() == typeof(Zone))
            {
                return(((Zone)obj).SpaceObjects.ToList() as List <T>);
            }

            return(null);
        }
Example #10
0
        /// <summary>
        /// Test Property Set Names against sheets
        /// </summary>
        /// <param name="testStr">Name string to test</param>
        /// <param name="parent">Parent object</param>
        /// <returns>bool</returns>
        public bool PSetNameFilterOnSheetName(string testStr, CobieObject parent = null)
        {
            bool result = false;

            if (!string.IsNullOrEmpty(testStr))
            {
                result = CommonFilter.PSetNameFilter(testStr);
                if (!result)
                {
                    if (parent == null)
                    {
                        result = false;
                    }
                    else if ((parent is Zone) && (ZoneFilter != null))
                    {
                        result = ZoneFilter.PSetNameFilter(testStr);
                    }
                    else if ((parent is AssetType) && (TypeFilter != null))
                    {
                        result = TypeFilter.PSetNameFilter(testStr);
                    }
                    else if ((parent is Space) && (SpaceFilter != null))
                    {
                        result = SpaceFilter.PSetNameFilter(testStr);
                    }
                    else if ((parent is Floor) && (FloorFilter != null))
                    {
                        result = FloorFilter.PSetNameFilter(testStr);
                    }
                    else if ((parent is Facility) && (FacilityFilter != null))
                    {
                        result = FacilityFilter.PSetNameFilter(testStr);
                    }
                    else if ((parent is Spare) && (SpareFilter != null))
                    {
                        result = SpareFilter.PSetNameFilter(testStr);
                    }
                    else if ((parent is Asset) && (ComponentFilter != null))
                    {
                        result = ComponentFilter.PSetNameFilter(testStr);
                    }
                    else
                    {
                        result = false;
                    }
                }
            }
            //don't flip property sets as this excludes all the attributes, so we do not see attribute name exclusions as all property sets get excluded
            //return FlipResult ? !result : result;
            return(result);
        }
Example #11
0
        public static IEnumerable <Category> GetMatchingCategories(this CobieObject retType)
        {
            var cls   = retType.GetMatchingClassifications().GetEnumerator();
            var codes = retType.GetMatchingCodes().GetEnumerator();

            while (cls.MoveNext() && codes.MoveNext())
            {
                yield return(new Category
                {
                    Classification = cls.Current,
                    Code = codes.Current
                });
            }
        }
Example #12
0
        /// <summary>
        /// Write the text to the TextWriter
        /// </summary>
        /// <param name="logMe">string to write</param>
        public void WriteLine(CobieObject rootObj, CobieObject parentObj, Type mergeType, int duplicateNo, int mergedNo, int depthIndicator)
        {
            if (logger != null)
            {
                string        mergeindicator = (mergedNo > 0) ? "*" : "";
                StringBuilder sb             = new StringBuilder();
                if (mergedNo > 0)
                {
                    sb.Append("*");
                }
                else
                {
                    sb.Append(" ");
                }

                if (depthIndicator > 0)
                {
                    sb.Append('\t', depthIndicator);
                }

                if (rootObj != null && (depthIndicator == 0))
                {
                    sb.Append(rootObj.GetType().Name);
                    sb.Append("(");
                    sb.Append(rootObj.Name);
                    sb.Append(":");
                    sb.Append(rootObj.ExternalId);
                    sb.Append("): ");
                }

                if (parentObj != null)
                {
                    sb.Append(parentObj.GetType().Name);
                    sb.Append("(");
                    sb.Append(parentObj.Name);
                    sb.Append(":");
                    sb.Append(parentObj.ExternalId);
                    sb.Append("): ");
                }

                sb.Append(mergeType.Name);
                sb.Append(" ");
                sb.Append(duplicateNo);
                sb.Append(" duplicate, ");
                sb.Append(mergedNo);
                sb.Append(" merged.");
                logger.WriteLine(sb.ToString());
            }
        }
Example #13
0
        //TODO: IfcProperty filterining on IfcObjects

        /// <summary>
        /// Test property Names against sheets
        /// </summary>
        /// <param name="testStr">Name string to test</param>
        /// <param name="parent">Parent object</param>
        /// <returns>bool</returns>
        public bool NameFilterOnParent(string testStr, CobieObject parent = null)
        {
            var result = false;

            if (!string.IsNullOrEmpty(testStr))
            {
                result = CommonFilter.NameFilter(testStr);
                if (!result)
                {
                    if (parent == null)
                    {
                        result = false;
                    }
                    else if ((parent is Zone) && (ZoneFilter != null))
                    {
                        result = ZoneFilter.NameFilter(testStr);
                    }
                    else if ((parent is AssetType) && (TypeFilter != null))
                    {
                        result = TypeFilter.NameFilter(testStr);
                    }
                    else if ((parent is Space) && (SpaceFilter != null))
                    {
                        result = SpaceFilter.NameFilter(testStr);
                    }
                    else if ((parent is Floor) && (FloorFilter != null))
                    {
                        result = FloorFilter.NameFilter(testStr);
                    }
                    else if ((parent is Facility) && (FacilityFilter != null))
                    {
                        result = FacilityFilter.NameFilter(testStr);
                    }
                    else if ((parent is Spare) && (SpareFilter != null))
                    {
                        result = SpareFilter.NameFilter(testStr);
                    }
                    else if ((parent is Asset) && (ComponentFilter != null))
                    {
                        result = ComponentFilter.NameFilter(testStr);
                    }
                    else
                    {
                        result = false;
                    }
                }
            }
            return(FlipResult ? !result : result);
        }
Example #14
0
        public static IEnumerable <Category> GetRequirementCategories(this CobieObject retType)
        {
            var cls   = retType.GetRequirementClassifications().GetEnumerator();
            var codes = retType.GetRequirementCodes().GetEnumerator();
            var descs = retType.GetRequirementDescs().GetEnumerator();

            while (cls.MoveNext() && codes.MoveNext() && descs.MoveNext())
            {
                yield return(new Category
                {
                    Classification = cls.Current,
                    Code = codes.Current,
                    Description = descs.Current
                });
            }
        }
Example #15
0
        public static StatusOptions ValidationResult(this CobieObject obj)
        {
            if (obj.Categories == null)
            {
                return(StatusOptions.Invalid);
            }
            var firstCat =
                obj.Categories.FirstOrDefault(
                    c => c.Classification == @"DPoW" && (c.Code == "Passed" || c.Code == "Failed"));

            if (firstCat == null)
            {
                return(StatusOptions.Invalid);
            }
            return(firstCat.Code == "Passed"
                ? StatusOptions.Passed
                : StatusOptions.Failed);
        }
Example #16
0
        private static string GetStringValue(CobieObject retType, string attributeName)
        {
            if (retType.Attributes == null)
            {
                return("");
            }

            var existingAttribute =
                retType.Attributes.FirstOrDefault(
                    a => a.Name == attributeName && a.PropertySetName == AttributesPropertySetName);

            if (existingAttribute == null)
            {
                return("");
            }

            var stringValue = existingAttribute.Value as StringAttributeValue;

            return(stringValue == null
                ? @""
                : stringValue.Value);
        }
Example #17
0
        /// <summary>
        /// Filter IfcProduct and IfcTypeObject types
        /// </summary>
        /// <param name="obj">CobieObject</param>
        /// <param name="parent">Parent object</param>
        /// <param name="preDefinedType">strings for the ifcTypeObject predefinedtype enum property</param>
        /// <returns>bool, true = exclude</returns>
        public bool ObjFilter(CobieObject obj, CobieObject parent = null, string preDefinedType = null)
        {
            bool exclude = false;

            if (!string.IsNullOrEmpty(obj.ExternalEntity))
            {
                if (obj is Asset)
                {
                    exclude = IfcProductFilter.ItemsFilter(obj.ExternalEntity);
                    //check the element is not defined by a type which is excluded, by default if no type, then no element included
                    if (!exclude && parent is AssetType)
                    {
                        exclude = IfcTypeObjectFilter.ItemsFilter(parent.ExternalEntity, preDefinedType);
                    }
                }
                else if (obj is AssetType)
                {
                    exclude = IfcTypeObjectFilter.ItemsFilter(obj.ExternalEntity, preDefinedType);
                }
            }
            return(FlipResult ? !exclude : exclude);
        }
Example #18
0
        private static int GetIntegerValue(CobieObject retType, string attributeName)
        {
            if (retType.Attributes == null)
            {
                return(0);
            }

            var existingAttribute =
                retType.Attributes.FirstOrDefault(
                    a => a.Name == attributeName && a.PropertySetName == AttributesPropertySetName);

            if (existingAttribute == null)
            {
                return(0);
            }

            var integerValue = existingAttribute.Value as IntegerAttributeValue;

            return(integerValue == null || !integerValue.Value.HasValue
                ? 0
                : integerValue.Value.Value);
        }
Example #19
0
        private static IEnumerable <string> GetStringListFromCompound(CobieObject retType, string p)
        {
            if (retType.Attributes == null)
            {
                return(Enumerable.Empty <string>());
            }

            var existingAttribute =
                retType.Attributes.FirstOrDefault(
                    a => a.Name == p && a.PropertySetName == AttributesPropertySetName);

            if (existingAttribute == null)
            {
                return(Enumerable.Empty <string>());
            }

            var compoundStringValue = existingAttribute.Value as StringAttributeValue;

            return(compoundStringValue == null
                ? Enumerable.Empty <string>()
                : compoundStringValue.Value.CompoundStringToList());
        }
Example #20
0
        private static void SetListToCompoundAttribute(CobieObject retType, IEnumerable <string> list, string propName,
                                                       string description)
        {
            if (retType.Attributes == null)
            {
                retType.Attributes = new List <Attribute>();
            }

            var existingAttribute =
                retType.Attributes.FirstOrDefault(
                    a => a.Name == propName && a.PropertySetName == AttributesPropertySetName);

            var newValue = list.ListToCompoundString();

            if (existingAttribute != null)
            {
                existingAttribute.Value = new StringAttributeValue
                {
                    Value = newValue
                };
            }
            else
            {
                var matchingClassAttribute = new Attribute
                {
                    Name            = propName,
                    PropertySetName = AttributesPropertySetName,
                    Description     = description,
                    Value           = new StringAttributeValue {
                        Value = newValue
                    },
                    Categories = new List <Category> {
                        DpowValidatedAttributeClass
                    }
                };
                retType.Attributes.Add(matchingClassAttribute);
            }
        }
Example #21
0
 public static void SetChildObjects <TChild>(this CobieObject obj, List <TChild> newChildrenSet)
 {
     if (obj.GetType() == typeof(AssetType))
     {
         ((AssetType)obj).Assets = newChildrenSet as List <Asset>;
     }
     else if (obj.GetType() == typeof(Zone))
     {
         var destZone = obj as Zone;
         if (destZone == null)
         {
             return;
         }
         destZone.Spaces = new List <SpaceKey>(); // since this is a setter it's ok to create new.
         var destFaclity = destZone.Facility;
         if (destFaclity.Floors == null)          // we dont' wipe floors away, only prepare if it's null
         {
             destFaclity.Floors = new List <Floor>();
         }
         var tmpStorey = destFaclity.Get <Floor>(fl => fl.Name == @"DPoWTemporaryHoldingStorey").FirstOrDefault();
         if (tmpStorey == null)
         {
             tmpStorey        = destFaclity.Create <Floor>();
             tmpStorey.Name   = FacilityValidator.TemporaryFloorName;
             tmpStorey.Spaces = new List <Space>();
             destFaclity.Floors.Add(tmpStorey);
         }
         foreach (var child in newChildrenSet.OfType <Space>())
         {
             // add reference to the space in the zone
             destZone.Spaces.Add(new SpaceKey {
                 Name = child.Name
             });
             // the outer function will then ensure that floor and spaces are avalialale in the report facility
             tmpStorey.Spaces.Add(child);
         }
     }
 }
Example #22
0
        private static void SetRequirementClassifications(this CobieObject retType, IEnumerable <string> matchingCategories)
        {
            const string description = "Comma separated classification names applicable to the validation requirement.";

            SetListToCompoundAttribute(retType, matchingCategories, RequirementCategoriesAttributeName, description);
        }
Example #23
0
        private static void SetMatchingClassifications(this CobieObject retType, IEnumerable <string> matchingCategories)
        {
            const string description = "Comma separated values of the validation candidate that match a classification requirement.";

            SetListToCompoundAttribute(retType, matchingCategories, MatchingCategoriesAttributeName, description);
        }
Example #24
0
 static public string GetRequirementName(this CobieObject retType)
 {
     return(GetStringValue(retType, RequirementNameAttributeName));
 }
Example #25
0
 internal static IEnumerable <string> GetMatchingCodes(this CobieObject retType)
 {
     return(GetStringListFromCompound(retType, MatchingCodesAttributeName));
 }
Example #26
0
 internal static IEnumerable <string> GetRequirementClassifications(this CobieObject retType)
 {
     return(GetStringListFromCompound(retType, RequirementCategoriesAttributeName));
 }
Example #27
0
 internal static IEnumerable <string> GetRequirementDescs(this CobieObject retType)
 {
     return(GetStringListFromCompound(retType, RequirementDescsAttributeName));
 }
Example #28
0
 static public int GetValidChildrenCount(this CobieObject retType)
 {
     return(GetIntegerValue(retType, ValidChildrenAttributeName));
 }
Example #29
0
 public CobieObjectCategoryMatch(CobieObject evaluatingType)
 {
     MatchedObject      = evaluatingType;
     MatchingCategories = new List <Category>();
 }
Example #30
0
 public static bool IsClassifiedAsRequirement(this CobieObject obj)
 {
     return(obj.Categories != null && obj.Categories.Any(c => c.Classification == "DPoW" && c.Code == "required"));
 }