use of org.jbei.ice.lib.dto.entry.ParsedEntryId in project ice by JBEI.
the class Entries method validateEntries.
/**
* @param stream csv file input stream
*/
public List<ParsedEntryId> validateEntries(InputStream stream) throws IOException {
List<ParsedEntryId> accepted = new ArrayList<>();
EntryAuthorization authorization = new EntryAuthorization();
try (CSVReader reader = new CSVReader(new InputStreamReader(stream, StandardCharsets.UTF_8))) {
List<String[]> results = reader.readAll();
for (String[] result : results) {
if (result[0].isEmpty())
continue;
Entry entry = dao.getByPartNumber(result[0]);
if (entry == null || !authorization.canRead(this.userId, entry)) {
accepted.add(new ParsedEntryId(result[0], null));
continue;
}
PartData partData = new PartData(EntryType.nameToType(entry.getRecordType()));
partData.setPartId(entry.getPartNumber());
partData.setId(entry.getId());
accepted.add(new ParsedEntryId(result[0], partData));
}
}
return accepted;
}
Aggregations