Skip to content

Commit

Permalink
Added missing SelectedItemsRequest implements; Simplified AIP requests (
Browse files Browse the repository at this point in the history
#3269)

Signed-off-by: sugarylump <[email protected]>
  • Loading branch information
SugaryLump authored Jul 30, 2024
1 parent cb3aa16 commit e6d01ab
Show file tree
Hide file tree
Showing 22 changed files with 477 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ public String toString() {
public static final String CONTROLLER_NOTIFICATION_ID_PARAM = "notificationId";
public static final String CONTROLLER_NOTIFICATION_TOKEN_PARAM = "token";
public static final String CONTROLLER_JOB_PARAM = "job";
public static final String CONTROLLER_JOB_CREATE_REQUEST = "createJobRequest";
public static final String CONTROLLER_JOB_ID_PARAM = "jobId";
public static final String CONTROLLER_JOB_JUST_FAILED_PARAM = "justFailed";
public static final String CONTROLLER_JOB_REPORT_ID_PARAM = "jobReportId";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package org.roda.core.data.utils;

import org.roda.core.data.v2.generics.select.SelectedItemsAllRequest;
import org.roda.core.data.v2.generics.select.SelectedItemsFilterRequest;
import org.roda.core.data.v2.generics.select.SelectedItemsListRequest;
import org.roda.core.data.v2.generics.select.SelectedItemsNoneRequest;
import org.roda.core.data.v2.generics.select.SelectedItemsRequest;
import org.roda.core.data.v2.index.select.SelectedItems;
import org.roda.core.data.v2.index.select.SelectedItemsAll;
import org.roda.core.data.v2.index.select.SelectedItemsFilter;
import org.roda.core.data.v2.index.select.SelectedItemsList;
import org.roda.core.data.v2.index.select.SelectedItemsNone;

/**
* @author Miguel Guimarães <[email protected]>
Expand All @@ -25,6 +29,10 @@ public static SelectedItemsRequest convertToRESTRequest(SelectedItems<?> items)
request.setFilter(((SelectedItemsFilter<?>) items).getFilter());
request.setJustActive(((SelectedItemsFilter<?>) items).justActive());
return request;
} else if (items instanceof SelectedItemsNone<?>) {
return new SelectedItemsNoneRequest();
} else if (items instanceof SelectedItemsAll<?>) {
return new SelectedItemsAllRequest();
}

return new SelectedItemsListRequest();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.roda.core.data.v2.generics.select;

import java.io.Serial;

import com.fasterxml.jackson.annotation.JsonTypeName;

/**
* @author Alexandre Flores <[email protected]>
*/
@JsonTypeName("SelectedItemsAllRequest")
public class SelectedItemsAllRequest implements SelectedItemsRequest {
@Serial
private static final long serialVersionUID = 165811248428623687L;

public SelectedItemsAllRequest() {
// do nothing
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.roda.core.data.v2.generics.select;

import java.io.Serial;

import com.fasterxml.jackson.annotation.JsonTypeName;

/**
* @author Alexandre Flores <[email protected]>
*/
@JsonTypeName("SelectedItemsNoneRequest")
public class SelectedItemsNoneRequest implements SelectedItemsRequest {
@Serial
private static final long serialVersionUID = 4225008000954460297L;

public SelectedItemsNoneRequest() {
// do nothing
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, visible = true, include = JsonTypeInfo.As.PROPERTY, property = "@type")
@JsonSubTypes({@JsonSubTypes.Type(value = SelectedItemsListRequest.class, name = "SelectedItemsListRequest"),
@JsonSubTypes.Type(value = SelectedItemsFilterRequest.class, name = "SelectedItemsFilterRequest")})
@JsonSubTypes.Type(value = SelectedItemsFilterRequest.class, name = "SelectedItemsFilterRequest"),
@JsonSubTypes.Type(value = SelectedItemsNoneRequest.class, name = "SelectedItemsNoneRequest"),
@JsonSubTypes.Type(value = SelectedItemsAllRequest.class, name = "SelectedItemsAllRequest")})
@Schema(type = "object", subTypes = {SelectedItemsListRequest.class,
SelectedItemsFilterRequest.class}, discriminatorMapping = {
SelectedItemsFilterRequest.class, SelectedItemsNoneRequest.class,
SelectedItemsAllRequest.class}, discriminatorMapping = {
@DiscriminatorMapping(value = "SelectedItemsListRequest", schema = SelectedItemsListRequest.class),
@DiscriminatorMapping(value = "SelectedItemsFilterRequest", schema = SelectedItemsFilterRequest.class)}, discriminatorProperty = "@type")
@DiscriminatorMapping(value = "SelectedItemsFilterRequest", schema = SelectedItemsFilterRequest.class),
@DiscriminatorMapping(value = "SelectedItemsNoneRequest", schema = SelectedItemsNoneRequest.class),
@DiscriminatorMapping(value = "SelectedItemsAllRequest", schema = SelectedItemsAllRequest.class)}, discriminatorProperty = "@type")
public interface SelectedItemsRequest extends Serializable {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package org.roda.core.data.v2.jobs;

import java.io.Serial;
import java.io.Serializable;
import java.util.Map;

import org.roda.core.data.v2.generics.select.SelectedItemsRequest;

/**
* @author Alexandre Flores <[email protected]>
*/
public class CreateJobRequest implements Serializable {

@Serial
private static final long serialVersionUID = 5136924368954184386L;

private String name;
private String plugin;
private Map<String, String> pluginParameters;
private SelectedItemsRequest sourceObjects;
private String sourceObjectsClass;
private String priority;
private String parallelism;

public CreateJobRequest() {
// do nothing
}

public String getParallelism() {
return parallelism;
}

public void setParallelism(String parallelism) {
this.parallelism = parallelism;
}

public String getPriority() {
return priority;
}

public void setPriority(String priority) {
this.priority = priority;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getPlugin() {
return plugin;
}

public void setPlugin(String plugin) {
this.plugin = plugin;
}

public Map<String, String> getPluginParameters() {
return pluginParameters;
}

public void setPluginParameters(Map<String, String> pluginParameters) {
this.pluginParameters = pluginParameters;
}

public SelectedItemsRequest getSourceObjects() {
return sourceObjects;
}

public void setSourceObjects(SelectedItemsRequest sourceObjects) {
this.sourceObjects = sourceObjects;
}

public String getSourceObjectsClass() {
return sourceObjectsClass;
}

public void setSourceObjectsClass(String sourceObjectsClass) {
this.sourceObjectsClass = sourceObjectsClass;
}
}
Original file line number Diff line number Diff line change
@@ -1,42 +1,87 @@
package org.roda.core.data.v2.user.requests;

import com.fasterxml.jackson.annotation.JsonInclude;
import org.roda.core.data.common.SecureString;
import org.roda.core.data.v2.generics.MetadataValue;
import org.roda.core.data.v2.user.User;

import java.io.Serial;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import org.roda.core.data.common.SecureString;
import org.roda.core.data.v2.generics.MetadataValue;

import com.fasterxml.jackson.annotation.JsonInclude;

/**
* @author António Lindo <[email protected]>
*/
@JsonInclude(JsonInclude.Include.ALWAYS)
public class CreateUserRequest implements Serializable {

@Serial
private static final long serialVersionUID = -2706255856347304025L;
private static final long serialVersionUID = 2288990827132952813L;

private User user;
private String email;
private String name;
private String fullName;
private Set<String> groups;
private boolean guest;
private SecureString password;
private Set<MetadataValue> values;

public CreateUserRequest(User user, SecureString password, Set<MetadataValue> values) {
this.user = user;
public CreateUserRequest(String email, String name, String fullName, Set<String> groups, boolean guest,
SecureString password, Set<MetadataValue> values) {
this.email = email;
this.name = name;
this.fullName = fullName;
this.groups = groups;
this.guest = guest;
this.password = password;
this.values = values;
}

public CreateUserRequest() {
this.user = new User();
this.groups = new HashSet<>();
this.password = new SecureString();
this.values = new HashSet<>();
}

public User getUser() {
return user;
public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getFullName() {
return fullName;
}

public void setFullName(String fullName) {
this.fullName = fullName;
}

public Set<String> getGroups() {
return groups;
}

public void setGroups(Set<String> groups) {
this.groups = groups;
}

public boolean getGuest() {
return guest;
}

public void setGuest(boolean guest) {
this.guest = guest;
}

public Set<MetadataValue> getValues() {
Expand All @@ -47,10 +92,6 @@ public void setValues(Set<MetadataValue> values) {
this.values = values;
}

public void setUser(User user) {
this.user = user;
}

public SecureString getPassword() {
return password;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package org.roda.core.data.v2.user.requests;

import java.io.Serial;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import org.roda.core.data.common.SecureString;
import org.roda.core.data.v2.generics.MetadataValue;

import com.fasterxml.jackson.annotation.JsonInclude;

/**
* @author António Lindo <[email protected]>
*/
@JsonInclude(JsonInclude.Include.ALWAYS)
public class RegisterUserRequest implements Serializable {

@Serial
private static final long serialVersionUID = 2288990827132952813L;

private String email;
private String name;
private String fullName;
private SecureString password;
private Set<MetadataValue> values;

public RegisterUserRequest(String email, String name, String fullName, SecureString password,
Set<MetadataValue> values) {
this.email = email;
this.name = name;
this.fullName = fullName;
this.password = password;
this.values = values;
}

public RegisterUserRequest() {
this.password = new SecureString();
this.values = new HashSet<>();
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getFullName() {
return fullName;
}

public void setFullName(String fullName) {
this.fullName = fullName;
}

public Set<MetadataValue> getValues() {
return values;
}

public void setValues(Set<MetadataValue> values) {
this.values = values;
}

public SecureString getPassword() {
return password;
}

public void setPassword(SecureString password) {
this.password = password;
}
}
Loading

0 comments on commit e6d01ab

Please sign in to comment.