Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • arsnova/arsnova-backend
  • pcvl72/arsnova-backend
  • tksl38/arsnova-backend
3 results
Show changes
Showing
with 3054 additions and 56 deletions
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2019 The ARSnova Team and Contributors
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ARSnova Backend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.model;
import com.fasterxml.jackson.annotation.JsonView;
import java.util.Date;
import java.util.Map;
import java.util.Objects;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import org.springframework.core.style.ToStringCreator;
import de.thm.arsnova.model.serialization.View;
public class Comment extends Entity {
@NotEmpty
private String roomId;
@NotEmpty
private String creatorId;
@NotBlank
private String subject;
@NotBlank
private String body;
@NotNull
private Date timestamp;
private boolean read;
private Map<String, Map<String, Object>> extensions;
@JsonView({View.Persistence.class, View.Public.class})
public String getRoomId() {
return roomId;
}
@JsonView(View.Persistence.class)
public void setRoomId(final String roomId) {
this.roomId = roomId;
}
@JsonView(View.Persistence.class)
public String getCreatorId() {
return creatorId;
}
@JsonView(View.Persistence.class)
public void setCreatorId(final String creatorId) {
this.creatorId = creatorId;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getSubject() {
return subject;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setSubject(final String subject) {
this.subject = subject;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getBody() {
return body;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setBody(final String body) {
this.body = body;
}
@JsonView({View.Persistence.class, View.Public.class})
public Date getTimestamp() {
return timestamp;
}
@JsonView(View.Persistence.class)
public void setTimestamp(final Date timestamp) {
this.timestamp = timestamp;
}
@JsonView({View.Persistence.class, View.Public.class})
public boolean isRead() {
return read;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setRead(final boolean read) {
this.read = read;
}
@JsonView({View.Persistence.class, View.Public.class})
public Map<String, Map<String, Object>> getExtensions() {
return extensions;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setExtensions(final Map<String, Map<String, Object>> extensions) {
this.extensions = extensions;
}
/**
* {@inheritDoc}
*
* <p>
* The following fields of <tt>LogEntry</tt> are excluded from equality checks:
* {@link #extensions}.
* </p>
*/
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!super.equals(o)) {
return false;
}
final Comment comment = (Comment) o;
return read == comment.read
&& Objects.equals(roomId, comment.roomId)
&& Objects.equals(creatorId, comment.creatorId)
&& Objects.equals(subject, comment.subject)
&& Objects.equals(body, comment.body)
&& Objects.equals(timestamp, comment.timestamp)
&& Objects.equals(extensions, comment.extensions);
}
@Override
protected ToStringCreator buildToString() {
return super.buildToString()
.append("roomId", roomId)
.append("creatorId", creatorId)
.append("subject", subject)
.append("body", body)
.append("timestamp", timestamp)
.append("read", read);
}
}
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2019 The ARSnova Team and Contributors
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ARSnova Backend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.model;
import com.fasterxml.jackson.annotation.JsonView;
import java.util.List;
import java.util.Map;
import de.thm.arsnova.model.serialization.View;
public class Configuration {
private List<AuthenticationProvider> authenticationProviders;
private Map<String, Object> features;
private Map<String, Object> ui;
@JsonView(View.Public.class)
public List<AuthenticationProvider> getAuthenticationProviders() {
return authenticationProviders;
}
public void setAuthenticationProviders(final List<AuthenticationProvider> authenticationProviders) {
this.authenticationProviders = authenticationProviders;
}
@JsonView(View.Public.class)
public Map<String, Object> getFeatures() {
return features;
}
public void setFeatures(final Map<String, Object> features) {
this.features = features;
}
@JsonView(View.Public.class)
public Map<String, Object> getUi() {
return ui;
}
public void setUi(final Map<String, Object> ui) {
this.ui = ui;
}
}
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2019 The ARSnova Team and Contributors
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ARSnova Backend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.model;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonView;
import com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver;
import java.util.Date;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
import org.springframework.core.style.ToStringCreator;
import de.thm.arsnova.model.serialization.FormatContentTypeIdResolver;
import de.thm.arsnova.model.serialization.View;
@JsonTypeInfo(
use = JsonTypeInfo.Id.CUSTOM,
property = "format",
visible = true,
defaultImpl = Content.class
)
@JsonTypeIdResolver(FormatContentTypeIdResolver.class)
public class Content extends Entity {
public enum Format {
CHOICE,
BINARY,
SCALE,
NUMBER,
TEXT,
GRID
}
public static class State {
@Positive
private int round = 1;
private Date roundEndTimestamp;
private boolean visible = true;
private boolean additionalTextVisible = true;
private boolean responsesEnabled = true;
private boolean responsesVisible = false;
@JsonView({View.Persistence.class, View.Public.class})
public int getRound() {
return round;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setRound(final int round) {
this.round = round;
}
@JsonView({View.Persistence.class, View.Public.class})
public Date getRoundEndTimestamp() {
return roundEndTimestamp;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setRoundEndTimestamp(final Date roundEndTimestamp) {
this.roundEndTimestamp = roundEndTimestamp;
}
@JsonView({View.Persistence.class, View.Public.class})
public boolean isVisible() {
return visible;
}
@JsonView({View.Persistence.class, View.Public.class})
public boolean isAdditionalTextVisible() {
return additionalTextVisible;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setAdditionalTextVisible(final boolean additionalTextVisible) {
this.additionalTextVisible = additionalTextVisible;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setVisible(final boolean visible) {
this.visible = visible;
}
@JsonView({View.Persistence.class, View.Public.class})
public boolean isResponsesEnabled() {
return responsesEnabled;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setResponsesEnabled(final boolean responsesEnabled) {
this.responsesEnabled = responsesEnabled;
}
@JsonView({View.Persistence.class, View.Public.class})
public boolean isResponsesVisible() {
return responsesVisible;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setResponsesVisible(final boolean responsesVisible) {
this.responsesVisible = responsesVisible;
}
@Override
public int hashCode() {
return Objects.hash(round, roundEndTimestamp, visible, additionalTextVisible, responsesEnabled, responsesVisible);
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!super.equals(o)) {
return false;
}
final State state = (State) o;
return round == state.round
&& visible == state.visible
&& additionalTextVisible == state.additionalTextVisible
&& responsesEnabled == state.responsesEnabled
&& responsesVisible == state.responsesVisible
&& Objects.equals(roundEndTimestamp, state.roundEndTimestamp);
}
@Override
public String toString() {
return new ToStringCreator(this)
.append("round", round)
.append("roundEndTimestamp", roundEndTimestamp)
.append("visible", visible)
.append("solutionVisible", additionalTextVisible)
.append("responsesEnabled", responsesEnabled)
.append("responsesVisible", responsesVisible)
.toString();
}
}
@NotEmpty
private String roomId;
@NotBlank
private String subject;
@NotBlank
private String body;
@NotNull
private Format format;
private Set<String> groups;
private boolean abstentionsAllowed;
private State state;
private Date timestamp;
private String additionalText;
private String additionalTextTitle;
private Map<String, Map<String, Object>> extensions;
private Map<String, String> attachments;
@JsonView({View.Persistence.class, View.Public.class})
public String getRoomId() {
return roomId;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setRoomId(final String roomId) {
this.roomId = roomId;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getSubject() {
return subject;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setSubject(final String subject) {
this.subject = subject;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getBody() {
return body;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setBody(final String body) {
this.body = body;
}
@JsonView({View.Persistence.class, View.Public.class})
public Format getFormat() {
return format;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setFormat(final Format format) {
this.format = format;
}
@JsonView(View.Public.class)
public Set<String> getGroups() {
if (groups == null) {
groups = new HashSet<>();
}
return groups;
}
/* Content groups are persisted in the Room */
@JsonView(View.Public.class)
public void setGroups(final Set<String> groups) {
this.groups = groups;
}
@JsonView({View.Persistence.class, View.Public.class})
public State getState() {
return state != null ? state : (state = new State());
}
public void resetState() {
this.state = new State();
}
@JsonView({View.Persistence.class, View.Public.class})
public void setState(final State state) {
this.state = state;
}
@JsonView({View.Persistence.class, View.Public.class})
public Date getTimestamp() {
return timestamp;
}
@JsonView(View.Persistence.class)
public void setTimestamp(final Date timestamp) {
this.timestamp = timestamp;
}
@JsonView({View.Persistence.class, View.Owner.class})
public String getAdditionalText() {
return additionalText;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setAdditionalText(final String additionalText) {
this.additionalText = additionalText;
}
@JsonView({View.Persistence.class, View.Owner.class})
public String getAdditionalTextTitle() {
return additionalTextTitle;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setAdditionalTextTitle(final String additionalTextTitle) {
this.additionalTextTitle = additionalTextTitle;
}
@JsonView({View.Persistence.class, View.Public.class})
public Map<String, Map<String, Object>> getExtensions() {
return extensions;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setExtensions(final Map<String, Map<String, Object>> extensions) {
this.extensions = extensions;
}
@JsonView({View.Persistence.class, View.Public.class})
public Map<String, String> getAttachments() {
return attachments;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setAttachments(final Map<String, String> attachments) {
this.attachments = attachments;
}
@JsonView({View.Persistence.class, View.Public.class})
public boolean isAbstentionsAllowed() {
return abstentionsAllowed;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setAbstentionsAllowed(final boolean abstentionsAllowed) {
this.abstentionsAllowed = abstentionsAllowed;
}
@JsonView(View.Persistence.class)
@Override
public Class<? extends Entity> getType() {
return Content.class;
}
/**
* {@inheritDoc}
*
* <p>
* The following fields of <tt>LogEntry</tt> are excluded from equality checks:
* {@link #state}, {@link #extensions}, {@link #attachments}.
* </p>
*/
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!super.equals(o)) {
return false;
}
final Content content = (Content) o;
return Objects.equals(roomId, content.roomId)
&& Objects.equals(subject, content.subject)
&& Objects.equals(body, content.body)
&& format == content.format
&& Objects.equals(groups, content.groups)
&& Objects.equals(timestamp, content.timestamp);
}
@Override
protected ToStringCreator buildToString() {
return super.buildToString()
.append("roomId", roomId)
.append("subject", subject)
.append("body", body)
.append("format", format)
.append("groups", groups)
.append("abstentionsAllowed", abstentionsAllowed)
.append("state", state)
.append("additionalText", additionalText)
.append("additionalTextTitle", additionalTextTitle)
.append("timestamp", timestamp)
.append("attachments", attachments);
}
}
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2019 The ARSnova Team and Contributors
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ARSnova Backend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.model;
import com.fasterxml.jackson.annotation.JsonView;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import org.springframework.core.style.ToStringCreator;
import de.thm.arsnova.model.serialization.View;
public class ContentGroup extends Entity {
@NotEmpty
private String roomId;
@NotBlank
private String name;
private Set<String> contentIds;
private boolean autoSort;
public ContentGroup() {
}
public ContentGroup(final String roomId, final String name) {
this.roomId = roomId;
this.name = name;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getRoomId() {
return roomId;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setRoomId(final String roomId) {
this.roomId = roomId;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getName() {
return this.name;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setName(final String name) {
this.name = name;
}
@JsonView({View.Persistence.class, View.Public.class})
public Set<String> getContentIds() {
if (contentIds == null) {
contentIds = new HashSet<>();
}
return contentIds;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setContentIds(final Set<String> contentIds) {
this.contentIds = contentIds;
}
@JsonView({View.Persistence.class, View.Public.class})
public boolean isAutoSort() {
return autoSort;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setAutoSort(final boolean autoSort) {
this.autoSort = autoSort;
}
@Override
public int hashCode() {
return Objects.hash(name, contentIds, autoSort);
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final ContentGroup that = (ContentGroup) o;
return autoSort == that.autoSort
&& Objects.equals(name, that.name)
&& Objects.equals(contentIds, that.contentIds);
}
@Override
public String toString() {
return new ToStringCreator(this)
.append("name", name)
.append("contentIds", contentIds)
.append("autoSort", autoSort)
.toString();
}
}
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2019 The ARSnova Team and Contributors
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ARSnova Backend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.model;
import com.fasterxml.jackson.annotation.JsonView;
import java.util.Date;
import java.util.Objects;
import org.springframework.core.style.ToStringCreator;
import de.thm.arsnova.model.serialization.View;
/**
* Used as base for classes that represent persistent data with an unique ID.
*
* @author Daniel Gerhardt
*/
public abstract class Entity {
protected String id;
protected String rev;
protected Date creationTimestamp;
protected Date updateTimestamp;
private boolean internal;
@JsonView({View.Persistence.class, View.Public.class})
public String getId() {
return id;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setId(final String id) {
this.id = id;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getRevision() {
return rev;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setRevision(final String rev) {
this.rev = rev;
}
@JsonView(View.Persistence.class)
public Date getCreationTimestamp() {
return creationTimestamp;
}
@JsonView(View.Persistence.class)
public void setCreationTimestamp(final Date creationTimestamp) {
this.creationTimestamp = creationTimestamp;
}
@JsonView(View.Persistence.class)
public Date getUpdateTimestamp() {
return updateTimestamp;
}
@JsonView(View.Persistence.class)
public void setUpdateTimestamp(final Date updateTimestamp) {
this.updateTimestamp = updateTimestamp;
}
@JsonView(View.Persistence.class)
public Class<? extends Entity> getType() {
return getClass();
}
public boolean isInternal() {
return internal;
}
public void setInternal(final boolean internal) {
this.internal = internal;
}
@Override
public int hashCode() {
return Objects.hash(id, rev, creationTimestamp, updateTimestamp);
}
/**
* Use this helper method when overriding {@link #hashCode()}.
*
* @param init The result of <tt>super.hashCode()</tt>
* @param additionalFields Fields introduced by the subclass which should be included in the hash code generation
*
* @see java.util.Arrays#hashCode(Object[])
*/
protected int hashCode(final int init, final Object... additionalFields) {
int result = init;
if (additionalFields == null) {
return result;
}
for (final Object element : additionalFields) {
result = 31 * result + (element == null ? 0 : element.hashCode());
}
return result;
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final Entity entity = (Entity) o;
return Objects.equals(id, entity.id)
&& Objects.equals(rev, entity.rev)
&& Objects.equals(creationTimestamp, entity.creationTimestamp)
&& Objects.equals(updateTimestamp, entity.updateTimestamp);
}
@Override
public String toString() {
return buildToString().toString();
}
/**
* Use this helper method to adjust the output of {@link #toString()}.
* Override this method instead of <tt>toString()</tt> and call <tt>super.buildToString()</tt>.
* Additional fields can be added to the String by calling
* {@link org.springframework.core.style.ToStringCreator#append} on the <tt>ToStringCreator</tt>.
*/
protected ToStringCreator buildToString() {
final ToStringCreator toStringCreator = new ToStringCreator(this);
toStringCreator
.append("id", id)
.append("revision", rev)
.append("creationTimestamp", creationTimestamp)
.append("updateTimestamp", updateTimestamp);
return toStringCreator;
}
}
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2015 The ARSnova Team
* Copyright (C) 2012-2019 The ARSnova Team and Contributors
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -15,28 +15,27 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.events;
import de.thm.arsnova.entities.Question;
import de.thm.arsnova.entities.Session;
package de.thm.arsnova.model;
public class NewQuestionEvent extends SessionEvent {
import javax.validation.ValidationException;
import org.springframework.validation.Errors;
private static final long serialVersionUID = 1L;
public class EntityValidationException extends ValidationException {
private Errors errors;
private Entity entity;
private final Question question;
public NewQuestionEvent(Object source, Session session, Question question) {
super(source, session);
this.question = question;
public EntityValidationException(final Errors errors, final Entity entity) {
super(errors.getAllErrors().toString());
this.errors = errors;
this.entity = entity;
}
public Question getQuestion() {
return question;
public Errors getErrors() {
return errors;
}
@Override
public void accept(NovaEventVisitor visitor) {
visitor.visit(this);
public Entity getEntity() {
return entity;
}
}
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2015 The ARSnova Team
* Copyright (C) 2012-2019 The ARSnova Team and Contributors
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -15,12 +15,21 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.entities;
package de.thm.arsnova.model;
import com.fasterxml.jackson.annotation.JsonView;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import de.thm.arsnova.model.serialization.View;
/**
* The feedback values of a single session.
*/
public class Feedback {
public static final int MIN_FEEDBACK_TYPE = 0;
public static final int MAX_FEEDBACK_TYPE = 3;
......@@ -32,26 +41,44 @@ public class Feedback {
private final List<Integer> values;
public Feedback(final int a, final int b, final int c, final int d) {
values = new ArrayList<Integer>();
values = new ArrayList<>();
values.add(a);
values.add(b);
values.add(c);
values.add(d);
}
@JsonView(View.Public.class)
public final List<Integer> getValues() {
return values;
}
public Optional<Double> getAverage() {
final int count = this.getCount();
if (count == 0) {
return Optional.empty();
}
final double sum = values.get(FEEDBACK_OK) + values.get(FEEDBACK_SLOWER) * 2
+ values.get(FEEDBACK_AWAY) * 3;
return Optional.of(sum / count);
}
public int getCount() {
return values.get(FEEDBACK_FASTER) + values.get(FEEDBACK_OK)
+ values.get(FEEDBACK_SLOWER) + values.get(FEEDBACK_AWAY);
}
@Override
public boolean equals(Object obj) {
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (!(obj instanceof Feedback)) {
return false;
}
Feedback other = (Feedback) obj;
final Feedback other = (Feedback) obj;
if (this.values.size() != other.values.size()) {
return false;
......@@ -68,7 +95,7 @@ public class Feedback {
public int hashCode() {
// See http://stackoverflow.com/a/113600
int result = 42;
for (Integer v : values) {
for (final Integer v : values) {
result = 37 * result + v;
}
return result;
......
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2019 The ARSnova Team and Contributors
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ARSnova Backend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.model;
import com.fasterxml.jackson.annotation.JsonView;
import java.util.Map;
import org.springframework.core.style.ToStringCreator;
import de.thm.arsnova.model.serialization.View;
public class FindQuery<E extends Entity> {
enum LogicalOperator {
AND,
OR
}
private LogicalOperator operator = LogicalOperator.AND;
private E properties;
private Map<String, Object> externalFilters;
public LogicalOperator getOperator() {
return operator;
}
@JsonView(View.Public.class)
public void setOperator(final LogicalOperator operator) {
this.operator = operator;
}
public E getProperties() {
return properties;
}
@JsonView(View.Public.class)
public void setProperties(final E properties) {
this.properties = properties;
}
public Map<String, Object> getExternalFilters() {
return externalFilters;
}
@JsonView(View.Public.class)
public void setExternalFilters(final Map<String, Object> externalFilters) {
this.externalFilters = externalFilters;
}
@Override
public String toString() {
return new ToStringCreator(getClass())
.append("operator", operator)
.append("properties", properties)
.append("externalFilters", externalFilters)
.toString();
}
}
package de.thm.arsnova.model;
import com.fasterxml.jackson.annotation.JsonView;
import java.util.ArrayList;
import java.util.List;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Positive;
import de.thm.arsnova.model.serialization.View;
public class GridImageContent extends Content {
public static class Grid {
@Positive
private int columns;
@Positive
private int rows;
@Min(-1)
@Max(1)
private double normalizedX;
@Min(-1)
@Max(1)
private double normalizedY;
@Positive
@Max(1)
private double normalizedFieldSize;
private boolean visible;
@JsonView({View.Persistence.class, View.Public.class})
public int getColumns() {
return columns;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setColumns(final int columns) {
this.columns = columns;
}
@JsonView({View.Persistence.class, View.Public.class})
public int getRows() {
return rows;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setRows(final int rows) {
this.rows = rows;
}
@JsonView({View.Persistence.class, View.Public.class})
public double getNormalizedX() {
return normalizedX;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setNormalizedX(final double normalizedX) {
this.normalizedX = normalizedX;
}
@JsonView({View.Persistence.class, View.Public.class})
public double getNormalizedY() {
return normalizedY;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setNormalizedY(final double normalizedY) {
this.normalizedY = normalizedY;
}
@JsonView({View.Persistence.class, View.Public.class})
public double getNormalizedFieldSize() {
return normalizedFieldSize;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setNormalizedFieldSize(final double normalizedFieldSize) {
this.normalizedFieldSize = normalizedFieldSize;
}
@JsonView({View.Persistence.class, View.Public.class})
public boolean isVisible() {
return visible;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setVisible(final boolean visible) {
this.visible = visible;
}
}
public static class Image {
private String url;
@Min(-1)
@Max(1)
private double normalizedX;
@Min(-1)
@Max(1)
private double normalizedY;
@Positive
private double scaleFactor;
@Min(0)
@Max(360)
private int rotation;
@JsonView({View.Persistence.class, View.Public.class})
public String getUrl() {
return url;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setUrl(final String url) {
this.url = url;
}
@JsonView({View.Persistence.class, View.Public.class})
public double getNormalizedX() {
return normalizedX;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setNormalizedX(final double normalizedX) {
this.normalizedX = normalizedX;
}
@JsonView({View.Persistence.class, View.Public.class})
public double getNormalizedY() {
return normalizedY;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setNormalizedY(final double normalizedY) {
this.normalizedY = normalizedY;
}
@JsonView({View.Persistence.class, View.Public.class})
public double getScaleFactor() {
return scaleFactor;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setScaleFactor(final double scaleFactor) {
this.scaleFactor = scaleFactor;
}
@JsonView({View.Persistence.class, View.Public.class})
public int getRotation() {
return rotation;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setRotation(final int rotation) {
this.rotation = rotation;
}
}
private Grid grid;
private Image image;
private List<Integer> correctOptionIndexes = new ArrayList<>();
@JsonView({View.Persistence.class, View.Public.class})
public Grid getGrid() {
if (grid == null) {
grid = new Grid();
}
return grid;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setGrid(final Grid grid) {
this.grid = grid;
}
@JsonView({View.Persistence.class, View.Public.class})
public Image getImage() {
if (image == null) {
image = new Image();
}
return image;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setImage(final Image image) {
this.image = image;
}
/* TODO: A new JsonView is needed here. */
@JsonView(View.Persistence.class)
public List<Integer> getCorrectOptionIndexes() {
return correctOptionIndexes;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setCorrectOptionIndexes(final List<Integer> correctOptionIndexes) {
this.correctOptionIndexes = correctOptionIndexes;
}
}
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2019 The ARSnova Team and Contributors
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ARSnova Backend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonView;
import java.util.Map;
import java.util.Objects;
import de.thm.arsnova.model.serialization.View;
public class LogEntry extends Entity {
public enum LogLevel {
TRACE,
DEBUG,
INFO,
WARN,
ERROR,
FATAL
}
private String event;
private int level;
private Map<String, Object> payload;
public LogEntry(@JsonProperty final String event, @JsonProperty final int level,
@JsonProperty final Map<String, Object> payload) {
this.event = event;
this.level = level;
this.payload = payload;
}
@JsonView(View.Persistence.class)
public String getEvent() {
return event;
}
@JsonView(View.Persistence.class)
public void setEvent(final String event) {
this.event = event;
}
@JsonView(View.Persistence.class)
public int getLevel() {
return level;
}
@JsonView(View.Persistence.class)
public void setLevel(final int level) {
this.level = level;
}
@JsonView(View.Persistence.class)
public void setLevel(final de.thm.arsnova.model.migration.v2.LogEntry.LogLevel level) {
this.level = level.ordinal();
}
@JsonView(View.Persistence.class)
public Map<String, Object> getPayload() {
return payload;
}
@JsonView(View.Persistence.class)
public void setPayload(final Map<String, Object> payload) {
this.payload = payload;
}
/**
* {@inheritDoc}
*
* <p>
* The following fields of <tt>LogEntry</tt> are excluded from equality checks:
* {@link #payload}.
* </p>
*/
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!super.equals(o)) {
return false;
}
final LogEntry logEntry = (LogEntry) o;
return level == logEntry.level
&& Objects.equals(id, logEntry.id)
&& Objects.equals(rev, logEntry.rev)
&& Objects.equals(creationTimestamp, logEntry.creationTimestamp)
&& Objects.equals(updateTimestamp, logEntry.updateTimestamp)
&& Objects.equals(event, logEntry.event);
}
}
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2015 The ARSnova Team
* Copyright (C) 2012-2019 The ARSnova Team and Contributors
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -15,49 +15,41 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.entities;
public class PossibleAnswer {
package de.thm.arsnova.model;
private String id;
private String text;
private boolean correct;
private int value;
import com.fasterxml.jackson.annotation.JsonView;
import org.springframework.core.style.ToStringCreator;
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
import de.thm.arsnova.model.serialization.View;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public class LoginCredentials {
private String loginId;
private String password;
public boolean isCorrect() {
return correct;
public String getLoginId() {
return loginId;
}
public void setCorrect(boolean correct) {
this.correct = correct;
@JsonView(View.Public.class)
public void setLoginId(final String loginId) {
this.loginId = loginId;
}
public int getValue() {
return value;
public String getPassword() {
return password;
}
public void setValue(int value) {
this.value = value;
@JsonView(View.Public.class)
public void setPassword(final String password) {
this.password = password;
}
@Override
public String toString() {
return "PossibleAnswer [id=" + id + ", text=" + text + ", correct=" + correct + "]";
return new ToStringCreator(this)
.append("loginId", loginId)
.append("password", password)
.toString();
}
}
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2019 The ARSnova Team and Contributors
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ARSnova Backend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.model;
import com.fasterxml.jackson.annotation.JsonView;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import org.springframework.core.style.ToStringCreator;
import de.thm.arsnova.model.serialization.View;
public class MigrationState extends Entity {
public static class Migration {
private String id;
private Date start;
private int step;
private Object state;
public Migration() {
}
public Migration(final String id, final Date start) {
this.id = id;
this.start = start;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getId() {
return id;
}
@JsonView({View.Persistence.class, View.Public.class})
public Date getStart() {
return start;
}
@JsonView({View.Persistence.class, View.Public.class})
public int getStep() {
return step;
}
@JsonView(View.Persistence.class)
public void setStep(final int step) {
this.step = step;
}
@JsonView({View.Persistence.class, View.Public.class})
public Object getState() {
return state;
}
@JsonView(View.Persistence.class)
public void setState(final Object state) {
this.state = state;
}
@Override
public String toString() {
return new ToStringCreator(this)
.append("id", id)
.append("start", start)
.append("step", step)
.append("state", state)
.toString();
}
}
public static final String ID = "MigrationState";
private Migration active;
private List<String> completed = new ArrayList<>();
{
id = ID;
}
@Override
@JsonView(View.Persistence.class)
public String getId() {
return ID;
}
@Override
@JsonView(View.Persistence.class)
public void setId(final String id) {
if (!id.equals(this.ID)) {
throw new IllegalArgumentException("ID of this entity must not be changed.");
}
}
@Override
@JsonView({View.Persistence.class, View.Public.class})
public String getRevision() {
return rev;
}
@Override
@JsonView(View.Persistence.class)
public void setRevision(final String rev) {
this.rev = rev;
}
@JsonView({View.Persistence.class, View.Public.class})
public Migration getActive() {
return active;
}
@JsonView(View.Persistence.class)
public void setActive(final Migration active) {
this.active = active;
}
public void setActive(final String id, final Date start) {
this.setActive(new Migration(id, start));
}
@JsonView({View.Persistence.class, View.Public.class})
public List<String> getCompleted() {
return completed;
}
@JsonView(View.Persistence.class)
public void setCompleted(final List<String> completed) {
this.completed = completed;
}
/**
* {@inheritDoc}
*
* <p>
* All fields of <tt>MigrationState</tt> are included in equality checks.
* </p>
*/
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!super.equals(o)) {
return false;
}
final MigrationState that = (MigrationState) o;
return Objects.equals(active, that.active)
&& Objects.equals(completed, that.completed);
}
@Override
protected ToStringCreator buildToString() {
return super.buildToString()
.append("active", active)
.append("completed", completed);
}
}
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2019 The ARSnova Team and Contributors
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ARSnova Backend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.model;
import com.fasterxml.jackson.annotation.JsonView;
import java.util.Date;
import java.util.Objects;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import org.springframework.core.style.ToStringCreator;
import de.thm.arsnova.model.serialization.View;
public class Motd extends Entity {
public enum Audience {
ALL,
AUTHENTICATED,
AUTHORS,
PARTICIPANTS,
ROOM
}
@NotEmpty
private String roomId;
private Date startDate;
private Date endDate;
@NotBlank
private String title;
@NotBlank
private String body;
@NotNull
private Audience audience;
@Override
@JsonView(View.Persistence.class)
public Date getUpdateTimestamp() {
return updateTimestamp;
}
@Override
@JsonView(View.Persistence.class)
public void setUpdateTimestamp(final Date updateTimestamp) {
this.updateTimestamp = updateTimestamp;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getRoomId() {
return roomId;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setRoomId(final String roomId) {
this.roomId = roomId;
}
@JsonView({View.Persistence.class, View.Public.class})
public Date getStartDate() {
return startDate;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setStartDate(final Date startDate) {
this.startDate = startDate;
}
@JsonView({View.Persistence.class, View.Public.class})
public Date getEndDate() {
return endDate;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setEndDate(final Date endDate) {
this.endDate = endDate;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getTitle() {
return title;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setTitle(final String title) {
this.title = title;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getBody() {
return body;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setBody(final String body) {
this.body = body;
}
@JsonView({View.Persistence.class, View.Public.class})
public Audience getAudience() {
return audience;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setAudience(final Audience audience) {
this.audience = audience;
}
/**
* {@inheritDoc}
*
* <p>
* All fields of <tt>Motd</tt> are included in equality checks.
* </p>
*/
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!super.equals(o)) {
return false;
}
final Motd motd = (Motd) o;
return Objects.equals(roomId, motd.roomId)
&& Objects.equals(startDate, motd.startDate)
&& Objects.equals(endDate, motd.endDate)
&& Objects.equals(title, motd.title)
&& Objects.equals(body, motd.body)
&& audience == motd.audience;
}
@Override
protected ToStringCreator buildToString() {
return super.buildToString()
.append("roomId", roomId)
.append("startDate", startDate)
.append("endDate", endDate)
.append("title", title)
.append("body", body)
.append("audience", audience);
}
}
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2019 The ARSnova Team and Contributors
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ARSnova Backend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.model;
import com.fasterxml.jackson.annotation.JsonView;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import org.springframework.core.style.ToStringCreator;
import de.thm.arsnova.model.serialization.View;
public class Room extends Entity {
public static class Moderator {
public enum Role {
EDITING_MODERATOR,
EXECUTIVE_MODERATOR
}
@NotEmpty
private String userId;
private Set<Role> roles;
@JsonView({View.Persistence.class, View.Public.class})
public String getUserId() {
return userId;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setUserId(final String userId) {
this.userId = userId;
}
@JsonView({View.Persistence.class, View.Public.class})
public Set<Role> getRoles() {
if (roles == null) {
roles = new HashSet<>();
}
return roles;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setRoles(final Set<Role> roles) {
this.roles = roles;
}
}
public static class Settings {
private boolean questionsEnabled = true;
private boolean slidesEnabled = true;
private boolean commentsEnabled = true;
private boolean flashcardsEnabled = true;
private boolean quickSurveyEnabled = true;
private boolean quickFeedbackEnabled = true;
private boolean scoreEnabled = true;
private boolean multipleRoundsEnabled = true;
private boolean timerEnabled = true;
private boolean feedbackLocked = false;
@JsonView({View.Persistence.class, View.Public.class})
public boolean isQuestionsEnabled() {
return questionsEnabled;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setQuestionsEnabled(final boolean questionsEnabled) {
this.questionsEnabled = questionsEnabled;
}
@JsonView({View.Persistence.class, View.Public.class})
public boolean isSlidesEnabled() {
return slidesEnabled;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setSlidesEnabled(final boolean slidesEnabled) {
this.slidesEnabled = slidesEnabled;
}
@JsonView({View.Persistence.class, View.Public.class})
public boolean isCommentsEnabled() {
return commentsEnabled;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setCommentsEnabled(final boolean commentsEnabled) {
this.commentsEnabled = commentsEnabled;
}
@JsonView({View.Persistence.class, View.Public.class})
public boolean isFlashcardsEnabled() {
return flashcardsEnabled;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setFlashcardsEnabled(final boolean flashcardsEnabled) {
this.flashcardsEnabled = flashcardsEnabled;
}
@JsonView({View.Persistence.class, View.Public.class})
public boolean isQuickSurveyEnabled() {
return quickSurveyEnabled;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setQuickSurveyEnabled(final boolean quickSurveyEnabled) {
this.quickSurveyEnabled = quickSurveyEnabled;
}
@JsonView({View.Persistence.class, View.Public.class})
public boolean isQuickFeedbackEnabled() {
return quickFeedbackEnabled;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setQuickFeedbackEnabled(final boolean quickFeedbackEnabled) {
this.quickFeedbackEnabled = quickFeedbackEnabled;
}
@JsonView({View.Persistence.class, View.Public.class})
public boolean isScoreEnabled() {
return scoreEnabled;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setScoreEnabled(final boolean scoreEnabled) {
this.scoreEnabled = scoreEnabled;
}
@JsonView({View.Persistence.class, View.Public.class})
public boolean isMultipleRoundsEnabled() {
return multipleRoundsEnabled;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setMultipleRoundsEnabled(final boolean multipleRoundsEnabled) {
this.multipleRoundsEnabled = multipleRoundsEnabled;
}
@JsonView({View.Persistence.class, View.Public.class})
public boolean isTimerEnabled() {
return timerEnabled;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setTimerEnabled(final boolean timerEnabled) {
this.timerEnabled = timerEnabled;
}
@JsonView({View.Persistence.class, View.Public.class})
public boolean isFeedbackLocked() {
return feedbackLocked;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setFeedbackLocked(final boolean feedbackLocked) {
this.feedbackLocked = feedbackLocked;
}
@Override
public int hashCode() {
return Objects.hash(
questionsEnabled, slidesEnabled, commentsEnabled, flashcardsEnabled,
quickSurveyEnabled, quickFeedbackEnabled, scoreEnabled, multipleRoundsEnabled,
timerEnabled, feedbackLocked);
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final Settings settings = (Settings) o;
return questionsEnabled == settings.questionsEnabled
&& slidesEnabled == settings.slidesEnabled
&& commentsEnabled == settings.commentsEnabled
&& flashcardsEnabled == settings.flashcardsEnabled
&& quickSurveyEnabled == settings.quickSurveyEnabled
&& quickFeedbackEnabled == settings.quickFeedbackEnabled
&& scoreEnabled == settings.scoreEnabled
&& multipleRoundsEnabled == settings.multipleRoundsEnabled
&& timerEnabled == settings.timerEnabled
&& feedbackLocked == settings.feedbackLocked;
}
@Override
public String toString() {
return new ToStringCreator(this)
.append("questionsEnabled", questionsEnabled)
.append("slidesEnabled", slidesEnabled)
.append("commentsEnabled", commentsEnabled)
.append("flashcardsEnabled", flashcardsEnabled)
.append("quickSurveyEnabled", quickSurveyEnabled)
.append("quickFeedbackEnabled", quickFeedbackEnabled)
.append("scoreEnabled", scoreEnabled)
.append("multipleRoundsEnabled", multipleRoundsEnabled)
.append("timerEnabled", timerEnabled)
.append("feedbackLocked", feedbackLocked)
.toString();
}
}
public static class Author {
private String name;
private String mail;
private String organizationName;
private String organizationLogo;
private String organizationUnit;
@JsonView({View.Persistence.class, View.Public.class})
public String getName() {
return name;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setName(final String name) {
this.name = name;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getMail() {
return mail;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setMail(final String mail) {
this.mail = mail;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getOrganizationName() {
return organizationName;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setOrganizationName(final String organizationName) {
this.organizationName = organizationName;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getOrganizationLogo() {
return organizationLogo;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setOrganizationLogo(final String organizationLogo) {
this.organizationLogo = organizationLogo;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getOrganizationUnit() {
return organizationUnit;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setOrganizationUnit(final String organizationUnit) {
this.organizationUnit = organizationUnit;
}
@Override
public int hashCode() {
return Objects.hash(name, mail, organizationName, organizationLogo, organizationUnit);
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final Author author = (Author) o;
return Objects.equals(name, author.name)
&& Objects.equals(mail, author.mail)
&& Objects.equals(organizationName, author.organizationName)
&& Objects.equals(organizationLogo, author.organizationLogo)
&& Objects.equals(organizationUnit, author.organizationUnit);
}
@Override
public String toString() {
return new ToStringCreator(this)
.append("name", name)
.append("mail", mail)
.append("organizationName", organizationName)
.append("organizationLogo", organizationLogo)
.append("organizationUnit", organizationUnit)
.toString();
}
}
public static class PoolProperties {
private String category;
private String level;
private String license;
@JsonView({View.Persistence.class, View.Public.class})
public String getCategory() {
return category;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setCategory(final String category) {
this.category = category;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getLevel() {
return level;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setLevel(final String level) {
this.level = level;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getLicense() {
return license;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setLicense(final String license) {
this.license = license;
}
@Override
public int hashCode() {
return Objects.hash(category, level, license);
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final PoolProperties that = (PoolProperties) o;
return Objects.equals(category, that.category)
&& Objects.equals(level, that.level)
&& Objects.equals(license, that.license);
}
@Override
public String toString() {
return new ToStringCreator(this)
.append("category", category)
.append("level", level)
.append("license", license)
.toString();
}
}
@NotEmpty
private String shortId;
@NotEmpty
private String ownerId;
@NotBlank
private String name;
@NotBlank
private String abbreviation;
private String description;
private boolean closed;
private Set<Moderator> moderators;
private boolean moderatorsInitialized;
private Settings settings;
private Author author;
private PoolProperties poolProperties;
private Map<String, Map<String, Object>> extensions;
private Map<String, String> attachments;
private RoomStatistics statistics;
@JsonView({View.Persistence.class, View.Public.class})
public String getShortId() {
return shortId;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setShortId(final String shortId) {
this.shortId = shortId;
}
@JsonView(View.Persistence.class)
public String getOwnerId() {
return ownerId;
}
@JsonView(View.Persistence.class)
public void setOwnerId(final String ownerId) {
this.ownerId = ownerId;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getName() {
return name;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setName(final String name) {
this.name = name;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getAbbreviation() {
return abbreviation;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setAbbreviation(final String abbreviation) {
this.abbreviation = abbreviation;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getDescription() {
return description;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setDescription(final String description) {
this.description = description;
}
@JsonView({View.Persistence.class, View.Public.class})
public boolean isClosed() {
return closed;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setClosed(final boolean closed) {
this.closed = closed;
}
@JsonView(View.Persistence.class)
public Set<Moderator> getModerators() {
if (moderators == null) {
moderators = new HashSet<>();
}
return moderators;
}
@JsonView(View.Persistence.class)
public void setModerators(final Set<Moderator> moderators) {
this.moderators = moderators;
moderatorsInitialized = true;
}
public boolean isModeratorsInitialized() {
return moderatorsInitialized;
}
@JsonView({View.Persistence.class, View.Public.class})
public Settings getSettings() {
if (settings == null) {
settings = new Settings();
}
return settings;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setSettings(final Settings settings) {
this.settings = settings;
}
@JsonView({View.Persistence.class, View.Public.class})
public Author getAuthor() {
return author;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setAuthor(final Author author) {
this.author = author;
}
@JsonView({View.Persistence.class, View.Public.class})
public PoolProperties getPoolProperties() {
return poolProperties;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setPoolProperties(final PoolProperties poolProperties) {
this.poolProperties = poolProperties;
}
@JsonView({View.Persistence.class, View.Public.class})
public Map<String, Map<String, Object>> getExtensions() {
return extensions;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setExtensions(final Map<String, Map<String, Object>> extensions) {
this.extensions = extensions;
}
@JsonView({View.Persistence.class, View.Public.class})
public Map<String, String> getAttachments() {
return attachments;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setAttachments(final Map<String, String> attachments) {
this.attachments = attachments;
}
@JsonView(View.Public.class)
public RoomStatistics getStatistics() {
return statistics;
}
public void setStatistics(final RoomStatistics statistics) {
this.statistics = statistics;
}
/**
* {@inheritDoc}
*
* <p>
* The following fields of <tt>Room</tt> are excluded from equality checks:
* {@link #settings}, {@link #author}, {@link #poolProperties}, {@link #extensions}, {@link #attachments},
* {@link #statistics}.
* </p>
*/
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!super.equals(o)) {
return false;
}
final Room room = (Room) o;
return closed == room.closed
&& Objects.equals(shortId, room.shortId)
&& Objects.equals(ownerId, room.ownerId)
&& Objects.equals(name, room.name)
&& Objects.equals(abbreviation, room.abbreviation)
&& Objects.equals(description, room.description);
}
@Override
protected ToStringCreator buildToString() {
return super.buildToString()
.append("shortId", shortId)
.append("ownerId", ownerId)
.append("name", name)
.append("abbreviation", abbreviation)
.append("description", description)
.append("closed", closed)
.append("settings", settings)
.append("author", author)
.append("poolProperties", poolProperties)
.append("attachments", attachments)
.append("statistics", statistics);
}
}
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2019 The ARSnova Team and Contributors
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ARSnova Backend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.model;
import com.fasterxml.jackson.annotation.JsonView;
import java.util.ArrayList;
import java.util.List;
import org.springframework.core.style.ToStringCreator;
import de.thm.arsnova.model.serialization.View;
public class RoomStatistics {
private int currentParticipants;
private int contentCount = 0;
private int unansweredContentCount = 0;
private int answerCount = 0;
private int unreadAnswerCount = 0;
private int commentCount = 0;
private int unreadCommentCount = 0;
private List<ContentGroupStatistics> groupStats;
@JsonView(View.Public.class)
public int getCurrentParticipants() {
return currentParticipants;
}
public void setCurrentParticipants(final int currentParticipants) {
this.currentParticipants = currentParticipants;
}
public int getUnansweredContentCount() {
return unansweredContentCount;
}
public void setUnansweredContentCount(final int unansweredContentCount) {
this.unansweredContentCount = unansweredContentCount;
}
@JsonView(View.Public.class)
public int getContentCount() {
return contentCount;
}
public void setContentCount(final int contentCount) {
this.contentCount = contentCount;
}
@JsonView(View.Public.class)
public int getAnswerCount() {
return answerCount;
}
public void setAnswerCount(final int answerCount) {
this.answerCount = answerCount;
}
public int getUnreadAnswerCount() {
return unreadAnswerCount;
}
public void setUnreadAnswerCount(final int unreadAnswerCount) {
this.unreadAnswerCount = unreadAnswerCount;
}
@JsonView(View.Public.class)
public int getCommentCount() {
return commentCount;
}
public void setCommentCount(final int commentCount) {
this.commentCount = commentCount;
}
public int getUnreadCommentCount() {
return unreadCommentCount;
}
public void setUnreadCommentCount(final int unreadCommentCount) {
this.unreadCommentCount = unreadCommentCount;
}
@JsonView(View.Public.class)
public List<ContentGroupStatistics> getGroupStats() {
if (groupStats == null) {
groupStats = new ArrayList<>();
}
return groupStats;
}
public void setGroupStats(final List<ContentGroupStatistics> groupStats) {
this.groupStats = groupStats;
}
@Override
public String toString() {
return new ToStringCreator(this)
.append("currentParticipants", currentParticipants)
.append("contentCount", contentCount)
.append("unansweredContentCount", unansweredContentCount)
.append("answerCount", answerCount)
.append("unreadAnswerCount", unreadAnswerCount)
.append("commentCount", commentCount)
.append("unreadCommentCount", unreadCommentCount)
.append("groupStats", groupStats)
.toString();
}
public static class ContentGroupStatistics {
private String groupName;
private int contentCount = 0;
public ContentGroupStatistics() {
}
public ContentGroupStatistics(final ContentGroup contentGroup) {
this.setGroupName(contentGroup.getName());
this.setContentCount(contentGroup.getContentIds().size());
}
@JsonView(View.Public.class)
public String getGroupName() {
return groupName;
}
public void setGroupName(final String groupName) {
this.groupName = groupName;
}
@JsonView(View.Public.class)
public int getContentCount() {
return contentCount;
}
public void setContentCount(final int contentCount) {
this.contentCount = contentCount;
}
@Override
public String toString() {
return new ToStringCreator(this)
.append("groupName", groupName)
.append("contentCount", contentCount)
.toString();
}
}
}
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2015 The ARSnova Team
* Copyright (C) 2012-2019 The ARSnova Team and Contributors
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -15,81 +15,55 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.services;
import java.io.Serializable;
import java.util.UUID;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;
import de.thm.arsnova.entities.Session;
import de.thm.arsnova.entities.User;
package de.thm.arsnova.model;
@Component
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public class UserSessionServiceImpl implements UserSessionService, Serializable {
private static final long serialVersionUID = 1L;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
private User user;
private Session session;
private UUID socketId;
private Role role;
import de.thm.arsnova.model.serialization.View;
@Override
public void setUser(final User u) {
user = u;
user.setRole(role);
}
/**
* A session's settings regarding the calculation of the score.
*/
@ApiModel(value = "score options", description = "the score entity")
public class ScoreOptions implements Serializable {
@Override
public User getUser() {
return user;
}
private String type = "questions";
@Override
public void setSession(final Session s) {
session = s;
}
private String questionVariant = "";
@Override
public Session getSession() {
return session;
public ScoreOptions(final ScoreOptions scoreOptions) {
this();
this.type = scoreOptions.getType();
this.questionVariant = scoreOptions.getQuestionVariant();
}
@Override
public void setSocketId(final UUID sId) {
socketId = sId;
}
public ScoreOptions() {
@Override
public UUID getSocketId() {
return socketId;
}
@Override
public boolean inSession() {
return isAuthenticated()
&& getSession() != null;
@ApiModelProperty(required = true, value = "the type")
@JsonView({View.Persistence.class, View.Public.class})
public String getType() {
return type;
}
@Override
public boolean isAuthenticated() {
return getUser() != null
&& getRole() != null;
@JsonView({View.Persistence.class, View.Public.class})
public void setType(final String type) {
this.type = type;
}
@Override
public void setRole(final Role r) {
role = r;
if (user != null) {
user.setRole(role);
}
@ApiModelProperty(required = true, value = "either lecture or preparation")
@JsonView({View.Persistence.class, View.Public.class})
public String getQuestionVariant() {
return questionVariant;
}
@Override
public Role getRole() {
return role;
@JsonView({View.Persistence.class, View.Public.class})
public void setQuestionVariant(final String questionVariant) {
this.questionVariant = questionVariant;
}
}
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2015 The ARSnova Team
* Copyright (C) 2012-2019 The ARSnova Team and Contributors
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -15,83 +15,120 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.entities;
package de.thm.arsnova.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonView;
import java.util.Set;
import java.util.stream.Collectors;
import de.thm.arsnova.config.properties.AuthenticationProviderProperties;
import de.thm.arsnova.model.serialization.View;
/**
* A login service description. For example, this class is used to display the login buttons in ARSnova mobile.
*/
public class ServiceDescription {
private String id;
private String name;
private String dialogUrl;
private String image;
private int order = 0;
private boolean allowLecturer = true;
private Set<AuthenticationProviderProperties.Provider.Role> allowedRoles;
private Set<String> allowedRoleStrings;
public ServiceDescription(String id, String name, String dialogUrl) {
public ServiceDescription(final String id, final String name, final String dialogUrl) {
this.id = id;
this.name = name;
this.dialogUrl = dialogUrl;
}
public ServiceDescription(String id, String name, String dialogUrl, String image) {
public ServiceDescription(final String id, final String name, final String dialogUrl,
final Set<AuthenticationProviderProperties.Provider.Role> allowedRoles) {
this.id = id;
this.name = name;
this.dialogUrl = dialogUrl;
if (!"".equals(image)) {
this.image = image;
}
setAllowedRoles(allowedRoles);
}
public ServiceDescription(String id, String name, String dialogUrl, boolean allowLecturer) {
public ServiceDescription(final String id, final String name, final String dialogUrl,
final Set<AuthenticationProviderProperties.Provider.Role> allowedRoles, final String image) {
this.id = id;
this.name = name;
this.dialogUrl = dialogUrl;
this.allowLecturer = allowLecturer;
setAllowedRoles(allowedRoles);
if (!"".equals(image)) {
this.image = image;
}
}
@JsonView(View.Public.class)
public String getId() {
return id;
}
public void setId(String id) {
public void setId(final String id) {
this.id = id;
}
@JsonView(View.Public.class)
public String getName() {
return name;
}
public void setName(String name) {
public void setName(final String name) {
this.name = name;
}
@JsonView(View.Public.class)
public String getDialogUrl() {
return dialogUrl;
}
public void setDialogUrl(String dialogUrl) {
public void setDialogUrl(final String dialogUrl) {
this.dialogUrl = dialogUrl;
}
@JsonView(View.Public.class)
public String getImage() {
return image;
}
public void setImage(String image) {
public void setImage(final String image) {
this.image = image;
}
@JsonView(View.Public.class)
public int getOrder() {
return order;
}
public void setOrder(int order) {
public void setOrder(final int order) {
this.order = order;
}
public boolean isAllowLecturer() {
return allowLecturer;
public Set<AuthenticationProviderProperties.Provider.Role> getAllowedRoles() {
return allowedRoles;
}
public void setAllowedRoles(final Set<AuthenticationProviderProperties.Provider.Role> allowedRoles) {
this.allowedRoles = allowedRoles;
this.allowedRoleStrings = allowedRoles.stream().map(r -> {
switch (r) {
case MODERATOR:
return "speaker";
case PARTICIPANT:
return "student";
default:
throw new IllegalArgumentException();
}
}).collect(Collectors.toSet());
}
public void setAllowLecturer(boolean allowLecturer) {
this.allowLecturer = allowLecturer;
@JsonView(View.Public.class)
@JsonProperty("allowedRoles")
public Set<String> getAllowedRolesAsStrings() {
return allowedRoleStrings;
}
}
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2015 The ARSnova Team
* Copyright (C) 2012-2019 The ARSnova Team and Contributors
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -15,8 +15,19 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.entities;
package de.thm.arsnova.model;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import de.thm.arsnova.model.serialization.View;
/**
* Collection of several statistics about ARSnova.
*/
@ApiModel(value = "statistics", description = "the statistic entity")
public class Statistics {
private int answers;
......@@ -26,10 +37,14 @@ public class Statistics {
private int closedSessions;
private int creators;
private int activeUsers;
private int activeStudents;
private int loggedinUsers;
private int interposedQuestions;
private int conceptQuestions;
private int flashcards;
@ApiModelProperty(required = true, value = "the number of answers")
@JsonView(View.Public.class)
public int getAnswers() {
return answers;
}
......@@ -38,6 +53,8 @@ public class Statistics {
this.answers = answers;
}
@ApiModelProperty(required = true, value = "the number of lecture questions")
@JsonView(View.Public.class)
public int getLectureQuestions() {
return lectureQuestions;
}
......@@ -46,6 +63,8 @@ public class Statistics {
this.lectureQuestions = questions;
}
@ApiModelProperty(required = true, value = "the number of prepartion uestions")
@JsonView(View.Public.class)
public int getPreparationQuestions() {
return preparationQuestions;
}
......@@ -54,10 +73,14 @@ public class Statistics {
this.preparationQuestions = questions;
}
@ApiModelProperty(required = true, value = "the total number of questions")
@JsonView(View.Public.class)
public int getQuestions() {
return getLectureQuestions() + getPreparationQuestions();
}
@ApiModelProperty(required = true, value = "the number of open sessions")
@JsonView(View.Public.class)
public int getOpenSessions() {
return openSessions;
}
......@@ -66,6 +89,8 @@ public class Statistics {
this.openSessions = openSessions;
}
@ApiModelProperty(required = true, value = "the number of closed Sessions")
@JsonView(View.Public.class)
public int getClosedSessions() {
return closedSessions;
}
......@@ -74,10 +99,14 @@ public class Statistics {
this.closedSessions = closedSessions;
}
@ApiModelProperty(required = true, value = "the total number of Sessions")
@JsonView(View.Public.class)
public int getSessions() {
return getOpenSessions() + getClosedSessions();
}
@ApiModelProperty(required = true, value = "used to display Active Users")
@JsonView(View.Public.class)
public int getActiveUsers() {
return activeUsers;
}
......@@ -86,6 +115,8 @@ public class Statistics {
this.activeUsers = activeUsers;
}
@ApiModelProperty(required = true, value = "the number of users that are logged")
@JsonView(View.Public.class)
public int getLoggedinUsers() {
return loggedinUsers;
}
......@@ -94,30 +125,56 @@ public class Statistics {
this.loggedinUsers = loggedinUsers;
}
@ApiModelProperty(required = true, value = "the number of interposed Questions")
@JsonView(View.Public.class)
public int getInterposedQuestions() {
return interposedQuestions;
}
public void setInterposedQuestions(int interposedQuestions) {
public void setInterposedQuestions(final int interposedQuestions) {
this.interposedQuestions = interposedQuestions;
}
@ApiModelProperty(required = true, value = "the number of flashcards")
@JsonView(View.Public.class)
public int getFlashcards() {
return flashcards;
}
public void setFlashcards(final int flashcards) {
this.flashcards = flashcards;
}
@ApiModelProperty(required = true, value = "the number of creators")
@JsonView(View.Public.class)
public int getCreators() {
return creators;
}
public void setCreators(int creators) {
public void setCreators(final int creators) {
this.creators = creators;
}
@ApiModelProperty(required = true, value = "the number of concept Questions")
@JsonView(View.Public.class)
public int getConceptQuestions() {
return conceptQuestions;
}
public void setConceptQuestions(int conceptQuestions) {
public void setConceptQuestions(final int conceptQuestions) {
this.conceptQuestions = conceptQuestions;
}
@ApiModelProperty(required = true, value = "the number of active Students")
@JsonView(View.Public.class)
public int getActiveStudents() {
return activeStudents;
}
public void setActiveStudents(final int activeStudents) {
this.activeStudents = activeStudents;
}
@Override
public int hashCode() {
return (this.getClass().getName()
......
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2015 The ARSnova Team
* Copyright (C) 2012-2019 The ARSnova Team and Contributors
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -15,74 +15,66 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.entities.transport;
import java.util.ArrayList;
import java.util.List;
package de.thm.arsnova.model;
public class InterposedQuestion {
import com.fasterxml.jackson.annotation.JsonView;
import java.util.Date;
import javax.validation.constraints.NotBlank;
import org.springframework.core.style.ToStringCreator;
private String id;
private String subject;
private String text;
private long timestamp;
private boolean read;
public static List<InterposedQuestion> fromList(List<de.thm.arsnova.entities.InterposedQuestion> questions) {
ArrayList<InterposedQuestion> interposedQuestions = new ArrayList<InterposedQuestion>();
for (de.thm.arsnova.entities.InterposedQuestion question : questions) {
interposedQuestions.add(new InterposedQuestion(question));
}
return interposedQuestions;
}
import de.thm.arsnova.model.serialization.View;
public InterposedQuestion(de.thm.arsnova.entities.InterposedQuestion question) {
this.id = question.get_id();
this.subject = question.getSubject();
this.text = question.getText();
this.timestamp = question.getTimestamp();
this.read = question.isRead();
}
public InterposedQuestion() {}
public class TextAnswer extends Answer {
@NotBlank
private String subject;
public String getId() {
return id;
}
@NotBlank
private String body;
public void setId(String id) {
this.id = id;
}
private boolean read;
@JsonView({View.Persistence.class, View.Public.class})
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
@JsonView({View.Persistence.class, View.Public.class})
public void setSubject(final String subject) {
this.subject = subject;
}
public String getText() {
return text;
@JsonView({View.Persistence.class, View.Public.class})
public String getBody() {
return body;
}
public void setText(String text) {
this.text = text;
@JsonView({View.Persistence.class, View.Public.class})
public void setBody(final String body) {
this.body = body;
}
public long getTimestamp() {
return timestamp;
@JsonView({View.Persistence.class, View.Public.class})
public boolean isRead() {
return read;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
@JsonView({View.Persistence.class, View.Public.class})
public void setRead(final boolean read) {
this.read = read;
}
public boolean isRead() {
return read;
@Override
@JsonView({View.Persistence.class, View.Public.class})
public Date getCreationTimestamp() {
return creationTimestamp;
}
public void setRead(boolean read) {
this.read = read;
@Override
protected ToStringCreator buildToString() {
return super.buildToString()
.append("subject", subject)
.append("body", body)
.append("read", read);
}
}
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2019 The ARSnova Team and Contributors
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ARSnova Backend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.model;
import com.fasterxml.jackson.annotation.JsonView;
import java.util.Date;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import javax.validation.constraints.NotEmpty;
import org.springframework.core.style.ToStringCreator;
import de.thm.arsnova.model.serialization.View;
public class UserProfile extends Entity {
public enum AuthProvider {
NONE,
UNKNOWN,
ANONYMIZED,
ARSNOVA,
ARSNOVA_GUEST,
LDAP,
SAML,
CAS,
OIDC,
GOOGLE,
FACEBOOK,
TWITTER
}
public static class Account {
@NotEmpty
private String password;
private String activationKey;
private String passwordResetKey;
private Date passwordResetTime;
@JsonView(View.Persistence.class)
public String getPassword() {
return password;
}
@JsonView(View.Persistence.class)
public void setPassword(final String password) {
this.password = password;
}
@JsonView(View.Persistence.class)
public String getActivationKey() {
return activationKey;
}
@JsonView(View.Persistence.class)
public void setActivationKey(final String activationKey) {
this.activationKey = activationKey;
}
@JsonView(View.Persistence.class)
public String getPasswordResetKey() {
return passwordResetKey;
}
@JsonView(View.Persistence.class)
public void setPasswordResetKey(final String passwordResetKey) {
this.passwordResetKey = passwordResetKey;
}
@JsonView(View.Persistence.class)
public Date getPasswordResetTime() {
return passwordResetTime;
}
@JsonView(View.Persistence.class)
public void setPasswordResetTime(final Date passwordResetTime) {
this.passwordResetTime = passwordResetTime;
}
@Override
public int hashCode() {
return Objects.hash(password, activationKey, passwordResetKey, passwordResetTime);
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!super.equals(o)) {
return false;
}
final Account account = (Account) o;
return Objects.equals(password, account.password)
&& Objects.equals(activationKey, account.activationKey)
&& Objects.equals(passwordResetKey, account.passwordResetKey)
&& Objects.equals(passwordResetTime, account.passwordResetTime);
}
@Override
public String toString() {
return new ToStringCreator(this)
.append("password", password)
.append("activationKey", activationKey)
.append("passwordResetKey", passwordResetKey)
.append("passwordResetTime", passwordResetTime)
.toString();
}
}
public static class RoomHistoryEntry {
private String roomId;
private Date lastVisit;
public RoomHistoryEntry() {
}
public RoomHistoryEntry(final String roomId, final Date lastVisit) {
this.roomId = roomId;
this.lastVisit = lastVisit;
}
@JsonView(View.Persistence.class)
public String getRoomId() {
return roomId;
}
@JsonView(View.Persistence.class)
public void setRoomId(final String roomId) {
this.roomId = roomId;
}
@JsonView(View.Persistence.class)
public Date getLastVisit() {
return lastVisit;
}
@JsonView(View.Persistence.class)
public void setLastVisit(final Date lastVisit) {
this.lastVisit = lastVisit;
}
@Override
public int hashCode() {
return Objects.hash(roomId);
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final RoomHistoryEntry that = (RoomHistoryEntry) o;
return Objects.equals(roomId, that.roomId);
}
@Override
public String toString() {
return new ToStringCreator(this)
.append("roomId", roomId)
.append("lastVisit", lastVisit)
.toString();
}
}
private AuthProvider authProvider;
private String loginId;
private Date lastLoginTimestamp;
private Account account;
/* TODO: Review - is a Map more appropriate?
* pro List: can be ordered by date
* pro Map (roomId -> RoomHistoryEntry): easier to access for updating lastVisit
* -> Map but custom serialization to array? */
private Set<RoomHistoryEntry> roomHistory = new HashSet<>();
private Set<String> acknowledgedMotds = new HashSet<>();
private Map<String, Map<String, Object>> extensions;
public UserProfile() {
}
public UserProfile(final AuthProvider authProvider, final String loginId) {
this.authProvider = authProvider;
this.loginId = loginId;
}
@JsonView({View.Persistence.class, View.Public.class})
public AuthProvider getAuthProvider() {
return authProvider;
}
@JsonView(View.Persistence.class)
public void setAuthProvider(final AuthProvider authProvider) {
this.authProvider = authProvider;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getLoginId() {
return loginId;
}
@JsonView(View.Persistence.class)
public void setLoginId(final String loginId) {
this.loginId = loginId;
}
@JsonView({View.Persistence.class, View.Owner.class})
public Date getLastLoginTimestamp() {
return lastLoginTimestamp;
}
@JsonView(View.Persistence.class)
public void setLastLoginTimestamp(final Date lastLoginTimestamp) {
this.lastLoginTimestamp = lastLoginTimestamp;
}
@JsonView(View.Persistence.class)
public Account getAccount() {
return account;
}
@JsonView(View.Persistence.class)
public void setAccount(final Account account) {
this.account = account;
}
@JsonView({View.Persistence.class, View.Owner.class})
public Set<RoomHistoryEntry> getRoomHistory() {
return roomHistory;
}
@JsonView(View.Persistence.class)
public void setRoomHistory(final Set<RoomHistoryEntry> roomHistory) {
this.roomHistory = roomHistory;
}
@JsonView({View.Persistence.class, View.Owner.class})
public Set<String> getAcknowledgedMotds() {
return acknowledgedMotds;
}
@JsonView(View.Persistence.class)
public void setAcknowledgedMotds(final Set<String> acknowledgedMotds) {
this.acknowledgedMotds = acknowledgedMotds;
}
@JsonView({View.Persistence.class, View.Owner.class})
public Map<String, Map<String, Object>> getExtensions() {
return extensions;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setExtensions(final Map<String, Map<String, Object>> extensions) {
this.extensions = extensions;
}
/**
* {@inheritDoc}
*
* <p>
* The following fields of <tt>UserProfile</tt> are excluded from equality checks:
* {@link #account}, {@link #roomHistory}, {@link #acknowledgedMotds}, {@link #extensions}.
* </p>
*/
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!super.equals(o)) {
return false;
}
final UserProfile that = (UserProfile) o;
return authProvider == that.authProvider
&& Objects.equals(loginId, that.loginId)
&& Objects.equals(lastLoginTimestamp, that.lastLoginTimestamp);
}
@Override
protected ToStringCreator buildToString() {
return super.buildToString()
.append("authProvider", authProvider)
.append("loginId", loginId)
.append("lastLoginTimestamp", lastLoginTimestamp)
.append("account", account)
.append("roomHistory", roomHistory)
.append("acknowledgedMotds", acknowledgedMotds);
}
}