Class GroupProvider

java.lang.Object
cern.nxcals.api.extraction.metadata.AbstractProvider<Group,GroupClient,cern.nxcals.api.extraction.metadata.queries.Groups>
cern.nxcals.api.extraction.metadata.GroupProvider
All Implemented Interfaces:
AbstractGroupService<Group,cern.nxcals.api.extraction.metadata.queries.Groups>, GroupService, Queryable<Group,cern.nxcals.api.extraction.metadata.queries.Groups>, cern.nxcals.internal.extraction.metadata.InternalGroupService

public class GroupProvider extends AbstractProvider<Group,GroupClient,cern.nxcals.api.extraction.metadata.queries.Groups> implements cern.nxcals.internal.extraction.metadata.InternalGroupService
  • Constructor Details

    • GroupProvider

      public GroupProvider(GroupClient httpClient)
  • Method Details

    • findById

      public Optional<Group> findById(long id)
      Specified by:
      findById in interface Queryable<Group,cern.nxcals.api.extraction.metadata.queries.Groups>
    • create

      public Group create(Group group)
      Description copied from interface: AbstractGroupService
      Creates group as in the parameter NOTE: this is a mutative method. It is not thread-safe or meant to be used in parallel
      Specified by:
      create in interface AbstractGroupService<Group,cern.nxcals.api.extraction.metadata.queries.Groups>
      Parameters:
      group - to be created
      Returns:
      Created group
    • update

      public Group update(Group group)
      Description copied from interface: AbstractGroupService
      Updates an existing group to the new values as in the parameter NOTE: this is a mutative method. It is not thread-safe or meant to be used in parallel
      Specified by:
      update in interface AbstractGroupService<Group,cern.nxcals.api.extraction.metadata.queries.Groups>
      Parameters:
      group - to be updated
      Returns:
      Updated group or null if the group does not exist
    • delete

      public void delete(long groupId)
      Description copied from interface: AbstractGroupService
      Deletes an existing group
      Specified by:
      delete in interface AbstractGroupService<Group,cern.nxcals.api.extraction.metadata.queries.Groups>
      Parameters:
      groupId - the id of the group to be deleted
    • getVariables

      public Map<String,Set<Variable>> getVariables(long groupId)
      Description copied from interface: AbstractGroupService
      Returns the complete map of variables grouped by their association to a given group
      Specified by:
      getVariables in interface AbstractGroupService<Group,cern.nxcals.api.extraction.metadata.queries.Groups>
      Parameters:
      groupId - of the group to query
      Returns:
      Map of variables grouped by their association type to the group
    • setVariables

      public void setVariables(long groupId, Map<String,Set<Long>> variableIdsPerAssociation)
      Description copied from interface: AbstractGroupService
      Attaches the given Map of variables to the given group, overwriting any existing associations. In case the association(s) do not exist, it creates and sets the variables as described by their ids. The group and the variables must exist. The map key should represent the association type of the enclosed variable Set. NOTE: this action replaces any existing associations. The resulted associations would reflect the provided context. NOTE: this is a mutative method. It is not thread-safe or meant to be used in parallel
      Specified by:
      setVariables in interface AbstractGroupService<Group,cern.nxcals.api.extraction.metadata.queries.Groups>
      Parameters:
      groupId - group to attach variables to
      variableIdsPerAssociation - Map of variable ids to attach, grouped by the association type
    • addVariables

      public void addVariables(long groupId, Map<String,Set<Long>> variableIdsPerAssociation)
      Description copied from interface: AbstractGroupService
      Attaches the given Map of associations to the given group, by adding the provided variables to the corresponding association. In case the association(s) do not exist, it creates and adds the variables as described by their ids. The group and the variables to add must exist. The map key should represent the association type of the enclosed variable Set. NOTE: this action only adds to any existing attached Set. Does not fail if variable already present. The resulted associations would reflect the merged product of the existing associations and the provided ones. NOTE: this is a mutative method. It is not thread-safe or meant to be used in parallel
      Specified by:
      addVariables in interface AbstractGroupService<Group,cern.nxcals.api.extraction.metadata.queries.Groups>
      Parameters:
      groupId - group to attach variables to
      variableIdsPerAssociation - Map of variable ids to attach, grouped by the association type
    • removeVariables

      public void removeVariables(long groupId, Map<String,Set<Long>> variableIdsPerAssociation)
      Description copied from interface: AbstractGroupService
      Detaches the given Map of variables from the given group. The map key should represent the association type of the enclosed variable Set. The group and the variables must exist. NOTE: it removes from any existing attached Set. Does not fail if variable already absent. NOTE: this is a mutative method. It is not thread-safe or meant to be used in parallel
      Specified by:
      removeVariables in interface AbstractGroupService<Group,cern.nxcals.api.extraction.metadata.queries.Groups>
      Parameters:
      groupId - group to attach variables to
      variableIdsPerAssociation - Map of variable ids to detach, grouped by the association type
    • getEntities

      public Map<String,Set<Entity>> getEntities(long groupId)
      Description copied from interface: AbstractGroupService
      Returns the complete map of entities grouped by their association to a given group
      Specified by:
      getEntities in interface AbstractGroupService<Group,cern.nxcals.api.extraction.metadata.queries.Groups>
      Parameters:
      groupId - of the group to query
      Returns:
      Map of entities grouped by their association type to the group
    • setEntities

      public void setEntities(long groupId, Map<String,Set<Long>> entityIdsPerAssociation)
      Description copied from interface: AbstractGroupService
      Attaches the given Map of entities to the given group, overwriting any existing associations. In case the association(s) do not exist, it creates and sets the entities as described by their ids. The group and the entities must exist. The map key should represent the association type of the enclosed entity Set. NOTE: this action replaces any existing associations. The resulted associations would reflect the provided context. NOTE: this is a mutative method. It is not thread-safe or meant to be used in parallel
      Specified by:
      setEntities in interface AbstractGroupService<Group,cern.nxcals.api.extraction.metadata.queries.Groups>
      Parameters:
      groupId - id of the group to attach entities to
      entityIdsPerAssociation - Map of entity ids to attach, grouped by the association type
    • addEntities

      public void addEntities(long groupId, Map<String,Set<Long>> entityIdsPerAssociation)
      Description copied from interface: AbstractGroupService
      Attaches the given Map of entities to the given group, by adding the provided entities to the corresponding association. In case the association(s) do not exist, it creates and adds the entities as described by their ids. The group and the entities to add must exist. The map key should represent the association type of the enclosed entity Set. NOTE: this action only adds to any existing attached Set. Does not fail if entity already present. The resulted associations would reflect the merged product of the existing associations and the provided ones. NOTE: this is a mutative method. It is not thread-safe or meant to be used in parallel
      Specified by:
      addEntities in interface AbstractGroupService<Group,cern.nxcals.api.extraction.metadata.queries.Groups>
      Parameters:
      groupId - group to attach entities to
      entityIdsPerAssociation - Map of entity ids to attach, grouped by the association type
    • removeEntities

      public void removeEntities(long groupId, Map<String,Set<Long>> entityIdsPerAssociation)
      Description copied from interface: AbstractGroupService
      Detaches the given Map of entities from the given group. The map key should represent the association type of the enclosed entity Set. The group and the entities must exist. NOTE: it removes from any existing attached Set. Does not fail if entity already absent. NOTE: this is a mutative method. It is not thread-safe or meant to be used in parallel
      Specified by:
      removeEntities in interface AbstractGroupService<Group,cern.nxcals.api.extraction.metadata.queries.Groups>
      Parameters:
      groupId - group to attach entities to
      entityIdsPerAssociation - Map of entity ids to detach, grouped by the association type