@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; }
/** * 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; }
private void expungeCurrentVersionOfResource(Long theResourceId, AtomicInteger theRemainingCount) { ResourceTable resource = myResourceTableDao.findById(theResourceId).orElseThrow(IllegalStateException::new); ResourceHistoryTable currentVersion = myResourceHistoryTableDao.findForIdAndVersion(resource.getId(), resource.getVersion()); if (currentVersion != null) { expungeHistoricalVersion(currentVersion.getId()); } ourLog.info("Expunging current version of resource {}", resource.getIdDt().getValue()); myResourceIndexedSearchParamUriDao.deleteAll(resource.getParamsUri()); myResourceIndexedSearchParamCoordsDao.deleteAll(resource.getParamsCoords()); myResourceIndexedSearchParamDateDao.deleteAll(resource.getParamsDate()); myResourceIndexedSearchParamNumberDao.deleteAll(resource.getParamsNumber()); myResourceIndexedSearchParamQuantityDao.deleteAll(resource.getParamsQuantity()); myResourceIndexedSearchParamStringDao.deleteAll(resource.getParamsString()); myResourceIndexedSearchParamTokenDao.deleteAll(resource.getParamsToken()); myResourceLinkDao.deleteAll(resource.getResourceLinks()); myResourceLinkDao.deleteAll(resource.getResourceLinksAsTarget()); myResourceTagDao.deleteAll(resource.getTags()); resource.getTags().clear(); if (resource.getForcedId() != null) { ForcedId forcedId = resource.getForcedId(); resource.setForcedId(null); myResourceTableDao.saveAndFlush(resource); myIdHelperService.delete(forcedId); } myResourceTableDao.delete(resource); theRemainingCount.decrementAndGet(); }
/** * 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; }
private void expungeCurrentVersionOfResource(Long theResourceId, AtomicInteger theRemainingCount) { ResourceTable resource = myResourceTableDao.findById(theResourceId).orElseThrow(IllegalStateException::new); ResourceHistoryTable currentVersion = myResourceHistoryTableDao.findForIdAndVersion(resource.getId(), resource.getVersion()); if (currentVersion != null) { expungeHistoricalVersion(currentVersion.getId()); } ourLog.info("Expunging current version of resource {}", resource.getIdDt().getValue()); myResourceIndexedSearchParamUriDao.deleteAll(resource.getParamsUri()); myResourceIndexedSearchParamCoordsDao.deleteAll(resource.getParamsCoords()); myResourceIndexedSearchParamDateDao.deleteAll(resource.getParamsDate()); myResourceIndexedSearchParamNumberDao.deleteAll(resource.getParamsNumber()); myResourceIndexedSearchParamQuantityDao.deleteAll(resource.getParamsQuantity()); myResourceIndexedSearchParamStringDao.deleteAll(resource.getParamsString()); myResourceIndexedSearchParamTokenDao.deleteAll(resource.getParamsToken()); myResourceLinkDao.deleteAll(resource.getResourceLinks()); myResourceLinkDao.deleteAll(resource.getResourceLinksAsTarget()); myResourceTagDao.deleteAll(resource.getTags()); resource.getTags().clear(); if (resource.getForcedId() != null) { ForcedId forcedId = resource.getForcedId(); resource.setForcedId(null); myResourceTableDao.saveAndFlush(resource); myIdHelperService.delete(forcedId); } myResourceTableDao.delete(resource); theRemainingCount.decrementAndGet(); }