public void handle(IdentityBean<Integer> entity) { Integer value = (Integer) entity.getId(); if (value == null || value.intValue() == 0) { value = _maxId + 1; entity.setId(value); } _maxId = Math.max(_maxId, value.intValue()); } }
public void handle(IdentityBean<Integer> entity) { Integer value = (Integer) entity.getId(); if (value == null || value.intValue() == 0) { value = _maxId + 1; entity.setId(value); } _maxId = Math.max(_maxId, value.intValue()); } }
/** * Non-identifiable entities (see * {@link AbstractNonIdentifiableSingleEntityMergeStrategy}) still have an id * of sorts: an integer id that we randomly generate on data import to * distinguish between the entities. To avoid id collisions in the output * feed, we reset this generated id before outputing it to the merged output * feed. * * @param context * @param entity */ private void resetGeneratedIds(GtfsMergeContext context, IdentityBean<?> entity) { Object id = entity.getId(); if (id != null && id instanceof Integer) { @SuppressWarnings("unchecked") IdentityBean<Integer> hasIntegerId = (IdentityBean<Integer>) entity; hasIntegerId.setId(0); } }
/** * Non-identifiable entities (see * {@link AbstractNonIdentifiableSingleEntityMergeStrategy}) still have an id * of sorts: an integer id that we randomly generate on data import to * distinguish between the entities. To avoid id collisions in the output * feed, we reset this generated id before outputing it to the merged output * feed. * * @param context * @param entity */ private void resetGeneratedIds(GtfsMergeContext context, IdentityBean<?> entity) { Object id = entity.getId(); if (id != null && id instanceof Integer) { @SuppressWarnings("unchecked") IdentityBean<Integer> hasIntegerId = (IdentityBean<Integer>) entity; hasIntegerId.setId(0); } }
private <T extends IdentityBean<AgencyAndId>> void bulkRenameAgencyId( Iterable<T> elements, String oldAgencyId, String newAgencyId) { for (T element : elements) { AgencyAndId id = element.getId(); if (id.getAgencyId().equals(oldAgencyId)) { AgencyAndId newId = new AgencyAndId(newAgencyId, id.getId()); element.setId(newId); } } }
private <T extends IdentityBean<AgencyAndId>> void bulkRenameAgencyId( Iterable<T> elements, String oldAgencyId, String newAgencyId) { for (T element : elements) { AgencyAndId id = element.getId(); if (id.getAgencyId().equals(oldAgencyId)) { AgencyAndId newId = new AgencyAndId(newAgencyId, id.getId()); element.setId(newId); } } }
/** * Rename the id of the specified identity to avoid an raw GTFS identifier * collision in the merged output feed. * * @param context * @param entity */ @SuppressWarnings("unchecked") protected void rename(GtfsMergeContext context, IdentityBean<?> entity) { Object id = entity.getId(); if (id != null && id instanceof AgencyAndId) { IdentityBean<AgencyAndId> bean = (IdentityBean<AgencyAndId>) entity; AgencyAndId agencyAndId = bean.getId(); agencyAndId = MergeSupport.renameAgencyAndId(context, agencyAndId); bean.setId(agencyAndId); } } }
/** * Rename the id of the specified identity to avoid an raw GTFS identifier * collision in the merged output feed. * * @param context * @param entity */ @SuppressWarnings("unchecked") protected void rename(GtfsMergeContext context, IdentityBean<?> entity) { Object id = entity.getId(); if (id != null && id instanceof AgencyAndId) { IdentityBean<AgencyAndId> bean = (IdentityBean<AgencyAndId>) entity; AgencyAndId agencyAndId = bean.getId(); AgencyAndId newAgencyAndId; if (this.getDuplicateRenamingStrategy() == EDuplicateRenamingStrategy.AGENCY) { newAgencyAndId = MergeSupport.renameAgencyAndId(agencyAndId.getAgencyId()+"-", agencyAndId); _log.debug(agencyAndId.toString() + " renamed(1) to " + newAgencyAndId); } else { newAgencyAndId = MergeSupport.renameAgencyAndId(context, agencyAndId); _log.debug(agencyAndId.toString() + " renamed(2) to " + newAgencyAndId); } bean.setId(newAgencyAndId); } }