Interface IdentifiersManager<INT>

    • Method Detail

      • registerBrandNewExternalId

        @NotNull
        EntityId<INT> registerBrandNewExternalId​(@NotNull
                                                 String extId)
                                          throws InvalidIdentifierException
        Registers the given external identifier with a brand new internal one. If such external identifier was already registered, the correspondent internal one is dropped (and is not reused).
        Parameters:
        extId - the external identifier to register.
        Returns:
        new associated internal identifier.
        Throws:
        InvalidIdentifierException
        Since:
        8.0
      • registerOrReuseExternalAndConfigId

        @NotNull
        EntityId<INT> registerOrReuseExternalAndConfigId​(@NotNull
                                                         String extId,
                                                         @Nullable
                                                         String configId)
                                                  throws InvalidIdentifierException
        Registers the given external identifier and config id pair. If specified config id exists in database it's internal id will be used, otherwise new internal id will be generated.
        Parameters:
        extId - the external identifier to register.
        configId - the config identifier to register, if null new config id is generated.
        Returns:
        associated internal identifier.
        Throws:
        InvalidIdentifierException
        Since:
        9.0
      • generateAndRegisterBrandNewExternalId

        @NotNull
        EntityId<INT> generateAndRegisterBrandNewExternalId​(@Nullable
                                                            String parentExtId,
                                                            @NotNull
                                                            String name)
                                                     throws InvalidIdentifierException
        Generates a unique external identifier by the given parent external identifier and a user string (usually name), and register the just generated identifier as a brand new one.
        Parameters:
        parentExtId - the parent's external identifier (optional).
        name - the user string (name).
        Returns:
        just created identifiers pair.
        Throws:
        InvalidIdentifierException
        Since:
        8.0
      • findEntityIdByInternalId

        @Nullable
        EntityId<INT> findEntityIdByInternalId​(@NotNull
                                               INT intId)
        Looks for a registered entity id by the given internal id.
        Parameters:
        intId - internal id.
        Returns:
        found entity id or null when not found.
        Since:
        8.0
      • findEntityIdByExternalId

        @Nullable
        EntityId<INT> findEntityIdByExternalId​(@NotNull
                                               String extId)
        Looks for a registered entity id by the given external id.
        Parameters:
        intId - external id, case insensitive.
        Returns:
        found entity id or null when not found.
        Since:
        8.0
      • findEntityIdByConfigId

        @Nullable
        EntityId<INT> findEntityIdByConfigId​(@NotNull
                                             String configId)
        Looks for a registered entity id by the given config id.
        Parameters:
        configId - config id, case insensitive.
        Returns:
        found entity id or null when not found.
        Since:
        9.0
      • refreshFromDbIfNecessary

        @Nullable
        EntityId<INT> refreshFromDbIfNecessary​(@NotNull
                                               String extId,
                                               @Nullable
                                               String configId)
        Looks for a registered entity id by the given config id and ext id and refresh from db if necessary. Called by secondary nodes while loading new entities
        Returns:
        found entity id or null when not found.
        Since:
        2019.1
      • reassignInternalId

        void reassignInternalId​(@NotNull
                                EntityId<INT> entityId,
                                @NotNull
                                INT internalId,
                                @Nullable
                                CustomIdChangeApplier<INT> applier)
        Assigns the specified internalId to the given entity and runs provided applier after that. The internalId should come from an entityId present in DB and marked as removed, otherwise an IllegalArgumentException is thrown. Makes the extId of the given internalId becomes an alias for the entityId. Also creates a new deleted entity with extId='{entityId.extId}_Detached', intId={entityId.intId}, cfgId={entityId.cfgId}, so that {entityId.intId} can then be specified as internalId to in this method.
        Since:
        2018.1
      • reassignInternalIdInMemory

        void reassignInternalIdInMemory​(@NotNull
                                        EntityId<INT> entityId,
                                        @NotNull
                                        INT internalId)
        Reassigns internal id in memory only, does not change anything in database. Should be used in case of multi node event about internal id changes.
        Parameters:
        entityId -
        internalId -
      • removeExternalIdAlias

        boolean removeExternalIdAlias​(@NotNull
                                      String externalIdAlias)
                               throws FailedToRemoveExternalIdAlias
        Removes the external id alias (but not a primary external id) from the model and database. If no nether alias nor internal id found, just silently returns.
        Parameters:
        externalIdAlias - the alias to remove.
        Returns:
        whether the entry was really removed (from the database).
        Throws:
        FailedToRemoveExternalIdAlias - when could not remove.
        Since:
        9.0
      • isExternalIdAlias

        boolean isExternalIdAlias​(@NotNull
                                  String externalId)
        Check whether the external id is an alias (but not a primary external id).
        Parameters:
        externalId - the external id to check.
        Returns:
        whether the externalId is an alias
        Since:
        9.0
      • internalToExternal

        @Nullable
        String internalToExternal​(@Nullable
                                  INT intId)
        Looks for the external identifier by the given internal one.
        Parameters:
        intId - internal identifier (case sensitive).
        Returns:
        the external identifier if found, or null if not found.
        Since:
        8.0
      • internalToExternal

        @NotNull
        List<String> internalToExternal​(@NotNull
                                        List<INT> intIds)
        Looks for the external identifiers by the given internal ones.
        Parameters:
        intIds - list of internal IDs. Nulls are allowed.
        Returns:
        List of external IDs. List size is always equal to initial one. For unknown IDs null will be returned
        Since:
        9.1
      • externalToInternal

        @Nullable
        INT externalToInternal​(@Nullable
                               String extId)
        Looks for the internal identifier by the given external one.
        Parameters:
        extId - external identifier (case insensitive).
        Returns:
        the internal identifier if found, or null if not found.
        Since:
        8.0
      • externalToInternal

        @NotNull
        List<INT> externalToInternal​(@NotNull
                                     List<String> extIds)
        Looks for the internal identifiers by the given external ones
        Parameters:
        extIds - list of external IDs. Nulls are allowed.
        Returns:
        List of internal IDs. List size is always equal to initial one. For unknown IDs null will be returned
        Since:
        9.1
      • configIdToInternal

        @Nullable
        INT configIdToInternal​(@Nullable
                               String configId)
        Looks for the internal identifier by the given config id.
        Parameters:
        configId - config identifier (case insensitive).
        Returns:
        the internal identifier if found, or null if not found.
        Since:
        9.0
      • getAllInternalIds

        @NotNull
        Set<INT> getAllInternalIds()
        Provides with all known internal identifiers.
        Returns:
        internal identifiers as a set of case-sensitive strings.
        Since:
        8.0
      • getAllExternalIds

        @NotNull
        Set<String> getAllExternalIds()
        Provides with all known external identifiers.
        Returns:
        external identifiers as a set of case-insensitive strings.
        Since:
        8.0
      • getAllExternalIds

        @NotNull
        Set<String> getAllExternalIds​(@NotNull
                                      INT intId)
        Returns all external ids that correspond to the intId. There is a main one, or probably several aliases.

        If the intId is not found, empty set is returned.

        Parameters:
        intId - internal identifier (case sensitive).
        Returns:
        set of corresponding external ids
        Since:
        8.1
      • markRemoved

        void markRemoved​(@NotNull
                         EntityId<INT> entityId,
                         @Nullable
                         String originProjectIntId)
        Marks specified entityId as removed and sets the origin project internal id to the given value
      • resetRemoved

        void resetRemoved​(@NotNull
                          Collection<EntityId<INT>> entityIds)
        Resets removed mark for the given entityId
        Since:
        2018.2.2
      • consumeEntityIds

        void consumeEntityIds​(@NotNull
                              Consumer<EntityId<INT>> consumer)
        Consumes entityIds in this manager