/// <summary>
        /// Returns the IfcSpace created for this key
        /// </summary>
        /// <param name="spacekey"></param>
        /// <returns></returns>
        public IfcSpatialStructureElement GetIfcSpace(SpaceKey spacekey)
        {
            IfcSpatialStructureElement ifcSpace;

            _spaceLookup.TryGetValue(spacekey.Name, out ifcSpace);
            return(ifcSpace);
        }
        internal void AddSpaceToZone(SpaceKey spaceKey, IfcZone ifcZone)
        {
            var relationship = TargetRepository.Instances.OfType <IfcRelAssignsToGroup>().FirstOrDefault(r => r.RelatingGroup == ifcZone);

            if (relationship == null)
            {
                relationship = TargetRepository.Instances.New <IfcRelAssignsToGroup>();
                relationship.RelatingGroup = ifcZone;
            }
            var ifcSpace = GetIfcSpace(spaceKey);

            relationship.RelatedObjects.Add(ifcSpace);
            relationship.RelatedObjectsType = IfcObjectType.Product;
        }
Ejemplo n.º 3
0
        protected override Zone Mapping(IIfcZone ifcZone, Zone target)
        {
            var helper = ((IfcToCOBieLiteUkExchanger)Exchanger).Helper;

            target.ExternalEntity = helper.ExternalEntityName(ifcZone);
            target.ExternalId     = helper.ExternalEntityIdentity(ifcZone);
            target.AltExternalId  = ifcZone.GlobalId;
            target.ExternalSystem = helper.ExternalSystemName(ifcZone);
            target.Description    = ifcZone.Description;
            target.Categories     = helper.GetCategories(ifcZone);
            if (target.Categories == CoBieLiteUkHelper.UnknownCategory)
            {
                if (!string.IsNullOrWhiteSpace(ifcZone.ObjectType))
                {
                    target.Categories = new List <Category>(new [] { new Category {
                                                                         Code = ifcZone.ObjectType
                                                                     } });
                }
            }
            target.CreatedBy = helper.GetCreatedBy(ifcZone);
            target.CreatedOn = helper.GetCreatedOn(ifcZone);
            target.Name      = ifcZone.Name;
            //Attributes
            target.Attributes = helper.GetAttributes(ifcZone);
            //Documents
            var docsMappings = Exchanger.GetOrCreateMappings <MappingIfcDocumentSelectToDocument>();

            helper.AddDocuments(docsMappings, target, ifcZone);

            //get spaces in zones
            var spaces    = helper.GetSpaces(ifcZone);
            var ifcSpaces = spaces as IList <IIfcSpace> ?? spaces.ToList();

            if (ifcSpaces.Any())
            {
                target.Spaces = new List <SpaceKey>();
                foreach (var space in ifcSpaces)
                {
                    var spaceKey = new SpaceKey {
                        Name = space.Name
                    };
                    target.Spaces.Add(spaceKey);
                }
            }
            //TODO:
            //Space Issues

            return(target);
        }
