/** * Executes this {@link ProcessingStep}. * <br> * <br> * For each {@link Record} contained in the {@link RecordSet} * given as argument, if {@link AbstractFilter#isIncluded} returns * <code>true</code> the Record is included in the return result, * otherwise it is ignored. * * @see ProcessingStep#execute * * @param recs The initial set of records * @return The resulting set after the filter is applied */ @Override public RecordSet execute(RecordSet recs) { RecordSet ret = new RecordSet(); for (Record rec : recs) { if (this.isIncluded(rec)) { ret.addRecord(rec); } } return ret; }
@Override public RecordSet getRecords() throws MalformedSourceException { if (dtoList == null) { throw new MalformedSourceException("dtoList not initialized"); } RecordSet ret = new RecordSet(); for (ItemSubmissionLookupDTO dto : dtoList) { Record rec = dto.getTotalPublication(providers); ret.addRecord(rec); } log.info("BTE DataLoader finished. Items loaded: " + ret.getRecords().size()); // Printing debug message String totalString = ""; for (Record record : ret.getRecords()) { totalString += SubmissionLookupUtils.getPrintableString(record) + "\n"; } log.debug("Records loaded:\n" + totalString); return ret; }
@Override public RecordSet getRecords() throws MalformedSourceException { RecordSet recordSet = new RecordSet(); DataLoader provider = dataloadersMap.get(providerName); RecordSet subRecordSet = provider.getRecords(); recordSet.addAll(subRecordSet); for (Record record : subRecordSet.getRecords()) { if (record.isMutable()) { record.makeMutable().addValue( List<String> foundDOIs = new ArrayList<String>(); for (Record publication : recordSet.getRecords()) { String providerName = SubmissionLookupUtils.getFirstValue( publication, recordSet.addRecord(rec); if (rec.isMutable()) { rec.makeMutable().addValue( + recordSet.getRecords().size()); for (Record record : recordSet.getRecords()) { totalString += SubmissionLookupUtils.getPrintableString(record) + "\n";
@Override public RecordSet getRecords(DataLoadingSpec spec) throws MalformedSourceException { if (spec.getOffset() > 0) { return new RecordSet(); } return getRecords(); }
@Override public List<String> generateOutput(RecordSet recordSet) { log.info("BTE OutputGenerator started. Records to output: " + recordSet.getRecords().size()); // Printing debug message String totalString = ""; for (Record record : recordSet.getRecords()) { totalString += SubmissionLookupUtils.getPrintableString(record) + "\n"; } log.debug("Records to output:\n" + totalString); witems = new ArrayList<WorkspaceItem>(); for (Record rec : recordSet.getRecords()) { try { WorkspaceItem wi = workspaceItemService.create(context, collection, true); merge(formName, wi.getItem(), rec); witems.add(wi); } catch (AuthorizeException e) { log.error(e.getMessage(), e); } catch (SQLException e) { log.error(e.getMessage(), e); } } return new ArrayList<String>(); }
@Override public List<String> generateOutput(RecordSet record_set) { Iterator<Record> rec_it = record_set.iterator(); while (rec_it.hasNext()) { Record rec = rec_it.next(); String [] line = new String[fields_.size()]; for (int i = 0; i < fields_.size(); i++) { List<Value> vals = rec.getValues(fields_.get(i)); if (vals == null || vals.size() == 0) { continue; } String val = ""; for (int j = 0; j < vals.size(); j++) { val += vals.get(j).getAsString(); if(j == vals.size() - 1) { break; } val += "||"; } line[i] = val; } writer_.writeNext(line); } try{ writer_.flush(); } catch(IOException e) { logger_.info(e.getMessage()); } return new ArrayList<String>(); }
assert tmp_recs.size() <= dl_spec.getNumberOfRecords(); if ((tmp_recs.size() < dl_spec.getNumberOfRecords() && dl_spec.getNumberOfRecords() != 0) || end_of_input = true; n_records += tmp_recs.size(); if (tmp_recs.size() == 0) { logger.info("Loaded 0 records. Skipping the rest of the workflow."); continue; logger.info("Loaded " + tmp_recs.size() + " records. Running workflow."); tmp_recs = workflow.run(tmp_recs); kept_records = tmp_recs.size(); logger.info(tmp_recs.size() + " records remain after workflow."); if (tmp_recs.size() == 0) { logger.info("Empty record set. Skiping writting"); continue;
@Override public RecordSet getRecords(DataLoadingSpec spec) throws MalformedSourceException { if (spec.getOffset() > 0) { return new RecordSet(); } return getRecords(); }
@Override public RecordSet getRecords() throws MalformedSourceException { RecordSet recordSet = new RecordSet(); try { InputStream inputStream = new FileInputStream(new File(filename)); DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance(); factory.setValidating(false); factory.setIgnoringComments(true); factory.setIgnoringElementContentWhitespace(true); DocumentBuilder db = factory.newDocumentBuilder(); Document inDoc = db.parse(inputStream); Element xmlRoot = inDoc.getDocumentElement(); // There is no element to represent an record, so we can not process // multi records at once. Record record = CiNiiUtils.convertCiNiiDomToRecord(xmlRoot); if (record != null) { recordSet.addRecord(convertFields(record)); } } catch (FileNotFoundException e) { log.error(e.getMessage(), e); } catch (ParserConfigurationException e) { log.error(e.getMessage(), e); } catch (SAXException e) { log.error(e.getMessage(), e); } catch (IOException e) { log.error(e.getMessage(), e); } return recordSet; }
@Override public RecordSet getRecords(DataLoadingSpec loadingSpec) throws MalformedSourceException { // Identify the end of loading if (loadingSpec.getOffset() > 0) { return new RecordSet(); } return getRecords(); }
/** * Executes this {@link ProcessingStep}. * <br> * <br> * For each {@link Record} contained in the {@link RecordSet} * given as argument, converts it to {@link MutableRecord} calls * {@link AbstractModifier#modify}, and adds the modified record * in the return result. * * @see ProcessingStep#execute * * @param recs The initial set of records * @return A {@link RecordSet} containing the modified records */ @Override public RecordSet execute(RecordSet recs) { RecordSet ret = new RecordSet(); Record modified_record; for (Record rec : recs) { modified_record = this.modify(rec.makeMutable()); ret.addRecord(modified_record); } return recs; }
@Override public RecordSet getRecords(DataLoadingSpec spec) throws MalformedSourceException { if (spec.getOffset() > 0) { return new RecordSet(); } return getRecords(); }
@Override public RecordSet getRecords(DataLoadingSpec spec) throws MalformedSourceException { if (spec.getOffset() > 0) { return new RecordSet(); } return getRecords(); }
@Override public RecordSet getRecords(DataLoadingSpec spec) throws MalformedSourceException { if (spec.getOffset() > 0) { return new RecordSet(); } return getRecords(); }
@Override public RecordSet getRecords() throws MalformedSourceException { RecordSet recordSet = new RecordSet(); try { InputStream inputStream = new FileInputStream(new File(filename)); DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance(); factory.setValidating(false); factory.setIgnoringComments(true); factory.setIgnoringElementContentWhitespace(true); DocumentBuilder db = factory.newDocumentBuilder(); Document inDoc = db.parse(inputStream); Element xmlRoot = inDoc.getDocumentElement(); Element queryResult = XMLUtils.getSingleElement(xmlRoot, "query_result"); Element body = XMLUtils.getSingleElement(queryResult, "body"); Element dataRoot = XMLUtils.getSingleElement(body, "query"); Record record = CrossRefUtils.convertCrossRefDomToRecord(dataRoot); recordSet.addRecord(convertFields(record)); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return recordSet; }
@Override public RecordSet getRecords(DataLoadingSpec spec) throws MalformedSourceException { //Not using the DataLoadingSpec for the moment if (spec.getOffset() > 0) { return new RecordSet(); } return getRecords(); }