This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Commit cdb5bb7e authored by Michael Breu's avatar Michael Breu 💬
Browse files

Update to V0.1.0-Snapshot

parent 629b6af3
......@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.codeability.sharing</groupId>
<artifactId>SharingPluginPlatformAPI</artifactId>
<version>0.0.2</version>
<version>0.1.0-Snapshot</version>
<name>SharingPluginPlatformAPI</name>
<description>CodeAbility Sharing Plugin Platform API</description>
<packaging>jar</packaging>
......@@ -32,6 +32,14 @@
<properties-maven-plugin.version>1.0.0</properties-maven-plugin.version>
<sonar-maven-plugin.version>3.7.0.1746</sonar-maven-plugin.version>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.module/jackson-module-jaxb-annotations -->
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
<version>2.10.4</version>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>target</id>
......
......@@ -5,4 +5,5 @@
*/
module sharingPluginPlatform {
exports org.codeability.sharing.plugins.api;
requires com.fasterxml.jackson.annotation;
}
\ No newline at end of file
package org.codeability.sharing.plugins.api;
import java.util.List;
import org.codeability.sharing.plugins.api.UserProvidedMetadataDTO.ExerciseType;
public class SearchInputMetadataDTO {
private String programmingLanguage;
private String keyword;
private String naturalLanguage;
private String license;
private String author;
private List<UserProvidedMetadataDTO.ExerciseType> types;
public SearchInputMetadataDTO() {
}
public SearchInputMetadataDTO(String programmingLanguage,
String keyword,
String naturalLanguage,
String license,
String author) {
this.programmingLanguage = mapEmptyString(programmingLanguage);
this.keyword = mapEmptyString(keyword);
this.naturalLanguage = mapEmptyString(naturalLanguage);
this.license = mapEmptyString(license);
this.author = mapEmptyString(author);
}
private static String mapEmptyString(String str) {
return "".equals(str) ? null : str;
}
public boolean hasMetadataInput() {
return !(programmingLanguage == null
&& keyword == null
&& author == null
&& license == null);
}
public String getProgrammingLanguage() {
return programmingLanguage;
}
public void setProgrammingLanguage(String programmingLanguage) {
this.programmingLanguage = mapEmptyString(programmingLanguage);
}
public String getKeyword() {
return keyword;
}
public void setKeyword(String keyword) {
this.keyword = mapEmptyString(keyword);
}
public String getNaturalLanguage() {
return naturalLanguage;
}
public void setNaturalLanguage(String naturalLanguage) {
this.naturalLanguage = mapEmptyString(naturalLanguage);
}
public String getLicense() {
return license;
}
public void setLicense(String license) {
this.license = mapEmptyString(license);
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = mapEmptyString(author);
}
/**
* @return the types
*/
public List<ExerciseType> getTypes() {
return types;
}
/**
* @param types the types to set
*/
public void setTypes(List<ExerciseType> types) {
this.types = types;
}
@Override
public String toString() {
return "programmingLanguage: " + this.programmingLanguage
+ ", keyword: " + this.keyword
+ ", naturalLanguage: " + this.naturalLanguage
+ ", license: " + this.license
+ ", author: " + this.author;
}
}
package org.codeability.sharing.plugins.api;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
public class SearchResultDTO {
public static class PluginActionInfo {
String plugin;
String action;
String commandName;
public PluginActionInfo(String plugin, String action, String commandName) {
super();
this.plugin = plugin;
this.action = action;
this.commandName = commandName;
}
public PluginActionInfo() {
// JSON
}
/**
* @return the plugin
*/
public String getPlugin() {
return plugin;
}
/**
* @param plugin the plugin to set
*/
public void setPlugin(String plugin) {
this.plugin = plugin;
}
/**
* @return the action
*/
public String getAction() {
return action;
}
/**
* @param action the action to set
*/
public void setAction(String action) {
this.action = action;
}
/**
* @return the commandName
*/
public String getCommandName() {
return commandName;
}
/**
* @param commandName the commandName to set
*/
public void setCommandName(String commandName) {
this.commandName = commandName;
}
}
private GitProject project;
private MetadataFile file;
private UserProvidedMetadataDTO metadata;
private String exerciseId;
private int ranking5;
private List<PluginActionInfo> supportedActions = new ArrayList<>(2);
public SearchResultDTO() {
// default constructor
}
/**
* clone constructor
*
* @param toClone
*/
public SearchResultDTO(SearchResultDTO toClone) {
super();
this.project = toClone.project;
this.file = toClone.file;
this.metadata = toClone.metadata;
}
public GitProject getProject() {
return project;
}
public void setProject(GitProject project) {
this.project = project;
}
public MetadataFile getFile() {
return file;
}
public void setFile(MetadataFile file) {
this.file = file;
}
public UserProvidedMetadataDTO getMetadata() {
return metadata;
}
public void setMetadata(UserProvidedMetadataDTO metadata) {
this.metadata = metadata;
}
@Override
public String toString() {
return "SearchResultDTO : { project: " + this.project
+ ", file: " + this.file
+ ", metadata: " + this.metadata
+ " }";
}
@Override
public final int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((exerciseId == null) ? 0 : exerciseId.hashCode());
result = prime * result + ((file == null) ? 0 : file.hashCode());
result = prime * result + ((metadata == null) ? 0 : metadata.hashCode());
result = prime * result + ((project == null) ? 0 : project.hashCode());
return result;
}
@Override
public final boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof SearchResultDTO))
return false;
SearchResultDTO other = (SearchResultDTO) obj;
if (exerciseId == null) {
if (other.exerciseId != null)
return false;
} else if (!exerciseId.equals(other.exerciseId))
return false;
if (file == null) {
if (other.file != null)
return false;
} else if (!file.equals(other.file))
return false;
if (metadata == null) {
if (other.metadata != null)
return false;
} else if (!metadata.equals(other.metadata))
return false;
if (project == null) {
if (other.project != null)
return false;
} else if (!project.equals(other.project))
return false;
return true;
}
public static class GitProject {
private int project_id;
private String project_name;
private String namespace;
private String main_group;
private String sub_group;
private String url;
private Date last_activity_at;
public int getProject_id() {
return project_id;
}
public Date getLast_activity_at() {
return last_activity_at;
}
public void setLast_activity_at(Date last_activity_at) {
this.last_activity_at = last_activity_at;
}
public void setProject_id(int project_id) {
this.project_id = project_id;
}
public String getProject_name() {
return project_name;
}
public void setProject_name(String project_name) {
this.project_name = project_name;
}
public String getNamespace() {
return namespace;
}
public void setNamespace(String namespace) {
this.namespace = namespace;
}
public String getMain_group() {
return main_group;
}
public void setMain_group(String main_group) {
this.main_group = main_group;
}
public String getSub_group() {
return sub_group;
}
public void setSub_group(String sub_group) {
this.sub_group = sub_group;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public int getProjectId() {
return project_id;
}
public void setProjectId(int project_id) {
this.project_id = project_id;
}
@Override
public final int hashCode() {
return Integer.hashCode(project_id);
}
@Override
public final boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof GitProject)) {
return false;
}
GitProject other = (GitProject) obj;
return this.project_id == other.project_id;
}
@Override
public String toString() {
return "Project: { project_id: " + project_id
+ ", project_name: " + project_name
+ ", namespace: " + namespace
+ ", main_group: " + main_group
+ ", sub_group: " + sub_group
+ ", url: " + url
+ " }";
}
}
/**
* @return the exerciseId
*/
public String getExerciseId() {
return exerciseId;
}
/**
* @param exerciseId the exerciseId to set
*/
public void setExerciseId(String exerciseId) {
this.exerciseId = exerciseId;
}
/**
* @return the ranking5
*/
public int getRanking5() {
return ranking5;
}
/**
* @param ranking5 the ranking5 to set
*/
public void setRanking5(int ranking5) {
this.ranking5 = ranking5;
}
/**
* @return the supportedActions
*/
public List<PluginActionInfo> getSupportedActions() {
return supportedActions;
}
/**
* @param supportedActions the supportedActions to set
*/
public void setSupportedActions(List<PluginActionInfo> supportedActions) {
this.supportedActions = supportedActions;
}
public static class MetadataFile {
private String filename;
private String path;
private String commit_id;
private Date indexing_date;
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getCommit_id() {
return commit_id;
}
public void setCommit_id(String commit_id) {
this.commit_id = commit_id;
}
public Date getIndexing_date() {
return indexing_date;
}
public void setIndexing_date(Date indexing_date) {
this.indexing_date = indexing_date;
}
@Override
public final int hashCode() {
final int prime = 31;
int result = this.path.hashCode();
result = prime * result + this.commit_id.hashCode();
return result;
}
@Override
public final boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof MetadataFile)) {
return false;
}
MetadataFile other = (MetadataFile) obj;
return Objects.equals(this.path, other.path)
&& Objects.equals(this.commit_id, other.commit_id);
}
@Override
public String toString() {
return "MetadataFile: { filename: " + this.filename
+ ", path: " + this.path
+ ", commit_id: " + this.commit_id
+ ", indexing_date: " + this.indexing_date
+ " }";
}
}
}
package org.codeability.sharing.plugins.api;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonValue;
public class SearchResultsDTO {
public enum GitProjectVisibility {
PRIVATE("private"), PUBLIC("public"), INTERNAL("internal");
private final String externalName;
private GitProjectVisibility(String externalName) {
this.externalName = externalName;
}
@JsonValue
public String getExternalName() {
return externalName;
}
}
private List<SearchResultDTO> searchResult;
/**
*
* @return the list of search results on this page, starting with pageStartIndex
*/
public List<SearchResultDTO> getSearchResult() {
return searchResult;
}
public void setSearchResult(List<SearchResultDTO> searchResult) {
this.searchResult = searchResult;
}
long hitCount;
long pageStartIndex;
public long getPageStartIndex() {
return pageStartIndex;
}
public SearchResultsDTO(List<SearchResultDTO> searchResult, long hitCount, long pageStartIndex) {
this.searchResult = searchResult;
this.hitCount = hitCount;
this.pageStartIndex = pageStartIndex;
}
public SearchResultsDTO() {
}
/**
* returns the number of all hits.
*
* @return
*/
public long getHitCount() {
return hitCount;
}
public void setHitCount(long hitCount) {
this.hitCount = hitCount;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("SearchResultsDTO:");
sb.append(System.lineSeparator());
sb.append("hit count: ");
sb.append(this.hitCount);
sb.append(System.