use of org.jbei.ice.lib.dto.Setting in project ice by JBEI.
the class FileResource method downloadCSV.
/**
* Extracts the csv information and writes it to the temp dir and returns the file uuid. Then
* the client is expected to make another rest call with the uuid in a separate window. This
* workaround is due to not being able to download files using XHR or sumsuch
*/
@POST
@Path("csv")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response downloadCSV(@QueryParam("sequenceFormats") final List<String> sequenceFormats, @QueryParam("entryFields") final List<String> fields, EntrySelection selection) {
String userId = super.requireUserId();
EntriesAsCSV entriesAsCSV = new EntriesAsCSV(sequenceFormats.toArray(new String[sequenceFormats.size()]));
List<EntryField> entryFields = new ArrayList<>();
try {
if (fields != null) {
entryFields.addAll(fields.stream().map(EntryField::fromString).collect(Collectors.toList()));
}
} catch (Exception e) {
Logger.error(e);
}
boolean success = entriesAsCSV.setSelectedEntries(userId, selection, entryFields.toArray(new EntryField[entryFields.size()]));
if (!success)
return super.respond(false);
final File file = entriesAsCSV.getFilePath().toFile();
if (file.exists()) {
return Response.ok(new Setting("key", file.getName())).build();
}
return Response.serverError().build();
}
use of org.jbei.ice.lib.dto.Setting in project ice by JBEI.
the class ConfigurationController method retrieveSystemSettings.
public ArrayList<Setting> retrieveSystemSettings(String userId) {
ArrayList<Setting> settings = new ArrayList<>();
if (!new AccountController().isAdministrator(userId))
return settings;
for (ConfigurationKey key : ConfigurationKey.values()) {
Configuration configuration = dao.get(key);
Setting setting;
if (configuration == null)
setting = new Setting(key.name(), "");
else
setting = new Setting(configuration.getKey(), configuration.getValue());
settings.add(setting);
}
return settings;
}
use of org.jbei.ice.lib.dto.Setting in project ice by JBEI.
the class WebResource method getWebEntries.
@GET
@Path("/entries")
public Response getWebEntries(@QueryParam("download") boolean download, @QueryParam("limit") int limit, @QueryParam("offset") int offset) {
String userId = requireUserId();
log(userId, "downloading web entries");
RemoteEntriesAsCSV remoteEntriesAsCSV = new RemoteEntriesAsCSV(true);
remoteEntriesAsCSV.getEntries(offset, limit);
final File file = remoteEntriesAsCSV.getFilePath().toFile();
if (file.exists()) {
return Response.ok(new Setting("fileName", file.getName())).build();
}
return super.respond(false);
}
Aggregations