* @throws DatabaseException
* if a database error occurs
*/
- public Group createGroup(String name) throws DatabaseException {
+ public Group createGroup(String name, String shortName) throws DatabaseException {
Query query = new Query(Type.INSERT, "GROUPS");
String id = UUID.randomUUID().toString();
query.addValueField(new ValueField("ID", new StringParameter(id)));
query.addValueField(new ValueField("NAME", new StringParameter(name)));
+ query.addValueField(new ValueField("SHORT_NAME", new StringParameter(shortName)));
database.insert(query);
return getGroupById(id);
}
public void saveGroup(Group group) throws DatabaseException {
Query query = new Query(Type.UPDATE, "GROUPS");
query.addValueField(new ValueField("NAME", new StringParameter(group.getName())));
+ query.addValueField(new ValueField("SHORT_NAME", new StringParameter(group.getShortName())));
query.addWhereClause(new ValueFieldWhereClause(new ValueField("ID", new StringParameter(group.getId()))));
database.update(query);
/* save properties. */
*/
@Override
public Group createObject(ResultSet resultSet) throws SQLException {
- return new LazyGroup(resultSet.getString("GROUPS.ID")).setName(resultSet.getString("GROUPS.NAME"));
+ return new LazyGroup(resultSet.getString("GROUPS.ID")).setName(resultSet.getString("GROUPS.NAME")).setShortName(resultSet.getString("GROUPS.SHORT_NAME"));
}
}
* {@inheritDoc}
*/
@Override
+ public String getShortName() {
+ return getValue("shortName", String.class).get();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Group setShortName(String shortName) {
+ getValue("shortName", String.class).set(shortName);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
@SuppressWarnings("unchecked")
public Collection<Artist> getArtists() {
return getValue("artists", Collection.class).get();
public Group setName(String name);
/**
+ * Returns the short name of this group.
+ *
+ * @return The short name of this group, or {@code null} if this group does
+ * not have a short name
+ */
+ public String getShortName();
+
+ /**
+ * Sets the short name of this group.
+ *
+ * @param shortName
+ * The new short name of this group
+ * @return This group
+ */
+ public Group setShortName(String shortName);
+
+ /**
* Returns all artists belonging to this group.
*
* @return All artists belonging to this group
super.processTemplate(templateContext, request);
if (request.getMethod() == Method.POST) {
String name = request.getServletRequest().getParameter("name").trim();
+ String shortName = request.getServletRequest().getParameter("shortName").trim();
if (name.length() == 0) {
templateContext.set("error", "no-name-given");
return;
}
+ if (shortName.length() == 0) {
+ shortName = null;
+ }
try {
- Group group = getCore().getDataManager().createGroup(name);
+ Group group = getCore().getDataManager().createGroup(name, shortName);
throw new RedirectException("admin.edit-group?id=" + group.getId());
} catch (DatabaseException de1) {
throw new RuntimeException("Could not create group.", de1);
if (request.getMethod() == Method.POST) {
String name = request.getServletRequest().getParameter("name");
group.setName(name);
+ String shortName = request.getServletRequest().getParameter("shortName").trim();
+ group.setShortName((shortName.length() == 0) ? null : shortName);
/* process property changes. */
processProperties(request, group);
<input type="hidden" name="id" value="<%group.id|html>"/>
- <label>Name: <input type="text" name="name" value="<% group.name|html>"></label>
+ <div>
+ Name:
+ <input type="text" name="name" value="<% group.name|html>">
+ </div>
+ <div>
+ Short Name:
+ <input type="text" name="shortName" value="<% group.shortName|html>">
+ </div>
<button type="submit">Edit Group</button>
<%foreach group.properties property>
<div>
Name:
<input type="text" name="name" value=""/>
- <button type="submit">Add Group</button>
</div>
+ <div>
+ Short Name:
+ <input type="text" name="shortName" value="">
+ </div>
+ <button type="submit">Add Group</button>
</form>