Ejemplo n.º 4
0
        /// <returns>true if it has failures</returns>
        private bool ValidateZones(Facility requirement, Facility submitted, Facility retFacility)
        {
            if (requirement.Zones == null)
            {
                return(false);
            }
            var ret = false;
            // hack: create a fake modelFacility candidates from spaces.
            var fakeSubmittedFacility = new Facility();

            fakeSubmittedFacility.Floors = fakeSubmittedFacility.Clone(submitted.Floors as IEnumerable <Floor>).ToList();
            fakeSubmittedFacility.Zones  = new List <Zone>();
            var lSpaces = submitted.Get <Space>().ToList();

            foreach (var zoneRequirement in requirement.Zones)
            {
                var v = new CobieObjectValidator <Zone, Space>(zoneRequirement)
                {
                    TerminationMode = TerminationMode
                };
                if (!v.HasRequirements)
                {
                    continue;
                }

                // hack: now create a fake Zone based on candidates from spaces.
                var fakeZone = fakeSubmittedFacility.Create <Zone>();
                fakeZone.Categories     = zoneRequirement.Categories.Clone().ToList();
                fakeZone.Name           = zoneRequirement.Name;
                fakeZone.ExternalEntity = zoneRequirement.ExternalEntity;
                fakeZone.ExternalSystem = zoneRequirement.ExternalSystem;
                fakeZone.ExternalId     = zoneRequirement.ExternalId;
                fakeZone.Spaces         = new List <SpaceKey>();

                var candidateSpaces = v.GetCandidates(lSpaces).ToList();

                if (candidateSpaces.Any())
                {
                    foreach (var spaceMatch in candidateSpaces)
                    {
                        var mSpace = spaceMatch.MatchedObject as Space;
                        if (mSpace == null)
                        {
                            continue;
                        }
                        var sk = new SpaceKey {
                            Name = mSpace.Name
                        };
                        fakeZone.Spaces.Add(sk);
                    }
                    if (retFacility.Zones == null)
                    {
                        retFacility.Zones = new List <Zone>();
                    }
                    var validatedZone = v.Validate(fakeZone, retFacility);
                    retFacility.Zones.Add(validatedZone);
                    var tmpFloor = retFacility.Get <Floor>(fl => fl.Name == TemporaryFloorName).FirstOrDefault();
                    if (tmpFloor == null)
                    {
                        continue;
                    }
                    // ensure that the floor and spaces are avalialale in the report facility
                    foreach (var spaceKey in validatedZone.Spaces)
                    {
                        // 1) on the floor
                        var submissionOwningFloor =
                            submitted.Get <Floor>(f => f.Spaces != null && f.Spaces.Any(sp => sp.Name == spaceKey.Name)).FirstOrDefault();
                        if (submissionOwningFloor == null)
                        {
                            continue;
                        }
                        var destFloor = retFacility.Get <Floor>(f => f.Name == submissionOwningFloor.Name).FirstOrDefault();
                        if (destFloor == null)
                        {
                            destFloor                = retFacility.Create <Floor>();
                            destFloor.Name           = submissionOwningFloor.Name;
                            destFloor.ExternalEntity = submissionOwningFloor.ExternalEntity;
                            destFloor.ExternalId     = submissionOwningFloor.ExternalId;
                            destFloor.ExternalSystem = submissionOwningFloor.ExternalSystem;
                            destFloor.Elevation      = submissionOwningFloor.Elevation;
                            destFloor.Spaces         = new List <Space>();
                            retFacility.Floors.Add(destFloor); // finally add it in the facility tree
                        }
                        // 2) now on the space.

                        var sourceSpace = tmpFloor.Spaces.FirstOrDefault(sp => sp.Name == spaceKey.Name);
                        if (sourceSpace != null)
                        {
                            destFloor.Spaces.Add(sourceSpace);
                        }
                    }
                    retFacility.Floors.Remove(tmpFloor);
                }
                else
                {
                    if (retFacility.Zones == null)
                    {
                        retFacility.Zones = new List <Zone>();
                    }
                    retFacility.Zones.Add(v.Validate((Zone)null, retFacility));
                }
                ret |= v.HasFailures;
            }
            return(ret);
        }
Ejemplo n.º 5
0
        protected override Asset Mapping(IIfcElement ifcElement, Asset target)
        {
            var helper = ((IfcToCOBieLiteUkExchanger)Exchanger).Helper;

            target.ExternalEntity  = helper.ExternalEntityName(ifcElement);
            target.ExternalId      = helper.ExternalEntityIdentity(ifcElement);
            target.AltExternalId   = ifcElement.GlobalId;
            target.ExternalSystem  = helper.ExternalSystemName(ifcElement);
            target.Name            = ifcElement.Name;
            target.CreatedBy       = helper.GetCreatedBy(ifcElement);
            target.CreatedOn       = helper.GetCreatedOn(ifcElement);
            target.Categories      = helper.GetCategories(ifcElement);
            target.AssetIdentifier = helper.GetCoBieProperty("AssetIdentifier", ifcElement);
            target.BarCode         = helper.GetCoBieProperty("AssetBarCode", ifcElement);
            if (!string.IsNullOrWhiteSpace(ifcElement.Description))
            {
                target.Description = ifcElement.Description;
            }
            else
            {
                target.Description = helper.GetCoBieProperty("AssetSerialNumber", ifcElement);
            }
            target.InstallationDate  = helper.GetCoBieProperty <DateTime>("AssetInstallationDate", ifcElement);
            target.SerialNumber      = helper.GetCoBieProperty("AssetSerialNumber", ifcElement);
            target.TagNumber         = helper.GetCoBieProperty("AssetTagNumber", ifcElement);
            target.WarrantyStartDate = helper.GetCoBieProperty <DateTime>("AssetWarrantyStartDate", ifcElement);



            //Attributes
            target.Attributes = helper.GetAttributes(ifcElement);

            //Documents
            var docsMappings = Exchanger.GetOrCreateMappings <MappingIfcDocumentSelectToDocument>();

            helper.AddDocuments(docsMappings, target, ifcElement);

            //System Assignments

            //Space Assignments
            var spatialElements = helper.GetSpaces(ifcElement);

            var ifcSpatialStructureElements = spatialElements.ToList();

            target.Spaces = new List <SpaceKey>();
            if (ifcSpatialStructureElements.Any())
            {
                foreach (var spatialElement in ifcSpatialStructureElements)
                {
                    var space = new SpaceKey {
                        Name = spatialElement.Name
                    };
                    target.Spaces.Add(space);
                }
            }
            //else //it is in nowhere land, assign it to a special space all Default External
            //{
            //    var space = new SpaceKey();
            //    space.Name = "Default External";
            //    space.KeyType = EntityType.Space;
            //    target.Spaces.Add(space);
            //}
            else // if it is part of an aggregated element, add spaces of the aggregated element
            {
                var assemblyParts = ifcElement.Model.Instances.OfType <IIfcRelAggregates>().Where(b => b.RelatedObjects.Contains(ifcElement)).FirstOrDefault();
                if (assemblyParts != null)
                {
                    ifcSpatialStructureElements = helper.GetSpaces((IIfcElement)assemblyParts.RelatingObject).ToList();
                    target.Spaces = new List <SpaceKey>();
                    if (ifcSpatialStructureElements.Any())
                    {
                        foreach (var spatialElement in ifcSpatialStructureElements)
                        {
                            var Fspace = new SpaceKey {
                                Name = spatialElement.Name
                            };
                            target.Spaces.Add(Fspace);
                        }
                    }
                }
            }


            //Issues


            return(target);
        }
        protected override Asset Mapping(IfcElement ifcElement, Asset target)
        {
            var helper = ((IfcToCOBieLiteUkExchanger)Exchanger).Helper;

            target.ExternalEntity = helper.ExternalEntityName(ifcElement);
            target.ExternalId     = helper.ExternalEntityIdentity(ifcElement);
            target.ExternalSystem = helper.ExternalSystemName(ifcElement);
            target.Name           = ifcElement.Name;
            target.CreatedBy      = helper.GetCreatedBy(ifcElement);
            target.CreatedOn      = helper.GetCreatedOn(ifcElement);

            target.AssetIdentifier = helper.GetCoBieProperty("AssetIdentifier", ifcElement);
            target.BarCode         = helper.GetCoBieProperty("AssetBarCode", ifcElement);
            if (!string.IsNullOrWhiteSpace(ifcElement.Description))
            {
                target.Description = ifcElement.Description;
            }
            else
            {
                target.Description = helper.GetCoBieProperty("AssetSerialNumber", ifcElement);
            }
            target.InstallationDate  = helper.GetCoBieProperty <DateTime>("AssetInstallationDate", ifcElement);
            target.SerialNumber      = helper.GetCoBieProperty("AssetSerialNumber", ifcElement);
            target.TagNumber         = helper.GetCoBieProperty("AssetTagNumber", ifcElement);
            target.WarrantyStartDate = helper.GetCoBieProperty <DateTime>("AssetWarrantyStartDate", ifcElement);



            //Attributes
            target.Attributes = helper.GetAttributes(ifcElement);
            //System Assignments

            //Space Assignments
            var spatialElements = helper.GetSpaces(ifcElement);

            var ifcSpatialStructureElements = spatialElements as IList <IfcSpatialStructureElement> ?? spatialElements.ToList();

            target.Spaces = new List <SpaceKey>();
            if (ifcSpatialStructureElements.Any())
            {
                foreach (var spatialElement in ifcSpatialStructureElements)
                {
                    var space = new SpaceKey {
                        Name = spatialElement.Name
                    };
                    target.Spaces.Add(space);
                }
            }
            //else //it is in nowhere land, assign it to a special space all Default External
            //{
            //    var space = new SpaceKey();
            //    space.Name = "Default External";
            //    space.KeyType = EntityType.Space;
            //    target.Spaces.Add(space);
            //}


            //Issues

            //Documents
            return(target);
        }