Class PremisesService

java.lang.Object
io.vertx.core.AbstractVerticle
org.pidome.server.services.AbstractService
org.pidome.server.services.premises.PremisesService
All Implemented Interfaces:
io.vertx.core.Verticle

public final class PremisesService
extends AbstractService
Premises service.
  • Constructor Details

  • Method Details

    • getFullPremises

      public java.util.List<Premises> getFullPremises()
      Returns all premises levels.
      Returns:
      All levels known on the premises.
    • getPremises

      public Premises getPremises​(java.util.UUID id)
      Returns a premises based on the given id.
      Parameters:
      id - The id of the premises to etch.
      Returns:
      the selected premises.
    • addPremises

      public Premises addPremises​(Premises premises)
      Adds a premises.
      Parameters:
      premises - The premises to add.
      Returns:
      The newly persisted premises.
    • patchPremises

      public void patchPremises​(Premises premises)
      Patches a premises. The patching does not alter the property assignments.
      Parameters:
      premises - the premises to update.
    • deletePremises

      public void deletePremises​(java.util.UUID premisesId)
      Deletes a premises from the system. This method is recursive and deletes all properties on the premises.
      Parameters:
      premisesId - The premises id to delete.
    • getPremisesSections

      public java.util.List<PremisesSection> getPremisesSections​(java.util.UUID premisesId)
      Returns a list of premises sections.
      Parameters:
      premisesId - The id of the premises to gather the sections from.
      Returns:
      List of premises sections.
    • getPremisesSection

      public PremisesSection getPremisesSection​(java.util.UUID premisesId, java.util.UUID sectionId)
      Return a single premises section.
      Parameters:
      premisesId - The id of the premises to retrieve.
      sectionId - The id of the section to retrieve.
      Returns:
      the requested section.
    • addPremisesSection

      public PremisesSection addPremisesSection​(java.util.UUID premisesId, PremisesSection section)
      Adds a section to the given premises identified by the given id.
      Parameters:
      premisesId - The premises id.
      section - The section to add.
      Returns:
      The added premises section.
    • patchPremisesSection

      public void patchPremisesSection​(java.util.UUID premisesId, PremisesSection section)
      A shallow update of a section object in the given premises.
      Parameters:
      premisesId - The id of the premises where the to be patched object is present.
      section - The premises section to be patched.
    • deletePremisesSection

      public void deletePremisesSection​(java.util.UUID premisesId, java.util.UUID sectionId)
      Deletes a section from the system.
      Parameters:
      premisesId - The premises id to delete the section on.
      sectionId - The id of the section to delete.
    • getProperties

      public java.util.List<Property> getProperties​(java.util.UUID premisesId)
      Returns a list of properties on a premises.
      Parameters:
      premisesId - The premises to get the properties from.
      Returns:
      List of properties on the premises.
    • getProperty

      public Property getProperty​(java.util.UUID premisesId, java.util.UUID propertyId)
      Return a property on a given premises.
      Parameters:
      premisesId - id of the premises.
      propertyId - id of the property.
      Returns:
      The property when existing on the given premises.
    • addProperty

      public Property addProperty​(java.util.UUID premisesId, Property property)
      Adds a property to the given premises identified by the given id.
      Parameters:
      premisesId - The premises id.
      property - The property to add.
      Returns:
      The added property on success.
    • patchProperty

      public void patchProperty​(java.util.UUID premisesId, Property property)
      A shallow update of a property object in the given premises. This method does not modify the level collection in the property.
      Parameters:
      premisesId - The id of the premises where the to be patched object is present.
      property - The property to be patched.
    • deleteProperty

      public void deleteProperty​(java.util.UUID premisesId, java.util.UUID propertyId)
      Deletes a property from the system. This method is recursive and deletes all property levels and sections.
      Parameters:
      premisesId - The premises id to delete.
      propertyId - The id of the property to delete.
    • getPropertyLevels

      public java.util.List<PropertyLevel> getPropertyLevels​(java.util.UUID premisesId, java.util.UUID propertyId)
      Returns a list of property levels.
      Parameters:
      premisesId - The id of the property premises.
      propertyId - The id of property from which the levels should be returned.
      Returns:
      List of property levels when present, otherwise an empty list.
    • getPropertyLevel

      public PropertyLevel getPropertyLevel​(java.util.UUID premisesId, java.util.UUID propertyId, java.util.UUID levelId)
      Returns a single level on/in a property.
      Parameters:
      premisesId - The id of the premises containing the property on which the level resides.
      propertyId - The id of the property on which the level resides.
      levelId - The id of the premises level to return.
      Returns:
      A premises level.
    • addPropertyLevel

      public PropertyLevel addPropertyLevel​(java.util.UUID premisesId, java.util.UUID propertyId, PropertyLevel level)
      Adds a level on a property.
      Parameters:
      premisesId - The id of the premises.
      propertyId - The id of the property.
      level - The level to add to the property with the given id.
      Returns:
      The added property level.
    • patchPropertyLevel

      public void patchPropertyLevel​(java.util.UUID premisesId, java.util.UUID propertyId, PropertyLevel level)
      Shallow update of a property level. This does not modify the sections on a level. Use the appropriate method for this.
      Parameters:
      premisesId - The id of the premises of the property where the level resides.
      propertyId - The id of the property where the level should be updated.
      level - The level to patch.
    • deletePropertyLevel

      public void deletePropertyLevel​(java.util.UUID premisesId, java.util.UUID propertyId, java.util.UUID levelId)
      Deletes the given level from the property.
      Parameters:
      premisesId - The premises id of the premises with the property containing the level.
      propertyId - The id of the property having the level.
      levelId - the id of the level to be deleted.
    • getPropertyLevelSections

      public java.util.List<PropertySection> getPropertyLevelSections​(java.util.UUID premisesId, java.util.UUID propertyId, java.util.UUID levelId)
      Returns a list of property level sections.
      Parameters:
      premisesId - The id of the premises.
      propertyId - The id of the sections.
      levelId - The id of the property level.
      Returns:
      a list of property level sections.
    • addPropertyLevelSection

      public PropertySection addPropertyLevelSection​(java.util.UUID premisesId, java.util.UUID propertyId, java.util.UUID levelId, PropertySection section)
      Adds a property section to a property level.
      Parameters:
      premisesId - The premises the property is on.
      propertyId - The property containing the level.
      levelId - The level on which the section should be added.
      section - The section to add.
      Returns:
      The poperty section added.
    • patchPropertyLevelSection

      public void patchPropertyLevelSection​(java.util.UUID premisesId, java.util.UUID propertyId, java.util.UUID levelId, PropertySection section)
      Updates a property section.
      Parameters:
      premisesId - The premises the property is on.
      propertyId - The property containing the level.
      levelId - The level on which the section should be added.
      section - The section to update.
    • getPropertyLevelSection

      public PropertySection getPropertyLevelSection​(java.util.UUID premisesId, java.util.UUID propertyId, java.util.UUID levelId, java.util.UUID sectionId)
      Returns a single section on a property level.
      Parameters:
      premisesId - The premises the property is on.
      propertyId - The property containing the level.
      levelId - The level on which the section should be added.
      sectionId - The id of the section.
      Returns:
      The property section when found.
    • deletePropertyLevelSection

      public void deletePropertyLevelSection​(java.util.UUID premisesId, java.util.UUID propertyId, java.util.UUID levelId, java.util.UUID sectionId)
      Deletes the given level from the property.
      Parameters:
      premisesId - The premises id of the premises with the property containing the level.
      propertyId - The id of the property having the level.
      levelId - the id of the level containing the section.
      sectionId - the id of the section to be deleted.
    • getOrderedSectionsCompound

      public java.util.List<RegionSection> getOrderedSectionsCompound()
      Returns a compound of region sections. This provides the RegionSection a compound name and order to support displaying. A compound name looks like:
      • premises/section
      • premises/property/level/section
      The order will be set automatically and by default
      Returns:
      a compound of region sections.
    • getRegionSectionsWithItems

      public java.util.List<RegionSection> getRegionSectionsWithItems()
      Returns the region sections with the items.
      Returns:
      List of reqion sections with the items.
    • getPremisesListSize

      public long getPremisesListSize() throws java.lang.Exception
      Returns the amount of premises available.
      Returns:
      total amount of premises levels.
      Throws:
      java.lang.Exception - When an error occurs during count.
    • getPropertiesListSize

      public long getPropertiesListSize() throws java.lang.Exception
      Returns the amount of property levels available.
      Returns:
      total amount of premises levels.
      Throws:
      java.lang.Exception - When an error occurs during count.
    • getPropertiesListSize

      public long getPropertiesListSize​(Premises premises) throws java.lang.Exception
      Returns the amount of premises levels available.
      Parameters:
      premises - the premises to get the amount of properties on.
      Returns:
      total amount of premises levels.
      Throws:
      java.lang.Exception - When an error occurs during count.
    • getPropertLevelsListSize

      public long getPropertLevelsListSize() throws java.lang.Exception
      Returns the amount of premises levels available.
      Returns:
      total amount of premises levels.
      Throws:
      java.lang.Exception - When an error occurs during count.
    • getPropertLevelsListSize

      public long getPropertLevelsListSize​(Property property) throws java.lang.Exception
      Returns the amount of premises levels available.
      Parameters:
      property - The propty to get the amount of levels from.
      Returns:
      total amount of premises levels.
      Throws:
      java.lang.Exception - When an error occurs during count.
    • start

      public void start​(io.vertx.core.Promise<java.lang.Void> startPromise)
      Start the premises service.
      Specified by:
      start in interface io.vertx.core.Verticle
      Specified by:
      start in class AbstractService
      Parameters:
      startPromise - promise to determine a correct or failed start.
    • stop

      public void stop​(io.vertx.core.Promise<java.lang.Void> stopPromise)
      Stops the service.
      Specified by:
      stop in interface io.vertx.core.Verticle
      Specified by:
      stop in class AbstractService
      Parameters:
      stopPromise - Promise to determine the service stoppped correctly or not.