/** * Update DataSet in the database * * @param repox2sip * @throws IOException * @throws Repox2SipException */ public synchronized void updateDataSet2Database(Repox2Sip repox2sip) throws IOException, Repox2SipException { DataSet dataSet = repox2sip.getDataSet(this.getIdDb()); dataSet.setNameCode(this.getNameCode()); dataSet.setLanguage(this.getLanguage()); dataSet.setType(DataSetType.ESE); dataSet.setIdQName(this.getId()); dataSet.setName(this.getName()); dataSet.setDescription(this.getDescription()); dataSet.setProvider(repox2sip.getProvider(getDataProvider().getIdDb())); if (this.getRecordIdPolicy() instanceof IdExtracted) { dataSet.setIdQName(((IdExtracted) this.getRecordIdPolicy()).getIdentifierXpath()); } else { dataSet.setIdQName("Calculated by Repox"); } addSpecificInformation(dataSet); repox2sip.updateDataSet(dataSet); }
/** * Delete DataSet from the database * * @param repox2sip * @throws IOException * @throws eu.europeana.repox2sip.Repox2SipException */ public synchronized void deleteDataSourceFromDatabase(Repox2Sip repox2sip) throws IOException, Repox2SipException { repox2sip.removeDataSet(repox2sip.getDataSet(this.getIdDb())); }
public Task.Status startIngest(String taskId, boolean fullIngest) { Repox2Sip repox2sip = RepoxContextUtil.getRepoxManager().getDataManager().getRepox2sip(); Request request = new Request(); File logFile = getLogFile(taskId); Task.Status exitStatus = Task.Status.OK; try { if (RepoxContextUtil.getRepoxManager() .getConfiguration() .getUseSipDataBase() .equals("true")) { // REPOX2SIP Create request DataSet dataSet = repox2sip.getDataSet(this.getIdDb()); request.setDataSet(dataSet); request.setStatus(RequestStatus.UNDER_CONSTRUCTION); request.setCreationDate(new Date()); request = setRequestName(request); repox2sip.addRequest(request); } stopExecution = false; StringUtil.simpleLog( "Starting to import from Data Source with id " + id, this.getClass(), logFile); lastUpdate = getSynchronizationDate(); Date now = new Date(); exitStatus = ingestRecords(request, logFile, fullIngest); if (RepoxContextUtil.getRepoxManager() .getConfiguration() .getUseSipDataBase() .equals("true")) { // REPOX2SIP Change request status request.setStatus(getCorrespondentRequestStatus(exitStatus)); repox2sip.updateRequest(request); } lastUpdate = now; if (exitStatus.isSuccessful()) { signalSynchronizationFinished(lastUpdate); } StringUtil.simpleLog( "Finished importing from Data Source with id " + id + ". Exit status: " + exitStatus.toString(), this.getClass(), logFile); sendEmail(exitStatus, logFile); request.setStatus(RequestStatus.IMPORT_COMPLETED); } catch (TemplateException e) { log.error(e.getMessage(), e); StringUtil.simpleLog( "TemplateException: ERROR importing from Data Source with id " + id + ": " + e.getMessage(), this.getClass(), logFile); request.setStatus(RequestStatus.ABORTED); } catch (Repox2SipException e) { log.error(e.getMessage(), e); StringUtil.simpleLog( "Repox2SipException: ERROR importing from Data Source with id " + id + ": " + e.getMessage(), this.getClass(), logFile); request.setStatus(RequestStatus.ABORTED); } catch (MessagingException e) { log.error(e.getMessage(), e); StringUtil.simpleLog( "MessagingException: ERROR importing from Data Source with id " + id + ": " + e.getMessage(), this.getClass(), logFile); request.setStatus(RequestStatus.ABORTED); } catch (IOException e) { log.error(e.getMessage(), e); StringUtil.simpleLog( "IOException: ERROR importing from Data Source with id " + id + ": " + e.getMessage(), this.getClass(), logFile); request.setStatus(RequestStatus.ABORTED); } catch (Exception e) { log.error(e.getMessage(), e); StringUtil.simpleLog( "ERROR importing from Data Source with id " + id + ": " + e.getMessage(), this.getClass(), logFile); request.setStatus(RequestStatus.ABORTED); } return exitStatus; }