use of org.springframework.jdbc.core.namedparam.MapSqlParameterSource in project perun by CESNET.
the class AttributesManagerImpl method getAllAttributesStartWithNameWithoutNullValue.
public List<Attribute> getAllAttributesStartWithNameWithoutNullValue(PerunSession sess, Group group, String startPartOfName) throws InternalErrorException {
MapSqlParameterSource parameters = new MapSqlParameterSource();
parameters.addValue("gId", group.getId());
parameters.addValue("nSC", AttributesManager.NS_GROUP_ATTR_CORE);
parameters.addValue("nSO", AttributesManager.NS_GROUP_ATTR_OPT);
parameters.addValue("nSD", AttributesManager.NS_GROUP_ATTR_DEF);
parameters.addValue("startPartOfName", startPartOfName + "%");
try {
return namedParameterJdbcTemplate.query("select " + getAttributeMappingSelectQuery("grt") + " from attr_names " + "left join group_attr_values grt on id=grt.attr_id and group_id=:gId " + "where namespace in ( :nSC,:nSO,:nSD ) and attr_names.attr_name LIKE :startPartOfName", parameters, new AttributeRowMapper(sess, this, group));
} catch (EmptyResultDataAccessException ex) {
return new ArrayList<Attribute>();
} catch (RuntimeException ex) {
throw new InternalErrorException(ex);
}
}
use of org.springframework.jdbc.core.namedparam.MapSqlParameterSource in project perun by CESNET.
the class AttributesManagerImpl method getAttributes.
@Override
public List<Attribute> getAttributes(PerunSession sess, Member member, Group group, List<String> attrNames) throws InternalErrorException {
MapSqlParameterSource parameters = new MapSqlParameterSource();
parameters.addValue("mId", member.getId());
parameters.addValue("gId", group.getId());
parameters.addValue("nSO", AttributesManager.NS_MEMBER_GROUP_ATTR_OPT);
parameters.addValue("nSD", AttributesManager.NS_MEMBER_GROUP_ATTR_DEF);
parameters.addValue("nSV", AttributesManager.NS_MEMBER_GROUP_ATTR_VIRT);
parameters.addValue("attrNames", attrNames);
try {
return namedParameterJdbcTemplate.query("select " + getAttributeMappingSelectQuery("mem_gr") + " from attr_names " + "left join member_group_attr_values mem_gr on id=mem_gr.attr_id and member_id=:mId and group_id=:gId " + "where namespace in ( :nSO,:nSD,:nSV ) and attr_names.attr_name in ( :attrNames )", parameters, new AttributeRowMapper(sess, this, member, group));
} catch (EmptyResultDataAccessException ex) {
return new ArrayList<Attribute>();
} catch (RuntimeException ex) {
throw new InternalErrorException(ex);
}
}
use of org.springframework.jdbc.core.namedparam.MapSqlParameterSource in project perun by CESNET.
the class AttributesManagerImpl method getAttributes.
public List<Attribute> getAttributes(PerunSession sess, Group group, List<String> attrNames) throws InternalErrorException {
MapSqlParameterSource parameters = new MapSqlParameterSource();
parameters.addValue("gId", group.getId());
parameters.addValue("nSC", AttributesManager.NS_GROUP_ATTR_CORE);
parameters.addValue("nSO", AttributesManager.NS_GROUP_ATTR_OPT);
parameters.addValue("nSD", AttributesManager.NS_GROUP_ATTR_DEF);
parameters.addValue("nSV", AttributesManager.NS_GROUP_ATTR_VIRT);
parameters.addValue("attrNames", attrNames);
try {
return namedParameterJdbcTemplate.query("select " + getAttributeMappingSelectQuery("groupattr") + " from attr_names " + "left join group_attr_values groupattr on id=groupattr.attr_id and group_id=:gId " + "where namespace in ( :nSC,:nSO,:nSD,:nSV ) and attr_names.attr_name in ( :attrNames )", parameters, new AttributeRowMapper(sess, this, group));
} catch (EmptyResultDataAccessException ex) {
return new ArrayList<Attribute>();
} catch (RuntimeException ex) {
throw new InternalErrorException(ex);
}
}
use of org.springframework.jdbc.core.namedparam.MapSqlParameterSource in project perun by CESNET.
the class AttributesManagerImpl method getAttributes.
public List<Attribute> getAttributes(PerunSession sess, User user, List<String> attrNames) throws InternalErrorException {
MapSqlParameterSource parameters = new MapSqlParameterSource();
parameters.addValue("uId", user.getId());
parameters.addValue("nSC", AttributesManager.NS_USER_ATTR_CORE);
parameters.addValue("nSO", AttributesManager.NS_USER_ATTR_OPT);
parameters.addValue("nSD", AttributesManager.NS_USER_ATTR_DEF);
parameters.addValue("nSV", AttributesManager.NS_USER_ATTR_VIRT);
parameters.addValue("attrNames", attrNames);
try {
return namedParameterJdbcTemplate.query("select " + getAttributeMappingSelectQuery("usr") + " from attr_names " + "left join user_attr_values usr on id=usr.attr_id and user_id=:uId " + "where namespace in ( :nSC,:nSO,:nSD,:nSV ) and attr_names.attr_name in ( :attrNames )", parameters, new AttributeRowMapper(sess, this, user));
} catch (EmptyResultDataAccessException ex) {
return new ArrayList<Attribute>();
} catch (RuntimeException ex) {
throw new InternalErrorException(ex);
}
}
use of org.springframework.jdbc.core.namedparam.MapSqlParameterSource in project perun by CESNET.
the class AttributesManagerImpl method getAttributes.
public List<Attribute> getAttributes(PerunSession sess, Member member, List<String> attrNames) throws InternalErrorException {
MapSqlParameterSource parameters = new MapSqlParameterSource();
parameters.addValue("mId", member.getId());
parameters.addValue("nSC", AttributesManager.NS_MEMBER_ATTR_CORE);
parameters.addValue("nSO", AttributesManager.NS_MEMBER_ATTR_OPT);
parameters.addValue("nSD", AttributesManager.NS_MEMBER_ATTR_DEF);
parameters.addValue("nSV", AttributesManager.NS_MEMBER_ATTR_VIRT);
parameters.addValue("attrNames", attrNames);
try {
return namedParameterJdbcTemplate.query("select " + getAttributeMappingSelectQuery("mem") + " from attr_names " + "left join member_attr_values mem on id=mem.attr_id and member_id=:mId " + "where namespace in ( :nSC,:nSO,:nSD,:nSV ) and attr_names.attr_name in ( :attrNames )", parameters, new AttributeRowMapper(sess, this, member));
} catch (EmptyResultDataAccessException ex) {
return new ArrayList<Attribute>();
} catch (RuntimeException ex) {
throw new InternalErrorException(ex);
}
}
Aggregations