Class TemporaryIdentifiersManager<INT>

    • Constructor Detail

    • Method Detail

      • registerBrandNewExternalId

        @NotNull
        public EntityId<INT> registerBrandNewExternalId​(@NotNull
                                                        String extId)
        Description copied from interface: IdentifiersManager
        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).
        Specified by:
        registerBrandNewExternalId in interface IdentifiersManager<INT>
        Parameters:
        extId - the external identifier to register.
        Returns:
        new associated internal identifier.
      • findEntityIdByConfigId

        @Nullable
        public EntityId<INT> findEntityIdByConfigId​(@NotNull
                                                    String configId)
        Description copied from interface: IdentifiersManager
        Looks for a registered entity id by the given config id.
        Specified by:
        findEntityIdByConfigId in interface IdentifiersManager<INT>
        Parameters:
        configId - config id, case insensitive.
        Returns:
        found entity id or null when not found.
      • refreshFromDbIfNecessary

        @Nullable
        public EntityId<INT> refreshFromDbIfNecessary​(@NotNull
                                                      String extId,
                                                      @Nullable
                                                      String configId)
        Description copied from interface: IdentifiersManager
        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
        Specified by:
        refreshFromDbIfNecessary in interface IdentifiersManager<INT>
        Returns:
        found entity id or null when not found.
      • externalToInternal

        @NotNull
        public List<INT> externalToInternal​(@NotNull
                                            List<String> extIds)
        Description copied from interface: IdentifiersManager
        Looks for the internal identifiers by the given external ones
        Specified by:
        externalToInternal in interface IdentifiersManager<INT>
        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
      • externalToInternal

        @Nullable
        public INT externalToInternal​(@Nullable
                                      String extId)
        Description copied from interface: IdentifiersManager
        Looks for the internal identifier by the given external one.
        Specified by:
        externalToInternal in interface IdentifiersManager<INT>
        Parameters:
        extId - external identifier (case insensitive).
        Returns:
        the internal identifier if found, or null if not found.
      • generateNewIntId

        @NotNull
        public INT generateNewIntId​(@NotNull
                                    String newExtId)
      • generateNewExternalId

        @NotNull
        public String generateNewExternalId​(@Nullable
                                            String parentExtId,
                                            @NotNull
                                            String name,
                                            @Nullable
                                            Set<String> excludeAdditionalIds)
        Description copied from interface: ExternalIdGenerator
        Generates a new external id based on the given name and (optionally) parent external id. May adjust the case of the name part of the id to comply with external id conventions
        Specified by:
        generateNewExternalId in interface ExternalIdGenerator
        Parameters:
        parentExtId - the parent's external identifier (optional).
        name - the user string (name).
        excludeAdditionalIds - an additional set of ids that are already used (i.e. the result should not be one of them). The current assigned external ids are excluded by default.
        Returns:
        new external id
      • generateNewExternalId

        @NotNull
        public String generateNewExternalId​(@Nullable
                                            String parentExtId,
                                            @NotNull
                                            String name,
                                            @Nullable
                                            Set<String> excludeIds,
                                            boolean adjustCase)
        Description copied from interface: ExternalIdGenerator
        Generates a new external id based on the given name and (optionally) parent external id.
        Specified by:
        generateNewExternalId in interface ExternalIdGenerator
        Parameters:
        parentExtId - the parent's external identifier (optional).
        name - the user string (name).
        excludeIds - an additional set of ids that are already used (i.e. the result should not be one of them). The current assigned external ids are excluded by default.
        adjustCase - If true, the method is allowed to adjust the case of the name part of the external id
        Returns:
        new external id
      • externalIdSatisfiesConvention

        public boolean externalIdSatisfiesConvention​(@NotNull
                                                     String externalId,
                                                     @NotNull
                                                     String entityName,
                                                     @NotNull
                                                     String parentExtId)
        Description copied from interface: ExternalIdGenerator
        Returns true if provided external id satisfies convention used to generate new ids
        Specified by:
        externalIdSatisfiesConvention in interface ExternalIdGenerator
        Parameters:
        externalId - external ids to check
        entityName - name of the entity whose external id is to be verified
        parentExtId - parent external id
        Returns:
        see above
      • reassignInternalId

        public void reassignInternalId​(@NotNull
                                       EntityId<INT> entityId,
                                       @NotNull
                                       INT internalId,
                                       @Nullable
                                       CustomIdChangeApplier<INT> applier)
        Description copied from interface: IdentifiersManager
        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.
        Specified by:
        reassignInternalId in interface IdentifiersManager<INT>
      • reassignInternalIdInMemory

        public void reassignInternalIdInMemory​(@NotNull
                                               EntityId<INT> entityId,
                                               @NotNull
                                               INT internalId)
        Description copied from interface: IdentifiersManager
        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.
        Specified by:
        reassignInternalIdInMemory in interface IdentifiersManager<INT>
      • isExternalIdAlias

        public boolean isExternalIdAlias​(@NotNull
                                         String externalId)
        Description copied from interface: IdentifiersManager
        Check whether the external id is an alias (but not a primary external id).
        Specified by:
        isExternalIdAlias in interface IdentifiersManager<INT>
        Parameters:
        externalId - the external id to check.
        Returns:
        whether the externalId is an alias
      • internalToExternal

        @Nullable
        public String internalToExternal​(@Nullable
                                         INT intId)
        Description copied from interface: IdentifiersManager
        Looks for the external identifier by the given internal one.
        Specified by:
        internalToExternal in interface IdentifiersManager<INT>
        Parameters:
        intId - internal identifier (case sensitive).
        Returns:
        the external identifier if found, or null if not found.
      • internalToExternal

        @NotNull
        public List<String> internalToExternal​(@NotNull
                                               List<INT> intIds)
        Description copied from interface: IdentifiersManager
        Looks for the external identifiers by the given internal ones.
        Specified by:
        internalToExternal in interface IdentifiersManager<INT>
        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
      • configIdToInternal

        @Nullable
        public INT configIdToInternal​(@Nullable
                                      String configId)
        Description copied from interface: IdentifiersManager
        Looks for the internal identifier by the given config id.
        Specified by:
        configIdToInternal in interface IdentifiersManager<INT>
        Parameters:
        configId - config identifier (case insensitive).
        Returns:
        the internal identifier if found, or null if not found.
      • getAllExternalIds

        @NotNull
        public Set<String> getAllExternalIds​(@NotNull
                                             INT intId)
        Description copied from interface: IdentifiersManager
        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.

        Specified by:
        getAllExternalIds in interface IdentifiersManager<INT>
        Parameters:
        intId - internal identifier (case sensitive).
        Returns:
        set of corresponding external ids
      • regenerateExternalId

        @NotNull
        public String regenerateExternalId​(@Nullable
                                           String parentExtId,
                                           @NotNull
                                           String name,
                                           @NotNull
                                           String currentExternalId)
        Description copied from interface: ExternalIdGenerator
        Regenerates an external id based on the given name and (optionally) parent external id. The current external id is not taken into account, so the result can be the current id (but with another case).
        Specified by:
        regenerateExternalId in interface ExternalIdGenerator
        Parameters:
        parentExtId - the parent's external identifier (optional).
        name - the user string (name).
        currentExternalId - the external id an object currently has
        Returns:
        new external id
      • getNewOrChangedEntities

        @NotNull
        public Collection<EntityId<INT>> getNewOrChangedEntities()
        Returns:
        all new entity ids as well as entity ids with modified external id
      • getNewEntities

        @NotNull
        public Set<EntityId<INT>> getNewEntities()
        Returns:
        new entity ids, i.e. those with new internal identifier