public String translatePidIdToForcedId(String theResourceType, Long theId) { ForcedId forcedId = myForcedIdDao.findByResourcePid(theId); if (forcedId != null) { return forcedId.getResourceType() + '/' + forcedId.getForcedId(); } else { return theResourceType + '/' + theId.toString(); } }
/** * Returns the newly created forced ID. If the entity already had a forced ID, or if * none was created, returns null. */ protected ForcedId createForcedIdIfNeeded(ResourceTable theEntity, IIdType theId, boolean theCreateForPureNumericIds) { if (theId.isEmpty() == false && theId.hasIdPart() && theEntity.getForcedId() == null) { if (!theCreateForPureNumericIds && IdHelperService.isValidPid(theId)) { return null; } ForcedId fid = new ForcedId(); fid.setResourceType(theEntity.getResourceType()); fid.setForcedId(theId.getIdPart()); fid.setResource(theEntity); theEntity.setForcedId(fid); return fid; } return null; }
@Override public ResourceTable findTargetResource(RuntimeSearchParam theNextSpDef, String theNextPathsUnsplit, IIdType theNextId, String theTypeString, Class<? extends IBaseResource> theType, String theId) { ResourceTable target; target = new ResourceTable(); target.setResourceType(theTypeString); if (theNextId.isIdPartValidLong()) { target.setId(theNextId.getIdPartAsLong()); } else { ForcedId forcedId = new ForcedId(); forcedId.setForcedId(theId); target.setForcedId(forcedId); } return target; }
if (isBlank(forcedId.getResourceType())) { ourLog.info("Updating resource {} forcedId type to {}", forcedId.getForcedId(), resourceTable.getResourceType()); forcedId.setResourceType(resourceTable.getResourceType()); myForcedIdDao.save(forcedId);
private boolean resourceIdMatches(ResourceLink theResourceLink, ReferenceParam theReference) { ResourceTable target = theResourceLink.getTargetResource(); IdDt idDt = target.getIdDt(); if (idDt.isIdPartValidLong()) { return theReference.getIdPartAsLong() == idDt.getIdPartAsLong(); } else { ForcedId forcedId = target.getForcedId(); if (forcedId != null) { return forcedId.getForcedId().equals(theReference.getValue()); } else { return false; } } }
static List<Long> translateForcedIdToPids(DaoConfig theDaoConfig, IIdType theId, IForcedIdDao theForcedIdDao) { Validate.isTrue(theId.hasIdPart()); if (theDaoConfig.getResourceClientIdStrategy() != DaoConfig.ClientIdStrategyEnum.ANY && isValidPid(theId)) { return Collections.singletonList(theId.getIdPartAsLong()); } else { List<ForcedId> forcedId; if (theId.hasResourceType()) { forcedId = theForcedIdDao.findByTypeAndForcedId(theId.getResourceType(), theId.getIdPart()); } else { forcedId = theForcedIdDao.findByForcedId(theId.getIdPart()); } if (!forcedId.isEmpty()) { List<Long> retVal = new ArrayList<>(forcedId.size()); for (ForcedId next : forcedId) { retVal.add(next.getResourcePid()); } return retVal; } else { throw new ResourceNotFoundException(theId); } } }
if (isBlank(forcedId.getResourceType())) { ourLog.info("Updating resource {} forcedId type to {}", forcedId.getForcedId(), resourceTable.getResourceType()); forcedId.setResourceType(resourceTable.getResourceType()); myForcedIdDao.save(forcedId);
static List<Long> translateForcedIdToPids(DaoConfig theDaoConfig, IIdType theId, IForcedIdDao theForcedIdDao) { Validate.isTrue(theId.hasIdPart()); if (theDaoConfig.getResourceClientIdStrategy() != DaoConfig.ClientIdStrategyEnum.ANY && isValidPid(theId)) { return Collections.singletonList(theId.getIdPartAsLong()); } else { List<ForcedId> forcedId; if (theId.hasResourceType()) { forcedId = theForcedIdDao.findByTypeAndForcedId(theId.getResourceType(), theId.getIdPart()); } else { forcedId = theForcedIdDao.findByForcedId(theId.getIdPart()); } if (!forcedId.isEmpty()) { List<Long> retVal = new ArrayList<>(forcedId.size()); for (ForcedId next : forcedId) { retVal.add(next.getResourcePid()); } return retVal; } else { throw new ResourceNotFoundException(theId); } } }
@Override public IdDt getIdDt() { if (getForcedId() == null) { Long id = myId; return new IdDt(myResourceType + '/' + id + '/' + Constants.PARAM_HISTORY + '/' + myVersion); } else { return new IdDt(getForcedId().getResourceType() + '/' + getForcedId().getForcedId() + '/' + Constants.PARAM_HISTORY + '/' + myVersion); } }
/** * Returns the newly created forced ID. If the entity already had a forced ID, or if * none was created, returns null. */ protected ForcedId createForcedIdIfNeeded(ResourceTable theEntity, IIdType theId, boolean theCreateForPureNumericIds) { if (theId.isEmpty() == false && theId.hasIdPart() && theEntity.getForcedId() == null) { if (!theCreateForPureNumericIds && IdHelperService.isValidPid(theId)) { return null; } ForcedId fid = new ForcedId(); fid.setResourceType(theEntity.getResourceType()); fid.setForcedId(theId.getIdPart()); fid.setResource(theEntity); theEntity.setForcedId(fid); return fid; } return null; }
@Override public IdDt getIdDt() { if (getForcedId() == null) { Long id = myResourceId; return new IdDt(myResourceType + '/' + id + '/' + Constants.PARAM_HISTORY + '/' + getVersion()); } else { return new IdDt(getForcedId().getResourceType() + '/' + getForcedId().getForcedId() + '/' + Constants.PARAM_HISTORY + '/' + getVersion()); } }
public String translatePidIdToForcedId(String theResourceType, Long theId) { ForcedId forcedId = myForcedIdDao.findByResourcePid(theId); if (forcedId != null) { return forcedId.getResourceType() + '/' + forcedId.getForcedId(); } else { return theResourceType + '/' + theId.toString(); } }