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 508 additions and 437 deletions
package de.thm.arsnova.entities;
public class ServiceDescription {
private String id;
private String name;
private String dialogUrl;
private String image;
private int order = 0;
private boolean allowLecturer = true;
public ServiceDescription(String id, String name, String dialogUrl) {
this.id = id;
this.name = name;
this.dialogUrl = dialogUrl;
}
public ServiceDescription(String id, String name, String dialogUrl, String image) {
this.id = id;
this.name = name;
this.dialogUrl = dialogUrl;
if (!"".equals(image)) {
this.image = image;
}
}
public ServiceDescription(String id, String name, String dialogUrl, boolean allowLecturer) {
this.id = id;
this.name = name;
this.dialogUrl = dialogUrl;
this.allowLecturer = allowLecturer;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDialogUrl() {
return dialogUrl;
}
public void setDialogUrl(String dialogUrl) {
this.dialogUrl = dialogUrl;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public boolean isAllowLecturer() {
return allowLecturer;
}
public void setAllowLecturer(boolean allowLecturer) {
this.allowLecturer = allowLecturer;
}
}
/*
* Copyright (C) 2012 THM webMedia
*
* This file is part of ARSnova.
*
* ARSnova 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 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.entities;
import java.io.Serializable;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnore;
public class Session implements Serializable {
private static final long serialVersionUID = 1L;
private String type;
private String name;
private String shortName;
private String keyword;
private String creator;
private boolean active;
private long lastOwnerActivity;
private String courseType;
private String courseId;
private List<String> _conflicts;
private String _id;
private String _rev;
public String getType() {
return type;
}
public void setType(final String type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public String getShortName() {
return shortName;
}
public void setShortName(final String shortName) {
this.shortName = shortName;
}
public String getKeyword() {
return keyword;
}
public void setKeyword(final String keyword) {
this.keyword = keyword;
}
public String getCreator() {
return creator;
}
public void setCreator(final String creator) {
this.creator = creator;
}
public boolean isActive() {
return active;
}
public void setActive(final boolean active) {
this.active = active;
}
public long getLastOwnerActivity() {
return lastOwnerActivity;
}
public void setLastOwnerActivity(final long lastOwnerActivity) {
this.lastOwnerActivity = lastOwnerActivity;
}
public void set_id(final String id) {
_id = id;
}
public String get_id() {
return _id;
}
public void set_rev(final String rev) {
_rev = rev;
}
public String get_rev() {
return _rev;
}
public void set_conflicts(final List<String> conflicts) {
_conflicts = conflicts;
}
public List<String> get_conflicts() {
return _conflicts;
}
public boolean isCreator(final User user) {
return user.getUsername().equals(creator);
}
public String getCourseType() {
return courseType;
}
public void setCourseType(final String courseType) {
this.courseType = courseType;
}
public String getCourseId() {
return courseId;
}
public void setCourseId(final String courseId) {
this.courseId = courseId;
}
@JsonIgnore
public boolean isCourseSession() {
return getCourseId() != null && !getCourseId().isEmpty();
}
@Override
public String toString() {
return "Session [keyword=" + keyword+ ", type=" + type + "]";
}
}
package de.thm.arsnova.entities;
public class Statistics {
private int answers;
private int questions;
private int openSessions;
private int closedSessions;
private int activeUsers;
private int loggedinUsers;
public int getAnswers() {
return answers;
}
public void setAnswers(final int answers) {
this.answers = answers;
}
public int getQuestions() {
return questions;
}
public void setQuestions(final int questions) {
this.questions = questions;
}
public int getOpenSessions() {
return openSessions;
}
public void setOpenSessions(final int openSessions) {
this.openSessions = openSessions;
}
public int getClosedSessions() {
return closedSessions;
}
public void setClosedSessions(final int closedSessions) {
this.closedSessions = closedSessions;
}
public int getActiveUsers() {
return activeUsers;
}
public void setActiveUsers(final int activeUsers) {
this.activeUsers = activeUsers;
}
public int getLoggedinUsers() {
return loggedinUsers;
}
public void setLoggedinUsers(final int loggedinUsers) {
this.loggedinUsers = loggedinUsers;
}
public int getAverageAnswersPerQuestion() {
if (getQuestions() > 0) {
return getAnswers() / getQuestions();
}
return 0;
}
public void setAverageAnswersPerQuestion(final int value) {
// NOP
}
@Override
public int hashCode() {
return (this.getClass().getName()
+ activeUsers
+ answers
+ closedSessions
+ openSessions
+ questions
+ loggedinUsers
).hashCode();
}
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (obj == this) {
return true;
}
if (obj instanceof Statistics) {
final Statistics other = (Statistics) obj;
return hashCode() == other.hashCode();
}
return false;
}
}
package de.thm.arsnova.entities;
import java.io.Serializable;
import org.jasig.cas.client.authentication.AttributePrincipal;
import org.scribe.up.profile.facebook.FacebookProfile;
import org.scribe.up.profile.google.Google2Profile;
import org.scribe.up.profile.twitter.TwitterProfile;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import de.thm.arsnova.services.UserSessionService;
public class User implements Serializable {
public static final String GOOGLE = "google";
public static final String TWITTER = "twitter";
public static final String FACEBOOK = "facebook";
public static final String THM = "thm";
public static final String LDAP = "ldap";
public static final String ARSNOVA = "arsnova";
public static final String ANONYMOUS = "anonymous";
public static final String GUEST = "guest";
private static final long serialVersionUID = 1L;
private String username;
private String type;
private UserSessionService.Role role;
public User(Google2Profile profile) {
setUsername(profile.getEmail());
setType(User.GOOGLE);
}
public User(TwitterProfile profile) {
setUsername(profile.getScreenName());
setType(User.TWITTER);
}
public User(FacebookProfile profile) {
setUsername(profile.getLink());
setType(User.FACEBOOK);
}
public User(AttributePrincipal principal) {
setUsername(principal.getName());
setType(User.THM);
}
public User(AnonymousAuthenticationToken token) {
setUsername(User.ANONYMOUS);
setType(User.ANONYMOUS);
}
public User(UsernamePasswordAuthenticationToken token) {
setUsername(token.getName());
setType(LDAP);
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public UserSessionService.Role getRole() {
return role;
}
public void setRole(UserSessionService.Role role) {
this.role = role;
}
public boolean hasRole(UserSessionService.Role role) {
return this.role == role;
}
@Override
public String toString() {
return "User [username=" + username + ", type=" + type + "]";
}
@Override
public int hashCode() {
// See http://stackoverflow.com/a/113600
final int theAnswer = 42;
final int theOthers = 37;
int result = theAnswer;
result = theOthers * result + this.username.hashCode();
return theOthers * result + this.type.hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null || !obj.getClass().equals(this.getClass())) {
return false;
}
User other = (User) obj;
return this.username.equals(other.username) && this.type.equals(other.type);
}
}
package de.thm.arsnova.entities;
/*
* 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.event;
import de.thm.arsnova.model.Entity;
public class AfterCreationEvent<E extends Entity> extends CrudEvent<E> {
public AfterCreationEvent(final Object source, final E entity) {
super(source, entity);
}
}
/*
* 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.event;
import de.thm.arsnova.model.Entity;
public class AfterDeletionEvent<E extends Entity> extends CrudEvent<E> {
public AfterDeletionEvent(final Object source, final E entity) {
super(source, entity);
}
}
/*
* 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.event;
import de.thm.arsnova.model.Entity;
public class AfterFullUpdateEvent<E extends Entity> extends AfterUpdateEvent<E> {
private final E oldEntity;
public AfterFullUpdateEvent(final Object source, final E entity, final E oldEntity) {
super(source, entity);
this.oldEntity = oldEntity;
}
public E getOldEntity() {
return oldEntity;
}
}
/*
* 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.event;
import java.util.Map;
import java.util.function.Function;
import de.thm.arsnova.model.Entity;
public class AfterPatchEvent<E extends Entity> extends AfterUpdateEvent<E> {
private final Function<E, ? extends Object> propertyGetter;
private final Map<String, Object> changes;
public AfterPatchEvent(final Object source, final E entity, final Function<E, ? extends Object> propertyGetter,
final Map<String, Object> changes) {
super(source, entity);
this.propertyGetter = propertyGetter;
this.changes = changes;
}
public Function<E, ? extends Object> getPropertyGetter() {
return propertyGetter;
}
public Map<String, Object> getChanges() {
return changes;
}
}
/*
* 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.event;
import de.thm.arsnova.model.Entity;
public abstract class AfterUpdateEvent<E extends Entity> extends CrudEvent<E> {
public AfterUpdateEvent(final Object source, final E entity) {
super(source, entity);
}
}
/*
* 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.event;
import org.springframework.context.ApplicationEvent;
/**
* Base class of an ARSnova event.
*/
public abstract class ArsnovaEvent extends ApplicationEvent {
private static final long serialVersionUID = 1L;
public ArsnovaEvent(final Object source) {
super(source);
}
}
/*
* 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.event;
import de.thm.arsnova.model.Entity;
public class BeforeCreationEvent<E extends Entity> extends CrudEvent<E> {
public BeforeCreationEvent(final Object source, final E entity) {
super(source, entity);
}
}
/*
* 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.event;
import de.thm.arsnova.model.Entity;
public class BeforeDeletionEvent<E extends Entity> extends CrudEvent<E> {
public BeforeDeletionEvent(final Object source, final E entity) {
super(source, entity);
}
}
/*
* 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.event;
import de.thm.arsnova.model.Entity;
public class BeforeFullUpdateEvent<E extends Entity> extends BeforeUpdateEvent<E> {
private final E oldEntity;
public BeforeFullUpdateEvent(final Object source, final E entity, final E oldEntity) {
super(source, entity);
this.oldEntity = oldEntity;
}
public E getOldEntity() {
return oldEntity;
}
}
/*
* 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.event;
import java.util.Map;
import java.util.function.Function;
import de.thm.arsnova.model.Entity;
public class BeforePatchEvent<E extends Entity> extends BeforeUpdateEvent<E> {
private final Function<E, ? extends Object> propertyGetter;
private final Map<String, Object> changes;
public BeforePatchEvent(final Object source, final E entity, final Function<E, ? extends Object> propertyGetter,
final Map<String, Object> changes) {
super(source, entity);
this.propertyGetter = propertyGetter;
this.changes = changes;
}
public Function<E, ? extends Object> getPropertyGetter() {
return propertyGetter;
}
public Map<String, Object> getChanges() {
return changes;
}
}
/*
* 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.event;
import de.thm.arsnova.model.Entity;
public abstract class BeforeUpdateEvent<E extends Entity> extends CrudEvent<E> {
public BeforeUpdateEvent(final Object source, final E entity) {
super(source, entity);
}
}
/*
* 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.event;
/**
* Fires whenever a score related value changes.
*/
public class ChangeScoreEvent extends RoomEvent {
private static final long serialVersionUID = 1L;
public ChangeScoreEvent(final Object source, final String roomId) {
super(source, roomId);
}
}
/*
* 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.event;
import org.springframework.context.ApplicationEvent;
import org.springframework.core.ResolvableType;
import org.springframework.core.ResolvableTypeProvider;
import de.thm.arsnova.model.Entity;
public abstract class CrudEvent<E extends Entity> extends ApplicationEvent implements ResolvableTypeProvider {
private E entity;
public CrudEvent(final Object source, final E entity) {
super(source);
this.entity = entity;
}
public E getEntity() {
return entity;
}
@Override
public ResolvableType getResolvableType() {
return ResolvableType.forClassWithGenerics(getClass(), entity.getClass());
}
}
/*
* 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.event;
import java.util.Set;
import de.thm.arsnova.model.Room;
/**
* Fires whenever the feedback of a specific user has been reset.
*/
public class DeleteFeedbackForRoomsEvent extends ArsnovaEvent {
private static final long serialVersionUID = 1L;
private final Set<Room> sessions;
private final String userId;
public DeleteFeedbackForRoomsEvent(final Object source, final Set<Room> rooms, final String userId) {
super(source);
this.sessions = rooms;
this.userId = userId;
}
public Set<Room> getSessions() {
return sessions;
}
public String getUserId() {
return userId;
}
}
/*
* 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.event;
/**
* Fires whenever voting on a question is disabled.
*/
public class FlipFlashcardsEvent extends RoomEvent {
private static final long serialVersionUID = 1L;
public FlipFlashcardsEvent(final Object source, final String roomId) {
super(source, roomId);
}
}