use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.
the class SolrIndexer method clearDatabase.
public void clearDatabase(String query) {
try {
if (query != null && !query.equals(""))
solrServer.deleteByQuery(query);
else
solrServer.deleteByQuery("*:*");
solrServer.commit();
solrServer.optimize();
} catch (SolrServerException | IOException e) {
throw new NextProtException(e);
}
}
use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.
the class SolrIndexer method commit.
public void commit() {
try {
solrServer.commit();
solrServer.optimize();
} catch (SolrServerException | IOException e) {
throw new NextProtException(e);
}
}
use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.
the class UserDaoImpl method updateUser.
@Override
public void updateUser(User src) {
final String UPDATE_SQL = sqlDictionary.getSQLQuery("update-user");
MapSqlParameterSource namedParameters = new MapSqlParameterSource();
// key to identify application to be updated
namedParameters.addValue("user_id", src.getId());
// values to update
namedParameters.addValue("user_name", src.getUsername());
namedParameters.addValue("first_name", src.getFirstName());
namedParameters.addValue("last_name", src.getLastName());
NamedParameterJdbcTemplate jdbcTemplate = new NamedParameterJdbcTemplate(dsLocator.getUserDataSource());
int affectedRows = jdbcTemplate.update(UPDATE_SQL, namedParameters);
if (affectedRows != 1) {
String msg = "oops something wrong occurred" + affectedRows + " rows were affected instead of only 1.";
Logger.error(msg);
throw new NextProtException(msg);
}
if (src.getAuthorities() != null && !src.getAuthorities().isEmpty()) {
// 1. delete all roles for this user if roles exist in user_roles table of src
deleteUserRoles(src.getId());
// 2. insert roles with insertUserRoles(src.getKey(), src.getRoles())
insertUserAuthorities(src.getId(), src.getAuthorities());
}
}
use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.
the class UserQueryDaoImpl method updateUserQuery.
@Override
public void updateUserQuery(final UserQuery src) {
final String UPDATE_SQL = sqlDictionary.getSQLQuery("update-user-query");
MapSqlParameterSource namedParameters = new MapSqlParameterSource();
// key to identify query to update
namedParameters.addValue("query_id", src.getUserQueryId());
// values to update
namedParameters.addValue("title", src.getTitle());
namedParameters.addValue("description", src.getDescription());
namedParameters.addValue("sparql", src.getSparql());
namedParameters.addValue("published", src.getPublished() ? 'Y' : 'N');
NamedParameterJdbcTemplate jdbcTemplate = new NamedParameterJdbcTemplate(dsLocator.getUserDataSource());
int affectedRows = jdbcTemplate.update(UPDATE_SQL, namedParameters);
if (affectedRows != 1) {
String msg = "oops something wrong occurred" + affectedRows + " rows were affected instead of only 1.";
Logger.error(msg);
throw new NextProtException(msg);
}
}
use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.
the class UserApplicationDaoImpl method updateUserApplication.
@Override
public void updateUserApplication(final UserApplication src) {
final String UPDATE_SQL = sqlDictionary.getSQLQuery("update-user-application");
MapSqlParameterSource namedParameters = new MapSqlParameterSource();
// key to identify application to be updated
namedParameters.addValue("application_id", src.getId());
// values to update
namedParameters.addValue("application_name", src.getName());
namedParameters.addValue("description", src.getDescription());
namedParameters.addValue("organisation", src.getOrganisation());
namedParameters.addValue("responsible_name", src.getResponsibleName());
namedParameters.addValue("responsible_email", src.getResponsibleEmail());
namedParameters.addValue("website", src.getWebsite());
namedParameters.addValue("token", src.getToken());
namedParameters.addValue("status", src.getStatus());
namedParameters.addValue("user_data_access", src.getUserDataAccess());
namedParameters.addValue("origins", src.getOrigins());
NamedParameterJdbcTemplate jdbcTemplate = new NamedParameterJdbcTemplate(dsLocator.getUserDataSource());
int affectedRows = jdbcTemplate.update(UPDATE_SQL, namedParameters);
if (affectedRows != 1) {
String msg = "something wrong occurred: " + affectedRows + " rows were affected (expected=1).";
Logger.error(msg);
throw new NextProtException(msg);
}
}
Aggregations