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

Skip to content
Snippets Groups Projects
Commit b75f73a1 authored by Lukas Kaltenbrunner's avatar Lukas Kaltenbrunner
Browse files

Port to new filehook implementation

parent cbea6560
Branches
No related merge requests found
......@@ -15,19 +15,16 @@ public class DocumentInfo {
@Field(type = Text)
private String content;
//private Meta meta;
private FileInfo file;
private PathInfo path;
private ProjectInfo project;
public DocumentInfo() {
}
@Override
public String toString() {
//return "Document{" + "content='" + content + "'," + meta.toString() + ", " + file.toString() + ", " + path.toString() + '}';
return "Document{" + "content='" + content + "'}";
return "Document{" + "content='" + content + ", " + file.toString() + ", " + project.toString() + '}';
}
public String getId() {
......@@ -54,11 +51,11 @@ public class DocumentInfo {
this.file = file;
}
public PathInfo getPath() {
return path;
public ProjectInfo getProject() {
return project;
}
public void setPath(PathInfo path) {
this.path = path;
public void setProject(ProjectInfo project) {
this.project = project;
}
}
package at.ac.uibk.gitsearch.es.model;
import java.time.Instant;
import java.time.LocalDateTime;
public class FileInfo {
String extension;
String content_type;
Instant created;
Instant last_modified;
Instant last_accessed;
Instant indexing_date;
long filesize;
String filename;
String url;
String file_format;
private String filename;
private String extension;
private String path;
private String file_format;
private LocalDateTime indexing_date;
private String commit_id;
public String getExtension() {
return extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
public String getContent_type() {
return content_type;
public String getFilename() {
return filename;
}
public void setContent_type(String content_type) {
this.content_type = content_type;
public void setFilename(String filename) {
this.filename = filename;
}
public Instant getCreated() {
return created;
public String getExtension() {
return extension;
}
public void setCreated(Instant created) {
this.created = created;
public void setExtension(String extension) {
this.extension = extension;
}
public Instant getLast_modified() {
return last_modified;
public String getPath() {
return path;
}
public void setLast_modified(Instant last_modified) {
this.last_modified = last_modified;
public void setPath(String path) {
this.path = path;
}
public Instant getLast_accessed() {
return last_accessed;
public String getFile_format() {
return file_format;
}
public void setLast_accessed(Instant last_accessed) {
this.last_accessed = last_accessed;
public void setFile_format(String file_format) {
this.file_format = file_format;
}
public Instant getIndexing_date() {
public LocalDateTime getIndexing_date() {
return indexing_date;
}
public void setIndexing_date(Instant indexing_date) {
public void setIndexing_date(LocalDateTime indexing_date) {
this.indexing_date = indexing_date;
}
public long getFilesize() {
return filesize;
public String getCommit_id() {
return commit_id;
}
public void setFilesize(long filesize) {
this.filesize = filesize;
}
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getFile_format() {
return file_format;
}
public void setFile_format(String file_format) {
this.file_format = file_format;
public void setCommit_id(String commit_id) {
this.commit_id = commit_id;
}
}
package at.ac.uibk.gitsearch.es.model;
public class MetaData {
}
package at.ac.uibk.gitsearch.es.model;
public class PathInfo {
String root;
String virtual;
String real;
String repository;
String group;
String main_group;
String sub_group;
String url;
public class ProjectInfo {
private long project_id;
private String project_name;
private String url;
private String namespace;
private String main_group;
private String sub_group;
public String getRoot() {
return root;
public long getProject_id() {
return project_id;
}
public void setRoot(String root) {
this.root = root;
public void setProject_id(long project_id) {
this.project_id = project_id;
}
public String getVirtual() {
return virtual;
public String getProject_name() {
return project_name;
}
public void setVirtual(String virtual) {
this.virtual = virtual;
public void setProject_name(String project_name) {
this.project_name = project_name;
}
public String getReal() {
return real;
}
public void setReal(String real) {
this.real = real;
}
public String getRepository() {
return repository;
public String getUrl() {
return url;
}
public void setRepository(String repository) {
this.repository = repository;
public void setUrl(String url) {
this.url = url;
}
public String getGroup() {
return group;
public String getNamespace() {
return namespace;
}
public void setGroup(String group) {
this.group = group;
public void setNamespace(String namespace) {
this.namespace = namespace;
}
public String getMain_group() {
......@@ -65,12 +55,4 @@ public class PathInfo {
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;
}
}
......@@ -2,12 +2,12 @@ package at.ac.uibk.gitsearch.repository.search;
public final class GitFilesRepositoryConstants {
public static final String SUB_GROUP_AGG = "by_path.sub_group";
public static final String SUB_GROUP_FIELD = "path.sub_group.keyword";
public static final String SUB_GROUP_AGG = "by_project.sub_group";
public static final String SUB_GROUP_FIELD = "project.sub_group";
public static final String FILE_EXTENSION_AGG = "by_file.file_format";
public static final String FILE_EXTENSION_FIELD = "file.file_format.keyword";
public static final String REPOSITORY_AGG = "by_path.repository";
public static final String REPOSITORY_FIELD = "path.repository.keyword";
public static final String FILE_EXTENSION_FIELD = "file.file_format";
public static final String REPOSITORY_AGG = "by_project.project_name";
public static final String REPOSITORY_FIELD = "project.project_name";
public static final String CONTENT_FIELD = "content";
public static final String INDEX = "codeability.sharing";
public static final String INDEX_FULL_TEXT = "fulltext";
}
......@@ -42,7 +42,7 @@ public class GitFilesRepositoryImpl implements GitFilesRepository {
@Override
public GitFilesPageDetailsDTO pageDetails(String query, int pageSize, int page, List<String> selectedRepository,
List<String> selectedUniversity, List<String> selectedFileFormat) throws IOException {
SearchRequest searchRequest = new SearchRequest(GitFilesRepositoryConstants.INDEX);
SearchRequest searchRequest = new SearchRequest(GitFilesRepositoryConstants.INDEX_FULL_TEXT);
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery()
.must(QueryBuilders.queryStringQuery(query).defaultField(GitFilesRepositoryConstants.CONTENT_FIELD));
......@@ -97,7 +97,7 @@ public class GitFilesRepositoryImpl implements GitFilesRepository {
@Override
public GitFilesAggregationDTO aggregation(String query) throws IOException {
SearchRequest searchRequest = new SearchRequest(GitFilesRepositoryConstants.INDEX);
SearchRequest searchRequest = new SearchRequest(GitFilesRepositoryConstants.INDEX_FULL_TEXT);
BoolQueryBuilder matchQueryBuilder = QueryBuilders.boolQuery()
.must(QueryBuilders.queryStringQuery(query).defaultField(GitFilesRepositoryConstants.CONTENT_FIELD));
......
......@@ -29,15 +29,13 @@ public class GitFilesDTO {
this.fragment = new FragmentDTO().matchFillLine(documentInfo.getContent(), fragment, properties.getSearch());
this.fileFormat = documentInfo.getFile().getFile_format();
this.repository = documentInfo.getPath().getRepository();
this.url = documentInfo.getPath().getUrl();
this.subGroup = documentInfo.getPath().getSub_group();
this.repository = documentInfo.getProject().getProject_name();
this.url = documentInfo.getProject().getUrl();
this.subGroup = documentInfo.getProject().getSub_group();
this.fileExtension = documentInfo.getFile().getExtension();
this.fileName = documentInfo.getFile().getFilename();
final String virtualPath = documentInfo.getPath().getVirtual().replaceAll(" ", "-").toLowerCase();
int pathIdx = virtualPath.indexOf(repository) + repository.length() + 1;
this.filePath = virtualPath.substring(pathIdx);
this.gitUrl = url.substring(0, url.length() - 4) + "/-/blob/master/" + filePath;
this.filePath = documentInfo.getProject().getNamespace() + "/" + documentInfo.getFile().getFilename();
this.gitUrl = documentInfo.getProject().getUrl() + "/-/blob/master/" + documentInfo.getFile().getCommit_id() + "/" + filePath; // todo: use commit id
}
public String getContent() {
......
import {Moment} from "moment";
export interface IFileInfo {
extension: string;
content_type: string;
created: Moment;
last_modified: Moment;
last_accessed: Moment;
indexing_date: Moment;
filesize: bigint;
filename: string;
url: string;
path: string;
file_format: string;
indexing_date: Date;
commit_id: string;
}
export class FileInfo implements IFileInfo {
public constructor(public content_type: string,
public created: Moment,
public extension: string,
public constructor(public extension: string,
public filename: string,
public filesize: bigint,
public indexing_date: Moment,
public last_accessed: Moment,
public last_modified: Moment,
public url: string,
public file_format: string) {
public path: string,
public file_format: string,
public indexing_date: Date,
public commit_id: string,) {
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment