Class: ProjectData

BIM. ProjectData

A class for storing and accessing shared project data.

Instances of this class are also shared with the current project.

NOTE: This class has a dependency on both BIM.Supplier and PD.Registry, so the files containing the code for this class must be included after the files defining them.


new ProjectData()

Creates a new shared component store.

Author:
  • drajmarsh

Members


:Map

componentMap

A map of all the shared components and constructions in the project model.

Components include all the various component type classes and constructions, indexed by universally unique identifier (UUID).

Type
  • Map

:Map

materialMap

A map of all of the materials used in the project model.

Materials can be shared by multiple constructions, so need to be stored in their own separate map.

Type
  • Map

:Map

profileMap

A map of all of the daily profiles used in the project model.

Daly profiles can be shared by multiple schedules, so need to be stored in their own separate map.

Type
  • Map

:Map

scheduleMap

A map of all of the schedules used in the project model.

Schedules can be shared by multiple spaces, appliances and/or equipment, so need to be stored in their own separate map.

Type
  • Map

:Map

supplierMap

A map of all the shared suppliers in the project model.

Suppliers are all the various type classes and constructions, indexed by universally unique identifier (UUID).

Type
  • Map

Methods


addComponent(component)

Registers a component so that it can be stored and shared within the project.

Parameters:
Name Type Description
component BIM.Component | object

A component instance.

Throws:

Throws an error if the instance is not a valid component.

Type
Error
Returns:

Returns this instance to support method chaining.

Type
BIM.ProjectData

addDaySchedule(day_schedule)

Registers a day schedule so that it can be stored and shared within the project.

Parameters:
Name Type Description
day_schedule PD.DaySchedule | object

A day schedule profile instance.

Throws:

Throws an error if the instance is not a valid profile.

Type
Error
Returns:

Returns this instance to support method chaining.

Type
BIM.ProjectData

addItem(item)

Adds a new shared supplier, component, material, schedule or profile to the project.

Parameters:
Name Type Description
item PD.Base

A new item instance to share.

Returns:

Returns true if the item was successfully added.

Type
boolean

addMaterial(material)

Registers a material so that it can be stored and shared within the project.

Parameters:
Name Type Description
material BIM.Material | object

A material instance.

Throws:

Throws an error if the instance is not a valid material.

Type
Error
Returns:

Returns this instance to support method chaining.

Type
BIM.ProjectData

addSchedule(schedule)

Registers a schedule so that it can be stored and shared within the project.

Parameters:
Name Type Description
schedule PD.Schedule | object

A schedule instance.

Throws:

Throws an error if the instance is not a valid schedule.

Type
Error
Returns:

Returns this instance to support method chaining.

Type
BIM.ProjectData

addSupplier(supplier)

Registers a supplier so that it can be stored and shared within the project.

Parameters:
Name Type Description
supplier BIM.Supplier | object

A supplier instance.

Throws:

Throws an error if the instance is not a valid supplier.

Type
Error
Returns:

Returns this instance to support method chaining.

Type
BIM.ProjectData

clear()

Clears everything from the store so it can be reused.

Returns:

Returns this instance to support method chaining.

Type
BIM.ProjectData

findCompatibleComponents(entity)

Retrieves all registered component instances compatible with the given object.

This method simply iterates through the shared component list and calls the isCompatibleWith() method on each one to check the given entity.

Parameters:
Name Type Description
entity BIM.Entity

The entity to match components with.

Returns:

Returns an array of matching component instances.

Type
Array.<BIM.Component>

findComponentsByType(type)

Retrieves all registered component instances of the given type.

Parameters:
Name Type Description
type number

The component type as an integer value.

Returns:

Returns an array of matching component instances.

Type
Array.<BIM.Component>

findDayScheduleByName(search)

Retrieves all profile instances with the given name.

This method simply iterates through the shared profile list and checks the name of each one.

Parameters:
Name Type Description
search string

The search string.

Returns:

Returns an array of matching profile instances.

Type
Array.<PD.DaySchedule>

findMaterialByName(search)

Retrieves all material instances with the given name.

This method simply iterates through the shared material list and checks the name of each one.

Parameters:
Name Type Description
search string

The search string.

Returns:

Returns an array of matching material instances.

Type
Array.<BIM.Material>

findScheduleByName(search)

Retrieves all schedule instances with the given name.

This method simply iterates through the shared schedule list and checks the name of each one.

Parameters:
Name Type Description
search string

The search string.

Returns:

Returns an array of matching schedule instances.

Type
Array.<PD.Schedule>

findSupplierByName(search)

Retrieves all supplier instances with the given name.

This method simply iterates through the shared supplier list and checks the name of each one.

Parameters:
Name Type Description
search string

The search string.

Returns:

Returns an array of matching supplier instances.

Type
Array

fromJSON(data)

Safely copy properties from a source object.

See the PD.Base#fromJSON method for more details.

Parameters:
Name Type Description
data object

The source object containing data to copy.

Returns:

Returns this instance to support method chaining.

Type
BIM.ProjectData

getComponentByUUID(uuid)

Retrieves a shared component instance given a unique id.

Parameters:
Name Type Description
uuid string

The unique identifier of a shared component.

Returns:

Returns the component instance, or null if not found.

Type
BIM.Component | null

getDayScheduleByUUID(uuid)

Retrieves a shared profile instance given a unique id.

Parameters:
Name Type Description
uuid string

The unique identifier of a shared profile.

Returns:

Returns the profile instance, or null if not found.

Type
PD.DaySchedule | null

getMaterialByUUID(uuid)

Retrieves a shared material instance given a unique id.

Parameters:
Name Type Description
uuid string

The unique identifier of a shared material.

Returns:

Returns the material instance, or null if not found.

Type
BIM.Material | null

getOrCreateComponent(config)

Retrieves or creates/adds a shared component instance based on configuration.

If a shared component with a matching uuid is found in the list, that is returned. If the given argument is a valid BIM.Component, it is added to the list and returned. Otherwise, a new component is created based on the given configuration, added to the list and returned. This last case means that the given configuration object must be the results of parsing JSON data and must have a valid className property.

If the given configuration is null or invalid, the method returns null.

Parameters:
Name Type Description
config BIM.Component | object

A component instance or component configuration.

Returns:

Returns the component instance, or null if not found.

Type
BIM.Component | null

getOrCreateDaySchedule(config)

Retrieves or creates/adds a shared profile instance based on configuration.

If a shared profile with a matching uuid is found in the list, that is returned. If the given argument is a valid PD.DaySchedule, it is added to the list and returned. Otherwise, a new profile is created based on the given configuration, added to the list and returned.

If the given configuration is null or invalid, the method returns null.

Parameters:
Name Type Description
config PD.DaySchedule | object

A profile instance or profile configuration.

Returns:

Returns the profile instance, or null if not found.

Type
PD.DaySchedule | null

getOrCreateMaterial(config)

Retrieves or creates/adds a shared material instance based on configuration.

If a shared material with a matching uuid is found in the list, that is returned. If the given argument is a valid BIM.Material, it is added to the list and returned. Otherwise, a new material is created based on the given configuration, added to the list and returned.

If the given configuration is null or invalid, the method returns null.

Parameters:
Name Type Description
config BIM.Material | object

A material instance or material configuration.

Returns:

Returns the material instance, or null if not found.

Type
BIM.Material | null

getOrCreateSchedule(config)

Retrieves or creates/adds a shared schedule instance based on configuration.

If a shared schedule with a matching uuid is found in the list, that is returned. If the given argument is a valid PD.Schedule, it is added to the list and returned. Otherwise, a new schedule is created based on the given configuration, added to the list and returned.

If the given configuration is null or invalid, the method returns null.

Parameters:
Name Type Description
config PD.Schedule | object

A schedule instance or schedule configuration.

Returns:

Returns the schedule instance, or null if not found.

Type
PD.Schedule | null

getOrCreateSupplier(config)

Retrieves or creates/adds a shared supplier instance based on configuration.

If a shared supplier with a matching uuid is found in the list, that is returned. If the given argument is a valid BIM.Supplier, it is added to the list and returned. Otherwise, a new supplier is created based on the given configuration, added to the list and returned.

If the given configuration is null or invalid, the method returns null.

Parameters:
Name Type Description
config BIM.Supplier | object

A supplier instance or supplier configuration.

Returns:

Returns the supplier instance, or null if not found.

Type
BIM.Supplier | null

getScheduleByUUID(uuid)

Retrieves a shared schedule instance given a unique id.

Parameters:
Name Type Description
uuid string

The unique identifier of a shared schedule.

Returns:

Returns the schedule instance, or null if not found.

Type
PD.Schedule | null

getSupplierByUUID(uuid)

Retrieves a shared supplier instance given a unique id.

Parameters:
Name Type Description
uuid string

The unique identifier of a shared supplier.

Returns:

Returns the supplier instance, or null if not found.

Type
BIM.Supplier | null

removeComponent(component)

Removes a shared component from the project.

Parameters:
Name Type Description
component BIM.Component

A shared component instance.

Returns:

Returns true if the component was successfully deleted.

Type
boolean

removeDaySchedule(profile)

Removes a shared profile from the project.

Parameters:
Name Type Description
profile PD.DaySchedule

A shared profile instance.

Returns:

Returns true if the profile was successfully deleted.

Type
boolean

removeItem(item)

Removes a shared supplier, component, material, schedule or profile from the project.

Parameters:
Name Type Description
item PD.Base

A shared item instance.

Returns:

Returns true if the item was successfully deleted.

Type
boolean

removeMaterial(material)

Removes a shared material from the project.

Parameters:
Name Type Description
material BIM.Material

A shared material instance.

Returns:

Returns true if the material was successfully deleted.

Type
boolean

removeSchedule(schedule)

Removes a shared schedule from the project.

Parameters:
Name Type Description
schedule PD.Schedule

A shared schedule instance.

Returns:

Returns true if the schedule was successfully deleted.

Type
boolean

removeSupplier(supplier)

Removes a shared supplier from the project.

Parameters:
Name Type Description
supplier BIM.Supplier

A shared supplier instance.

Returns:

Returns true if the supplier was successfully deleted.

Type
boolean

toJSON( [data])

Converts the object instance to a simple POJO for JSON storage.

This method is used to copy, store and save the data for ths object, so the returned object must have all the properties required be able to rebuild this instance in its entirety when passed to the class constructor.

See the PD.Base#toJSON method for more details.

Parameters:
Name Type Argument Description
data object <optional>

An optional parent object to append this data to.

Returns:

Returns a JSON object.

Type
object