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 1805 additions and 23 deletions
package de.thm.arsnova.exceptions;
public class NotFoundException extends RuntimeException {
private static final long serialVersionUID = 1L;
}
package de.thm.arsnova.exceptions;
public class NotImplementedException extends RuntimeException {
private static final long serialVersionUID = 1L;
}
package de.thm.arsnova.exceptions;
public class PreconditionFailedException extends RuntimeException {
private static final long serialVersionUID = 1L;
}
package de.thm.arsnova.exceptions;
public class UnauthorizedException extends RuntimeException {
private static final long serialVersionUID = 1L;
}
package de.thm.arsnova.exceptions;
/*
* 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.management;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.stereotype.Component;
import de.thm.arsnova.model.Statistics;
import de.thm.arsnova.service.StatisticsService;
@Component
@Endpoint(id = "stats")
public class StatisticsEndpoint {
private StatisticsService statisticsService;
public StatisticsEndpoint(final StatisticsService statisticsService) {
this.statisticsService = statisticsService;
}
@ReadOperation
public Statistics readStatistics() {
return statisticsService.getStatistics();
}
}
/*
* 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.management;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import javax.annotation.Resource;
import org.springframework.boot.actuate.info.Info;
import org.springframework.boot.actuate.info.InfoContributor;
import org.springframework.stereotype.Component;
@Component
public class VersionInfoContributor implements InfoContributor {
private Map<String, Object> infoDetails;
@Override
public void contribute(final Info.Builder builder) {
builder.withDetails(infoDetails);
}
@Resource(name = "versionInfoProperties")
public void setVersionInfoProperties(final Properties versionInfoProperties) {
infoDetails = new HashMap<>();
final Map<String, Object> version = new HashMap<>();
version.put("string", versionInfoProperties.getProperty("version.string"));
version.put("buildTime", versionInfoProperties.getProperty("version.build-time"));
version.put("gitCommitId", versionInfoProperties.getProperty("version.git.commit-id"));
version.put("gitDirty", Boolean.parseBoolean(versionInfoProperties.getProperty("version.git.dirty")));
infoDetails.put("productName", "arsnova-backend");
infoDetails.put("version", version);
}
public Map<String, Object> getInfoDetails() {
return infoDetails;
}
}
/*
* 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.Map;
import java.util.Objects;
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.FormatAnswerTypeIdResolver;
import de.thm.arsnova.model.serialization.View;
@JsonTypeInfo(
use = JsonTypeInfo.Id.CUSTOM,
property = "format",
visible = true,
defaultImpl = Answer.class
)
@JsonTypeIdResolver(FormatAnswerTypeIdResolver.class)
public class Answer extends Entity {
@NotEmpty
private String contentId;
@NotEmpty
private String roomId;
@NotEmpty
private String creatorId;
@NotNull
private Content.Format format;
@Positive
private int round = 1;
private Map<String, Map<String, Object>> extensions;
@JsonView({View.Persistence.class, View.Public.class})
public String getContentId() {
return contentId;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setContentId(final String contentId) {
this.contentId = contentId;
}
@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 String getCreatorId() {
return creatorId;
}
public void setCreatorId(final String creatorId) {
this.creatorId = creatorId;
}
@JsonView({View.Persistence.class, View.Public.class})
public Content.Format getFormat() {
return format;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setFormat(final Content.Format format) {
this.format = format;
}
@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 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)
@Override
public Class<? extends Entity> getType() {
return Answer.class;
}
/**
* {@inheritDoc}
*
* <p>
* The following fields of <tt>Answer</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 Answer answer = (Answer) o;
return round == answer.round
&& Objects.equals(contentId, answer.contentId)
&& Objects.equals(roomId, answer.roomId)
&& Objects.equals(creatorId, answer.creatorId);
}
@Override
protected ToStringCreator buildToString() {
return super.buildToString()
.append("contentId", contentId)
.append("roomId", roomId)
.append("creatorId", creatorId)
.append("format", format)
.append("round", round);
}
}
/*
* 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.Collection;
import java.util.List;
import org.springframework.core.style.ToStringCreator;
import de.thm.arsnova.model.serialization.View;
public class AnswerStatistics {
public static class RoundStatistics {
public static class Combination {
private List<Integer> selectedChoiceIndexes;
private int count;
public Combination(final List<Integer> selectedChoiceIndexes, final int count) {
this.selectedChoiceIndexes = selectedChoiceIndexes;
this.count = count;
}
@JsonView(View.Public.class)
public List<Integer> getSelectedChoiceIndexes() {
return selectedChoiceIndexes;
}
@JsonView(View.Public.class)
public int getCount() {
return count;
}
@Override
public String toString() {
return new ToStringCreator(this)
.append("selectedChoiceIndexes", selectedChoiceIndexes)
.append("count", count)
.toString();
}
}
private int round;
private List<Integer> independentCounts;
private Collection<Combination> combinatedCounts;
private int abstentionCount;
@JsonView(View.Public.class)
public int getRound() {
return round;
}
public void setRound(final int round) {
this.round = round;
}
@JsonView(View.Public.class)
public List<Integer> getIndependentCounts() {
if (independentCounts == null) {
independentCounts = new ArrayList<>();
}
return independentCounts;
}
public void setIndependentCounts(final List<Integer> independentCounts) {
this.independentCounts = independentCounts;
}
@JsonView(View.Public.class)
public Collection<Combination> getCombinatedCounts() {
if (combinatedCounts == null) {
combinatedCounts = new ArrayList<>();
}
return combinatedCounts;
}
public void setCombinatedCounts(final Collection<Combination> combinatedCounts) {
this.combinatedCounts = combinatedCounts;
}
@JsonView(View.Public.class)
public int getAbstentionCount() {
return abstentionCount;
}
public void setAbstentionCount(final int abstentionCount) {
this.abstentionCount = abstentionCount;
}
@Override
public String toString() {
return new ToStringCreator(this)
.append("round", round)
.append("independentCounts", independentCounts)
.append("combinatedCounts", combinatedCounts)
.append("abstentionCount", abstentionCount)
.toString();
}
}
public static class RoundTransition {
private int roundA;
private int roundB;
private List<Integer> selectedChoiceIndexesA;
private List<Integer> selectedChoiceIndexesB;
private int count;
public RoundTransition(final int roundA, final List<Integer> selectedChoiceIndexesA,
final int roundB, final List<Integer> selectedChoiceIndexesB, final int count) {
this.roundA = roundA;
this.roundB = roundB;
this.selectedChoiceIndexesA = selectedChoiceIndexesA;
this.selectedChoiceIndexesB = selectedChoiceIndexesB;
this.count = count;
}
@JsonView(View.Public.class)
public int getRoundA() {
return roundA;
}
@JsonView(View.Public.class)
public int getRoundB() {
return roundB;
}
@JsonView(View.Public.class)
public List<Integer> getSelectedChoiceIndexesA() {
return selectedChoiceIndexesA;
}
@JsonView(View.Public.class)
public List<Integer> getSelectedChoiceIndexesB() {
return selectedChoiceIndexesB;
}
@JsonView(View.Public.class)
public int getCount() {
return count;
}
@Override
public String toString() {
return new ToStringCreator(this)
.append("roundA", roundA)
.append("selectedChoiceIndexesA", selectedChoiceIndexesA)
.append("roundB", roundB)
.append("selectedChoiceIndexesB", selectedChoiceIndexesB)
.append("count", count)
.toString();
}
}
private String contentId;
private List<RoundStatistics> roundStatistics;
private List<RoundTransition> roundTransitions;
@JsonView(View.Public.class)
public String getContentId() {
return contentId;
}
public void setContentId(final String contentId) {
this.contentId = contentId;
}
@JsonView(View.Public.class)
public List<RoundStatistics> getRoundStatistics() {
return roundStatistics;
}
public void setRoundStatistics(final List<RoundStatistics> roundStatistics) {
this.roundStatistics = roundStatistics;
}
@JsonView(View.Public.class)
public List<RoundTransition> getRoundTransitions() {
return roundTransitions;
}
public void setRoundTransitions(final List<RoundTransition> roundTransitions) {
this.roundTransitions = roundTransitions;
}
@Override
public String toString() {
return new ToStringCreator(this)
.append("contentId", contentId)
.append("roundStatistics", roundStatistics)
.append("roundTransitions", roundTransitions)
.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.Objects;
import org.springframework.core.style.ToStringCreator;
import de.thm.arsnova.model.serialization.View;
public class Attachment extends Entity {
private String mediaType;
private long size;
private String originalSourceUrl;
private String storageLocation;
@Override
@JsonView({View.Persistence.class, View.Public.class})
public String getId() {
return id;
}
@Override
@JsonView(View.Persistence.class)
public void setId(final String id) {
this.id = id;
}
@Override
@JsonView({View.Persistence.class, View.Public.class})
public String getRevision() {
return rev;
}
@Override
@JsonView(View.Public.class)
public void setRevision(final String rev) {
this.rev = rev;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getMediaType() {
return mediaType;
}
@JsonView(View.Persistence.class)
public void setMediaType(final String mediaType) {
this.mediaType = mediaType;
}
@JsonView(View.Persistence.class)
public long getSize() {
return size;
}
@JsonView(View.Persistence.class)
public void setSize(final long size) {
this.size = size;
}
@JsonView({View.Persistence.class, View.Public.class})
public String getOriginalSourceUrl() {
return originalSourceUrl;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setOriginalSourceUrl(final String originalSourceUrl) {
this.originalSourceUrl = originalSourceUrl;
}
@JsonView(View.Persistence.class)
public String getStorageLocation() {
return storageLocation;
}
@JsonView(View.Persistence.class)
public void setStorageLocation(final String storageLocation) {
this.storageLocation = storageLocation;
}
/**
* {@inheritDoc}
*
* <p>
* All fields of <tt>Attachment</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 Attachment that = (Attachment) o;
return size == that.size
&& Objects.equals(mediaType, that.mediaType)
&& Objects.equals(originalSourceUrl, that.originalSourceUrl)
&& Objects.equals(storageLocation, that.storageLocation);
}
@Override
protected ToStringCreator buildToString() {
return super.buildToString()
.append("mediaType", mediaType)
.append("size", size)
.append("originalSourceUrl", originalSourceUrl)
.append("storageLocation", storageLocation);
}
}
/*
* 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.Set;
import de.thm.arsnova.config.properties.AuthenticationProviderProperties;
import de.thm.arsnova.model.serialization.View;
public class AuthenticationProvider {
public enum Type {
ANONYMOUS,
USERNAME_PASSWORD,
SSO
}
private String id;
private boolean enabled;
private String title;
private int order;
private Set<AuthenticationProviderProperties.Provider.Role> allowedRoles;
private Type type;
public AuthenticationProvider(final String id, final AuthenticationProviderProperties.Provider provider) {
this.id = id;
this.enabled = provider.isEnabled();
this.title = provider.getTitle();
this.order = provider.getOrder();
this.allowedRoles = provider.getAllowedRoles();
if (provider instanceof AuthenticationProviderProperties.Guest) {
type = Type.ANONYMOUS;
} else if (provider instanceof AuthenticationProviderProperties.Registered
|| provider instanceof AuthenticationProviderProperties.Ldap) {
type = Type.USERNAME_PASSWORD;
} else {
type = Type.SSO;
}
}
@JsonView(View.Public.class)
public String getId() {
return id;
}
public void setId(final String id) {
this.id = id;
}
public boolean isEnabled() {
return enabled;
}
public void setEnabled(final boolean enabled) {
this.enabled = enabled;
}
@JsonView(View.Public.class)
public String getTitle() {
return title;
}
public void setTitle(final String title) {
this.title = title;
}
@JsonView(View.Public.class)
public int getOrder() {
return order;
}
public void setOrder(final int order) {
this.order = order;
}
@JsonView(View.Public.class)
public Set<AuthenticationProviderProperties.Provider.Role> getAllowedRoles() {
return allowedRoles;
}
public void setAllowedRoles(final Set<AuthenticationProviderProperties.Provider.Role> allowedRoles) {
this.allowedRoles = allowedRoles;
}
@JsonView(View.Public.class)
public Type getType() {
return type;
}
public void setType(final Type type) {
this.type = type;
}
}
/* /*
* This file is part of ARSnova Backend. * 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 * 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 * it under the terms of the GNU General Public License as published by
...@@ -15,12 +15,18 @@ ...@@ -15,12 +15,18 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * 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 de.thm.arsnova.model.serialization.View;
public class Authorize { public class Authorize {
private String user; private String user;
private String socketid; private String socketid;
@JsonView(View.Public.class)
public final String getUser() { public final String getUser() {
return user; return user;
} }
...@@ -29,6 +35,7 @@ public class Authorize { ...@@ -29,6 +35,7 @@ public class Authorize {
this.user = user; this.user = user;
} }
@JsonView(View.Public.class)
public final String getSocketid() { public final String getSocketid() {
return socketid; return socketid;
} }
......
/*
* 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 javax.validation.constraints.PositiveOrZero;
import org.springframework.core.style.ToStringCreator;
import de.thm.arsnova.model.serialization.View;
public class ChoiceAnswer extends Answer {
private List<@PositiveOrZero Integer> selectedChoiceIndexes;
@JsonView({View.Persistence.class, View.Public.class})
public List<Integer> getSelectedChoiceIndexes() {
return selectedChoiceIndexes;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setSelectedChoiceIndexes(final List<Integer> selectedChoiceIndexes) {
this.selectedChoiceIndexes = selectedChoiceIndexes;
}
@Override
protected ToStringCreator buildToString() {
return super.buildToString()
.append("selectedChoiceIndexes", selectedChoiceIndexes);
}
}
/*
* 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 java.util.Objects;
import javax.validation.constraints.NotBlank;
import org.springframework.core.style.ToStringCreator;
import de.thm.arsnova.model.serialization.View;
public class ChoiceQuestionContent extends Content {
public static class AnswerOption {
@NotBlank
private String label;
private int points;
@JsonView({View.Persistence.class, View.Public.class})
public String getLabel() {
return label;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setLabel(final String label) {
this.label = label;
}
@JsonView({View.Persistence.class, View.Public.class})
public int getPoints() {
return points;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setPoints(final int points) {
this.points = points;
}
@Override
public int hashCode() {
return Objects.hash(label, points);
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!super.equals(o)) {
return false;
}
final AnswerOption that = (AnswerOption) o;
return points == that.points
&& Objects.equals(label, that.label);
}
@Override
public String toString() {
return new ToStringCreator(this)
.append("label", label)
.append("points", points)
.toString();
}
}
private List<AnswerOption> options = new ArrayList<>();
private List<Integer> correctOptionIndexes = new ArrayList<>();
private boolean multiple;
@JsonView({View.Persistence.class, View.Public.class})
public List<AnswerOption> getOptions() {
return options;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setOptions(final List<AnswerOption> options) {
this.options = options;
}
/* 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;
}
@JsonView({View.Persistence.class, View.Public.class})
public boolean isMultiple() {
return multiple;
}
@JsonView({View.Persistence.class, View.Public.class})
public void setMultiple(final boolean multiple) {
this.multiple = multiple;
}
@Override
protected ToStringCreator buildToString() {
return super.buildToString()
.append("options", options)
.append("correctOptionIndexes", correctOptionIndexes)
.append("multiple", multiple);
}
}
/*
* 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 org.springframework.core.style.ToStringCreator;
import de.thm.arsnova.model.serialization.View;
public class ClientAuthentication {
private String userId;
private String loginId;
private UserProfile.AuthProvider authProvider;
private String token;
public ClientAuthentication(final String userId, final String loginId, final UserProfile.AuthProvider authProvider,
final String token) {
this.userId = userId;
this.loginId = loginId;
this.authProvider = authProvider;
this.token = token;
}
@JsonView(View.Public.class)
public String getUserId() {
return userId;
}
@JsonView(View.Public.class)
public String getLoginId() {
return loginId;
}
@JsonView(View.Public.class)
public UserProfile.AuthProvider getAuthProvider() {
return authProvider;
}
@JsonView(View.Public.class)
public String getToken() {
return token;
}
@Override
public String toString() {
return new ToStringCreator(this)
.append("userId", userId)
.append("loginId", loginId)
.append("authProvider", authProvider)
.append("token", token)
.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.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;
}
}