diff --git a/core/dao/src/main/java/gallerymine/backend/beans/repository/ImportRequestRepository.java b/core/dao/src/main/java/gallerymine/backend/beans/repository/ImportRequestRepository.java index 6f9f5d9..7c56aa6 100644 --- a/core/dao/src/main/java/gallerymine/backend/beans/repository/ImportRequestRepository.java +++ b/core/dao/src/main/java/gallerymine/backend/beans/repository/ImportRequestRepository.java @@ -41,6 +41,8 @@ public interface ImportRequestRepository extends MongoRepository findByParent(String parent, Pageable pageable); + Page findByParentAndIndexProcessIds(String parent, String processId, Pageable pageable); + Collection findByParent(String parent); Page findByParentNull(Pageable pageable); diff --git a/core/libs/image-importer/src/main/java/gallerymine/backend/importer/ImportApproveProcessor.java b/core/libs/image-importer/src/main/java/gallerymine/backend/importer/ImportApproveProcessor.java index f982933..078b984 100644 --- a/core/libs/image-importer/src/main/java/gallerymine/backend/importer/ImportApproveProcessor.java +++ b/core/libs/image-importer/src/main/java/gallerymine/backend/importer/ImportApproveProcessor.java @@ -48,7 +48,7 @@ public ImportApproveProcessor() { } public void requestProcessing(ImportRequest request, Process process) throws ImportFailedException { - log.warn(this.getClass().getSimpleName()+" approve processing id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); + log.warn(" approve processing start id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); ImportRequest.ImportStats stats = request.getStats(processType); ImportRequest.ImportStats statsEnum = request.getStats(ProcessType.MATCHING); stats.setFolders(statsEnum.getFolders()); @@ -65,7 +65,7 @@ public void requestProcessing(ImportRequest request, Process process) throws Imp requestRepository.save(request); } - log.info(this.getClass().getSimpleName()+" matching processing id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); + log.info(" approve processing done id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); } } \ No newline at end of file diff --git a/core/libs/image-importer/src/main/java/gallerymine/backend/importer/ImportMatchingProcessor.java b/core/libs/image-importer/src/main/java/gallerymine/backend/importer/ImportMatchingProcessor.java index c11f410..3a8b043 100644 --- a/core/libs/image-importer/src/main/java/gallerymine/backend/importer/ImportMatchingProcessor.java +++ b/core/libs/image-importer/src/main/java/gallerymine/backend/importer/ImportMatchingProcessor.java @@ -58,6 +58,7 @@ public ImportMatchingProcessor() { } public void requestProcessing(ImportRequest request, Process process) throws ImportFailedException { + log.warn(" matching processing start id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); Path path = appConfig.getImportRootFolderPath().resolve(request.getPath()); if (!validateImportRequest(process, path)) @@ -69,7 +70,7 @@ public void requestProcessing(ImportRequest request, Process process) throws Imp stats.setFolders(statsEnum.getFolders()); stats.setFiles(statsEnum.getFilesDone()); requestRepository.save(request); - log.info(this.getClass().getSimpleName()+" matching processing id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); + log.info(" matching processing id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); try { int filesCount = 0; int filesSucceedCount = 0; @@ -96,14 +97,17 @@ public void requestProcessing(ImportRequest request, Process process) throws Imp .incFilesDone(); } catch (Exception e) { request.getStats(processType).incFailed(); - log.error(this.getClass().getSimpleName()+" Failed processing info id=%s path=%s", info.getId(), info.getFileName()); + log.error(" matching processing failed: Failed processing info id={} path={}", info.getId(), info.getFileName()); } + log.info(" matching processing done {} or {} succeeded. id={} status={} path={}", + filesCount, filesSucceedCount, + request.getId(), request.getStatus(), request.getPath()); requestRepository.save(request); } String info = request.addNote("Matching info gathered for id=%s files %d of %d. Failed:%d", request.getId(), filesSucceedCount, filesCount, filesCount-filesSucceedCount); - log.info(this.getClass().getSimpleName()+" "+info); + log.info(" "+info); request.setStatus(statusHolder.getProcessingDone()); request.getStats(processType).setAllFilesProcessed(true); @@ -111,8 +115,9 @@ public void requestProcessing(ImportRequest request, Process process) throws Imp } catch (Exception e) { request.addError("Matching info analysing failed for indexRequest id=%s", request.getId()); requestRepository.save(request); - log.error(this.getClass().getSimpleName()+" Matching info analysing failed for indexRequest id=%s {}. Reason: {}", path, e.getMessage()); + log.error(" matching processing failed: Matching info analysing failed for indexRequest id=%s {}. Reason: {}", path, e.getMessage()); } + log.warn(" matching processing done id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); } } \ No newline at end of file diff --git a/core/libs/image-importer/src/main/java/gallerymine/backend/importer/ImportProcessor.java b/core/libs/image-importer/src/main/java/gallerymine/backend/importer/ImportProcessor.java index 20e1291..7f2f2d5 100644 --- a/core/libs/image-importer/src/main/java/gallerymine/backend/importer/ImportProcessor.java +++ b/core/libs/image-importer/src/main/java/gallerymine/backend/importer/ImportProcessor.java @@ -122,16 +122,19 @@ public ImportRequest registerImport(Path originalPath, boolean enforceImport) { } */ public void requestProcessing(ImportRequest requestSrc, Process process) throws ImportFailedException { + log.warn(" import processing start id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); Path path = appConfig.getImportRootFolderPath().resolve(request.getPath()); if (!validateImportRequest(process, path)) return; + ImportRequest.ImportStatus oldStatus = request.getStatus(); request.setStatus(statusHolder.getInProcessing()); request.getStats(processType).getFiles().set(-1); requestRepository.save(request); Path enumeratingDir = null; + log.info(" folders enumerating id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); try (DirectoryStream directoryStreamOfFolders = Files.newDirectoryStream(path, file -> file.toFile().isDirectory())) { int foldersCount = 0; for (Path dir : directoryStreamOfFolders) { @@ -143,26 +146,29 @@ public void requestProcessing(ImportRequest requestSrc, Process process) throws request.setFoldersCount(foldersCount); request.getStats(processType).incFolders(foldersCount); requestRepository.save(request); - log.info("ImportRequest status changed id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); + log.info(" folders processed {}. id={} status={} path={}", + foldersCount, + request.getId(), request.getStatus(), request.getPath()); } catch (IOException e) { request.setFoldersCount(-1); request.addError("ImportRequest indexing failed for folder "+enumeratingDir); requestRepository.save(request); - log.error("ImportRequest Failed to index. id={} status={} path={} reason='{}'", request.getId(), request.getStatus(), request.getPath(), e.getMessage(), e); + log.error(" Failed to index. id={} status={} path={} reason='{}'", request.getId(), request.getStatus(), request.getPath(), e.getMessage(), e); } + log.info(" files enumerating id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); try { - log.info("ImportRequest status changed id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); Path importRootFolder = Paths.get(request.getRootPath()); int filesCount = 0; int filesIgnoredCount = 0; + int filesSucceedCount = 0; ImportRequest.ImportStats stats = request.getStats(processType); try (DirectoryStream directoryStreamOfFiles = Files.newDirectoryStream(path, file -> file.toFile().isFile())) { for (Path file : directoryStreamOfFiles) { String fileName = file.toString().toLowerCase(); String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1); if (fileName.startsWith(".")) { - log.info("ImportRequest Ignore system file {}", file.toAbsolutePath().toString()); + log.info(" Ignore system file {}", file.toAbsolutePath().toString()); continue; } @@ -183,6 +189,7 @@ public void requestProcessing(ImportRequest requestSrc, Process process) throws stats.incMovedToApprove(); info.setRootPath(targetFolder.toFile().getAbsolutePath()); info.setStatus(InfoStatus.ANALYSING); + filesSucceedCount++; } } else { filesIgnoredCount++; @@ -190,7 +197,7 @@ public void requestProcessing(ImportRequest requestSrc, Process process) throws Path targetFolder = importUtils.moveToFailed(file, request.getRootPath()); info.setRootPath(targetFolder.toFile().getAbsolutePath()); info.setStatus(InfoStatus.FAILED); - logUnknownFormats.error("ImportRequest Unknown format of file {}", file.toAbsolutePath().toString()); + logUnknownFormats.error(" Unknown format of file {}", file.toAbsolutePath().toString()); } } else { Path targetFolder = importUtils.moveToFailed(file, request.getRootPath()); @@ -200,7 +207,7 @@ public void requestProcessing(ImportRequest requestSrc, Process process) throws } importSourceRepository.saveByGrade(info); if (!InfoStatus.FAILED.equals(info.getStatus()) && !info.hasThumb()) { - log.warn(" No thumbnail injected - need to generate one for {} in {}", info.getFileName(), info.getFilePath()); + log.warn(" No thumbnail injected - need to generate one for {} in {}", info.getFileName(), info.getFilePath()); Path thumbStoredFile = importUtils.generatePicThumbName(info.getFileName(), info.getTimestamp()); String relativeStoredPath = appConfig.relativizePathToThumb(thumbStoredFile.toFile().getAbsolutePath()); ThumbRequest request = new ThumbRequest(info.getFullFilePath(), relativeStoredPath); @@ -215,19 +222,23 @@ public void requestProcessing(ImportRequest requestSrc, Process process) throws stats.setAllFilesProcessed(true); stats.getFiles().set(filesCount); if (stats.getFilesDone().get() != filesCount) { - log.warn("Cound Mismatch for ImportRequest id={} done={} <> {}", + log.warn(" Count Mismatch for ImportRequest id={} done={} <> {}", request.getId(), stats.getFilesDone().get() , filesCount); } stats.getFilesDone().set(filesCount); requestRepository.save(request); + log.info(" files processing done {} or {} succeeded ({} ignored). id={} status={} path={}", + filesCount, filesSucceedCount, filesIgnoredCount, + request.getId(), request.getStatus(), request.getPath()); } catch (IOException e) { request.setFilesCount(-1); request.setFilesIgnoredCount(-1); request.getStats(processType).setAllFilesProcessed(true); request.addError("indexing failed for file "+path); requestRepository.save(request); - log.error("ImportRequest indexing failed for file {}. Reason: {}", path, e.getMessage()); + log.error(" import processing failed for file {}. Reason: {}", path, e.getMessage()); } + log.warn(" import processing done id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); } /** @@ -285,6 +296,7 @@ public ImportRequest registerNewImportFolderRequest(String path, ImportRequest p } catch (FileNotFoundException e) { throw new ImportFailedException("File not found "+ path, e); } + log.info(" register new Import path={} processId={} {}", path, indexProcessId, parent != null ? ("path="+parent.getPath()) : ""); ImportRequest newRequest = requestRepository.findByPath(path); if (newRequest == null) { newRequest = new ImportRequest(); @@ -308,7 +320,8 @@ public ImportRequest registerNewImportFolderRequest(String path, ImportRequest p newRequest.setRootId(newRequest.getId()); } requestRepository.save(newRequest); - log.info("ImportRequest status changed id={} status={} path={}", newRequest.getId(), newRequest.getStatus(), newRequest.getPath()); + log.info(" registered as id={} status={} path={} processid={} {}", newRequest.getId(), newRequest.getStatus(), newRequest.getPath(), + indexProcessId, parent != null ? ("path="+parent.getPath()) : ""); return newRequest; } diff --git a/core/libs/image-importer/src/main/java/gallerymine/backend/importer/ImportProcessorBase.java b/core/libs/image-importer/src/main/java/gallerymine/backend/importer/ImportProcessorBase.java index f433ab2..1f7cc9b 100644 --- a/core/libs/image-importer/src/main/java/gallerymine/backend/importer/ImportProcessorBase.java +++ b/core/libs/image-importer/src/main/java/gallerymine/backend/importer/ImportProcessorBase.java @@ -72,7 +72,7 @@ public ImportProcessorBase(ImportApproveRequestPoolManager.StatusHolder statuses protected boolean validateImportRequest(Process process, Path path) { if (!path.toFile().exists()) { String error = request.addError("Path not found for request : %s", path.toFile().getAbsolutePath()); - log.error(this.getClass().getSimpleName()+" "+error); + log.error(" "+error); request.setStatus(statusHolder.getProcessingDone()); requestRepository.save(request); @@ -87,7 +87,7 @@ protected boolean validateImportRequest(Process process, Path path) { public void run() { Process process = null; try { - log.info(this.getClass().getSimpleName()+" processing started for {}", request.getPath()); + log.info(" processing started for {}", request.getPath()); process = processRepository.findByIdInAndTypeIs(request.getIndexProcessIds(), processType); if (process == null) { process = new Process(); @@ -100,26 +100,26 @@ public void run() { processRequest(request, process); - log.info(this.getClass().getSimpleName()+" processing started successfuly for {}", request.getPath()); + log.info(" processing started successfuly for {}", request.getPath()); } catch (Exception e){ - log.error(this.getClass().getSimpleName()+" processing failed for {} Reason: {}", request.getPath(), e.getMessage(), e); + log.error(" processing failed for {} Reason: {}", request.getPath(), e.getMessage(), e); } } protected ImportRequest checkRequest(ImportRequest requestSrc) { ImportRequest request = requestRepository.findOne(requestSrc.getId()); if (request == null) { - log.info(this.getClass().getSimpleName()+" not found for id={} and path={}", requestSrc.getId(), requestSrc.getPath()); + log.info(" not found for id={} and path={}", requestSrc.getId(), requestSrc.getPath()); return null; } if (!statusHolder.getAwaitingProcessing().equals(request.getStatus())) { - log.info(this.getClass().getSimpleName()+" status is not processable id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); + log.info(" status is not processable id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); return null; } // request.setStatus(statusHolder.getAwaitingProcessing()); // requestRepository.save(request); -// log.info(this.getClass().getSimpleName()+" status changed id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); +// log.info(" status changed id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); return request; } @@ -127,13 +127,13 @@ protected ImportRequest checkRequest(ImportRequest requestSrc) { public abstract void requestProcessing(ImportRequest requestSrc, Process process) throws ImportFailedException; public void processRequest(ImportRequest requestSrc, Process process) { - log.info(this.getClass().getSimpleName()+" picked up id={} status={} path={}", requestSrc.getId(), requestSrc.getStatus(), requestSrc.getPath()); + log.info(" picked up id={} status={} path={}", requestSrc.getId(), requestSrc.getStatus(), requestSrc.getPath()); ImportRequest request = checkRequest(requestSrc); if (request == null) { - log.info(this.getClass().getSimpleName()+" skipped id={} status={} path={}", requestSrc.getId(), requestSrc.getStatus(), requestSrc.getPath()); + log.info(" skipped id={} status={} path={}", requestSrc.getId(), requestSrc.getStatus(), requestSrc.getPath()); return; } - log.info(this.getClass().getSimpleName()+" started processing id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); + log.info(" processing started id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); try { requestProcessing(requestSrc, process); @@ -144,8 +144,9 @@ public void processRequest(ImportRequest requestSrc, Process process) { request.addError(e.getMessage()); requestRepository.save(request); importService.finishRequestProcessing(request); - log.info(this.getClass().getSimpleName()+" status changed id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); + log.info(" status changed id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); } finally { + log.info(" processing done id={} status={} path={}", request.getId(), request.getStatus(), request.getPath()); pool.checkForAwaitingRequests(); } } diff --git a/core/libs/image-importer/src/main/java/gallerymine/backend/services/ImportService.java b/core/libs/image-importer/src/main/java/gallerymine/backend/services/ImportService.java index 26ddfb9..b23613d 100644 --- a/core/libs/image-importer/src/main/java/gallerymine/backend/services/ImportService.java +++ b/core/libs/image-importer/src/main/java/gallerymine/backend/services/ImportService.java @@ -113,7 +113,7 @@ public void checkIfMatchNeeded(ImportRequest rootImportRequest, Process process) long toMatch = rootImportRequest.getTotalStats(process.getType()).getMovedToApprove().get(); Process processOfMatching = null; if (toMatch > 0) { - log.info("ImportService Matching is needed for {} images", toMatch); + log.info("Matching is needed for {} images for id={}", toMatch, process.getId()); processOfMatching = new Process(); processOfMatching.setName("Processing of Matching"); processOfMatching.setStatus(ProcessStatus.PREPARING); @@ -123,19 +123,20 @@ public void checkIfMatchNeeded(ImportRequest rootImportRequest, Process process) processRepository.save(processOfMatching); - process.addNote("ImportService Matching process initiated %s", processOfMatching.getId()); + process.addNote("Matching process initiated %s", processOfMatching.getId()); processRepository.save(process); // update ImportRequests to TO_MATCH with processOfMatching uniSourceRepository.updateAllRequestsToNextProcess(process.getId(), processOfMatching.getId(), ENUMERATION_COMPLETE, TO_MATCH, ProcessType.MATCHING); requestMatchPool.executeRequest(rootImportRequest); + log.info(" initiated Matching id={} from Import id={}", processOfMatching.getId(), process.getId()); } else { - process.addNote("ImportService Matching process not required"); + process.addNote("Matching process not required"); processRepository.save(process); } } else { - log.info("ImportService Process not found imports={} importRequest={}", rootImportRequest.getIndexProcessIds(), rootImportRequest.getId()); + log.info("Process not found imports={} importRequest={}", rootImportRequest.getIndexProcessIds(), rootImportRequest.getId()); } } @@ -144,7 +145,7 @@ public void checkIfApproveNeeded(ImportRequest rootImportRequest, Process proces long toApprove = rootImportRequest.getTotalStats(process.getType()).getMovedToApprove().get(); Process processOfApprove = null; if (toApprove > 0) { - log.info("ImportService Approve is needed for {} images", toApprove); + log.info("Approve is needed for {} images for id={}", toApprove, process.getId()); processOfApprove = new Process(); processOfApprove.setName("Processing of Approval"); processOfApprove.setStatus(ProcessStatus.PREPARING); @@ -160,43 +161,45 @@ public void checkIfApproveNeeded(ImportRequest rootImportRequest, Process proces uniSourceRepository.updateAllRequestsToNextProcess(process.getId(), processOfApprove.getId(), MATCHING_COMPLETE, TO_APPROVE, ProcessType.APPROVAL); requestApprovePool.executeRequest(rootImportRequest); + + log.info(" initiated Approve id={} from Matching id={}", processOfApprove.getId(), process.getId()); } else { process.addNote("Approve process not required"); processRepository.save(process); } } else { - log.info("ImportRequest Process not found id={} importRequest={}", process.getId(), rootImportRequest.getId()); + log.info(" Process not found id={} importRequest={}", process.getId(), rootImportRequest.getId()); } } public void checkSubsAndDone(String requestId, ImportRequest child, ProcessType processType, ImportRequest.ImportStatus processingDoneStatus) throws ImportFailedException { if (requestId == null) { - log.error(this.getClass().getSimpleName()+" Failed to check subs for request id={}", requestId); + log.error(" checkSubsAndDone failed: Failed to check subs for request id={}", requestId); return; } ImportRequest request = requestRepository.findOne(requestId); if (request == null) { - log.error(this.getClass().getSimpleName()+" Request not found, failed to check subs for id={}", requestId); + log.error(" checkSubsAndDone failed: Request not found, failed to check subs for id={}", requestId); return; } - + log.info(" checkSubsAndDone for id={} path={}", requestId, request.getPath()); if (child != null) { if (child.getStatus().isFinal()) { - log.info(this.getClass().getSimpleName()+" Adding child substats from id={}", child.getId()); + log.info(" Adding child substats from id={} path={}", child.getId(), child.getPath()); request.getStats(processType).incFoldersDone(); request.getSubStats(processType).append(child.getTotalStats(processType)); requestRepository.save(request); } else { - log.error(this.getClass().getSimpleName()+" Adding child substats from id={} to parent={} while child is not FINISHED", child.getId(), requestId); + log.error(" Adding child substats from id={} path={} to parent={} while child is not FINISHED", child.getId(), child.getPath(), requestId); } } ImportRequest.ImportStats stats = request.getStats(processType); boolean allSubTasksDone = stats.getFolders().get() == stats.getFoldersDone().get(); if (!allSubTasksDone) { - log.debug(this.getClass().getSimpleName()+" id={} Not all subtasks are done", requestId); + log.info(" checkSubsAndDone exit id={} path={} Not all subtasks are done", requestId, request.getPath()); return; } else { if (!stats.getAllFoldersProcessed()) { @@ -215,34 +218,38 @@ public void checkSubsAndDone(String requestId, ImportRequest child, ProcessType } if (!isAllFilesProcessed) { - log.debug(this.getClass().getSimpleName()+" id={} Not all files are processed", requestId); + log.warn(" checkSubsAndDone exit id={} path={} Not all files are processed", requestId, request.getPath()); return; } - ImportRequest.ImportStatus currentStatus = request.getStatus(); + log.info(" checkSubsAndDone passes id={} path={} could be marked as done", requestId, request.getPath()); - boolean someErrors = request.getTotalStats(processType).getFailed().get() > 0; + ImportRequest.ImportStatus currentStatus = request.getStatus(); request.setStatus(processingDoneStatus); requestRepository.save(request); - log.info(this.getClass().getSimpleName()+" status changed id={} oldStatus={} status={} path={}", - request.getId(), currentStatus, request.getStatus(), request.getPath()); + log.info(" status changed id={} path={} oldStatus={} status={}", + request.getId(), request.getPath(), currentStatus, request.getStatus()); if (StringUtils.isNotBlank(request.getParent())) { - log.info(this.getClass().getSimpleName()+" processing parent of id={} parent={}", requestId, request.getParent()); + log.info(" processing parent of id={} path={}, parent={}", requestId, request.getPath(), request.getParent()); checkSubsAndDone(request.getParent(), request, processType, processingDoneStatus); + log.info(" processing parent done of id={} path={}, parent={}", requestId, request.getPath(), request.getParent()); } finishRequestProcessing(request); - log.info(this.getClass().getSimpleName()+" finished id={} status={}", requestId, request.getStatus()); + log.info(" finished id={} path={} status={}", requestId, request.getPath(), request.getStatus()); if (!request.getIndexProcessIds().isEmpty() && // has process StringUtils.isBlank(request.getParent())) { // this is the top import request Process process = processRepository.findByIdInAndTypeIs(request.getIndexProcessIds(), processType); + log.info(" finishing process id={} path={} processId={} processType={}", + requestId, request.getPath(), process.getId(), process.getType()); finishProcess(request, process); onRootImportFinished(request, process); } + log.info(" checkSubsAndDone complete for id={} path={}", requestId, request.getPath()); } private void onRootImportFinished(ImportRequest request, Process process) throws ImportFailedException { @@ -269,7 +276,7 @@ private void onRootImportFinished(ImportRequest request, Process process) throws protected void finishProcess(ImportRequest rootImportRequest, Process process) { ProcessStatus oldStatus = process.getStatus(); - log.info(this.getClass().getSimpleName()+" updating process of id={} process={} oldStatus={} rootImportStatus={}", + log.info(" updating process of id={} process={} oldStatus={} rootImportStatus={}", rootImportRequest.getId(), process.getId(), oldStatus, rootImportRequest.getStatus()); if (rootImportRequest.getStatus().isInProgress()) { process.addError("Import failed"); @@ -279,7 +286,7 @@ protected void finishProcess(ImportRequest rootImportRequest, Process process) { process.setStatus(ProcessStatus.FINISHED); } addImportStats(process, rootImportRequest); - log.info(this.getClass().getSimpleName()+" Process finished of id={} process={} oldStatus={} status={}", + log.info(" Process finished of id={} process={} oldStatus={} status={}", rootImportRequest.getId(), process.getId(), oldStatus, process.getStatus()); } @@ -299,7 +306,7 @@ private void addImportStats(Process process, ImportRequest rootImportRequest) { } public Boolean actionApprove(PictureInformation source) throws Exception { - log.info("ImportService approve for image id={} kind={}", source.getId()); + log.info("approve for image id={} status={}", source.getId(), source.getStatus()); PictureInformation target = uniSourceRepository.fetchOne(source.getId(), GALLERY.getEntityClass()); if (target != null) { @@ -347,6 +354,12 @@ public Boolean actionMarkAsDuplicate(PictureInformation source) throws Exception log.info(" source id={} is already marked as Duplicate", source.getId()); return true; } + PictureInformation target = uniSourceRepository.fetchOne(source.getId(), GALLERY.getEntityClass()); + if (target != null) { + log.info(" source id={} was approved - removing", source.getId()); + uniSourceRepository.delete(target); + } + source.setStatus(DUPLICATE); uniSourceRepository.saveByGrade(source); log.info(" source id={} marked as Duplicate", source.getId()); diff --git a/ui/web/src/assembly/galleryMine.xml b/ui/web/src/assembly/galleryMine.xml index 5c54d55..b90ce39 100644 --- a/ui/web/src/assembly/galleryMine.xml +++ b/ui/web/src/assembly/galleryMine.xml @@ -7,7 +7,7 @@ false - +