no message
parent
78b91ee3e0
commit
c25c9d72cf
@ -1,14 +1,19 @@
|
||||
import eu.eudat.data.entities.DataRepository;
|
||||
import eu.eudat.query.engine.builder.QueryBuilder;
|
||||
import eu.eudat.query.engine.builder.QueryBuilderImpl;
|
||||
import eu.eudat.query.engine.predicates.ComparisonPredicate;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 7/5/2018.
|
||||
*/
|
||||
public class Main {
|
||||
public static void main(String[] args){
|
||||
new Main().Test();
|
||||
}
|
||||
public void Test(){
|
||||
QueryBuilder<DataRepository> queryBuilder = new QueryBuilderImpl<>();
|
||||
queryBuilder.where((entity, comparisonExpression) -> comparisonExpression.field("id").greaterThan(5));
|
||||
//queryBuilder.and(((entity, expression) -> expression.field("id").greaterThan(4)),((entity, expression) -> expression.field("id").greaterThan(5)));
|
||||
QueryBuilder<DataRepository> queryBuilder = new QueryBuilderImpl<>(DataRepository.class);
|
||||
queryBuilder.<ComparisonPredicate>where((comparisonExpression) -> comparisonExpression.field("id").greaterThan(5) );
|
||||
queryBuilder.<ComparisonPredicate>where((comparisonExpression) -> comparisonExpression.field("label").equal("mitsos") );
|
||||
queryBuilder.toList();
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
package eu.eudat.query.engine.builder;
|
||||
|
||||
import eu.eudat.query.engine.expressions.Expression;
|
||||
import eu.eudat.query.engine.predicates.AndPredicate;
|
||||
import eu.eudat.query.engine.predicates.ComparisonPredicate;
|
||||
import eu.eudat.query.engine.predicates.Predicate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 7/5/2018.
|
||||
*/
|
||||
public interface QueryBuilder<T> {
|
||||
|
||||
Expression where(ComparisonPredicate<T> wherePredicate);
|
||||
|
||||
Expression and(AndPredicate<T> andPredicate);
|
||||
<P extends Predicate> Expression where(P wherePredicate);
|
||||
|
||||
List<T> toList();
|
||||
}
|
||||
|
@ -1,22 +1,50 @@
|
||||
package eu.eudat.query.engine.builder;
|
||||
|
||||
import eu.eudat.query.engine.expressions.ComparisonExpression;
|
||||
import eu.eudat.query.engine.expressions.Expression;
|
||||
import eu.eudat.query.engine.predicates.AndPredicate;
|
||||
import eu.eudat.query.engine.predicates.ComparisonPredicate;
|
||||
import eu.eudat.query.engine.predicates.Predicate;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 7/5/2018.
|
||||
*/
|
||||
public class QueryBuilderImpl<T> implements QueryBuilder<T> {
|
||||
|
||||
private List<Expression> expressions = new LinkedList<>();
|
||||
private Class<T> tClass;
|
||||
|
||||
public QueryBuilderImpl(Class<T> tClass) {
|
||||
this.tClass = tClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression where(ComparisonPredicate wherePredicate) {
|
||||
return null;
|
||||
public <P extends Predicate> Expression where(P wherePredicate) {
|
||||
ComparisonExpression comparisonExpression = new ComparisonExpression();
|
||||
Expression expression = wherePredicate.apply(comparisonExpression);
|
||||
this.expressions.add(expression);
|
||||
return expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression and(AndPredicate<T> andPredicate) {
|
||||
public List<T> toList() {
|
||||
String query = "Select * from ";
|
||||
Optional<Annotation> optionalAnnotation = Arrays.stream(this.tClass.getAnnotations())
|
||||
.filter(x-> x.annotationType().equals(javax.persistence.Table.class))
|
||||
.findFirst();
|
||||
|
||||
javax.persistence.Table annotation = optionalAnnotation.isPresent() ? (javax.persistence.Table)optionalAnnotation.get() : null;
|
||||
query += annotation.name()+" ";
|
||||
for (Expression expression : expressions) {
|
||||
if(expressions.indexOf(expression) > 0) query+= " and ";
|
||||
else query += " where ";
|
||||
query += expression.evaluate();
|
||||
}
|
||||
System.out.println(query);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
package eu.eudat.query.engine.predicates;
|
||||
|
||||
import eu.eudat.query.engine.expressions.ComparisonExpression;
|
||||
import eu.eudat.query.engine.expressions.Expression;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 7/5/2018.
|
||||
*/
|
||||
public interface AndPredicate<T> {
|
||||
<E extends Expression> Expression and(ComparisonPredicate<T>... predicates);
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
package eu.eudat.query.engine.predicates;
|
||||
|
||||
import eu.eudat.query.engine.expressions.ComparisonExpression;
|
||||
import eu.eudat.query.engine.expressions.Expression;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 7/5/2018.
|
||||
*/
|
||||
public interface ComparisonPredicate<T> extends Predicate<T, ComparisonExpression> {
|
||||
public interface ComparisonPredicate extends Predicate<ComparisonExpression> {
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package eu.eudat.query.engine.predicates;
|
||||
|
||||
import eu.eudat.query.engine.expressions.ComparisonExpression;
|
||||
import eu.eudat.query.engine.expressions.Expression;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 7/5/2018.
|
||||
*/
|
||||
public interface Predicate<T,E extends Expression> {
|
||||
Expression where(T entity, E expression);
|
||||
|
||||
public interface Predicate<E extends Expression> {
|
||||
Expression apply( E expression);
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
package eu.eudat.models.data.urls;
|
||||
|
||||
import eu.eudat.data.entities.Dataset;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 7/23/2018.
|
||||
*/
|
||||
public class DatasetUrlListing extends UrlListing<Dataset, DatasetUrlListing> {
|
||||
@Override
|
||||
public DatasetUrlListing fromDataModel(Dataset entity) {
|
||||
this.setLabel(entity.getLabel());
|
||||
this.setUrl(entity.getId().toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dataset toDataModel() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHint() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,35 +1,35 @@
|
||||
<div class="main-panel" id="main-panel">
|
||||
<div class="container">
|
||||
<div class="row" style="margin-top: 30px">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 col-md-offset-1">
|
||||
<h3 *ngIf="!this.isAuthenticated()">{{ 'HOMEPAGE.OPEN-DMPS.STATS' | translate }}</h3>
|
||||
<h3 *ngIf="this.isAuthenticated()">{{ 'HOMEPAGE.MY-DMPS.STATS' | translate }}</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="margin-top: 30px">
|
||||
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12 col-md-offset-1">
|
||||
<app-figurecard title={{dashboardStatisticsData.totalProjectCount}} headerIcon="list" [category]="this.isAuthenticated() ? 'My Projects' : 'Projects'"
|
||||
[hasFootContent]="this.isAuthenticated()" [footContent]="this.isAuthenticated() ? 'Open My Projects' : 'Open Projects'"
|
||||
routelLink='/projects' footerIcon="open_in_new" linearColor="linear-gradient(60deg, #ffa726, #fb8c00)" boxShadow="0 4px 20px 0 rgba(0, 0, 0, 0.14), 0 7px 10px -5px rgba(255, 152, 0, 0.4)">
|
||||
</app-figurecard>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
|
||||
<app-figurecard title={{dashboardStatisticsData.totalDataManagementPlanCount}} headerIcon="mode_edit" [category]="this.isAuthenticated() ? 'My DMPs' : 'DMPs'"
|
||||
[hasFootContent]="this.isAuthenticated()" [footContent]="this.isAuthenticated() ? 'Open My DMPs' : 'Open DMPs'"
|
||||
routelLink='/dmps' footerIcon="open_in_new" linearColor="linear-gradient(60deg, #ef5350, #e53935)" boxShadow="0 4px 20px 0px rgba(0, 0, 0, 0.14), 0 7px 10px -5px rgba(244, 67, 54, 0.4)">
|
||||
</app-figurecard>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
|
||||
<app-figurecard title={{dashboardStatisticsData.totalDataSetCount}} headerIcon="subject" [category]="this.isAuthenticated() ? 'My Datasets' : 'Datasets'"
|
||||
[hasFootContent]="this.isAuthenticated()" [footContent]="this.isAuthenticated() ? 'Open My Datasets' : 'Open Datasets'"
|
||||
routelLink='/datasets' footerIcon="open_in_new" linearColor="linear-gradient(60deg, #26c6da, #00acc1)" boxShadow="0 4px 20px 0px rgba(0, 0, 0, 0.14), 0 7px 10px -5px rgba(0, 188, 212, 0.4)">
|
||||
</app-figurecard>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="this.isAuthenticated()" class="row" style="margin-top: 30px">
|
||||
<div class="col-lg-9 col-md-12 col-sm-12 col-xs-12 col-md-offset-1">
|
||||
<app-recent-activity></app-recent-activity>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="row" style="margin-top: 30px">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 col-md-offset-1">
|
||||
<h3 *ngIf="!this.isAuthenticated()">{{ 'HOMEPAGE.OPEN-DMPS.STATS' | translate }}</h3>
|
||||
<h3 *ngIf="this.isAuthenticated()">{{ 'HOMEPAGE.MY-DMPS.STATS' | translate }}</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="margin-top: 30px">
|
||||
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12 col-md-offset-1">
|
||||
<app-figurecard title={{dashboardStatisticsData.totalProjectCount}} headerIcon="list" [category]="this.isAuthenticated() ? 'My Projects' : 'Projects'"
|
||||
[hasFootContent]="this.isAuthenticated()" [footContent]="this.isAuthenticated() ? 'Open My Projects' : 'Open Projects'"
|
||||
routelLink='/projects' footerIcon="open_in_new" linearColor="linear-gradient(60deg, #ffa726, #fb8c00)" boxShadow="0 4px 20px 0 rgba(0, 0, 0, 0.14), 0 7px 10px -5px rgba(255, 152, 0, 0.4)">
|
||||
</app-figurecard>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
|
||||
<app-figurecard title={{dashboardStatisticsData.totalDataManagementPlanCount}} headerIcon="mode_edit" [category]="this.isAuthenticated() ? 'My DMPs' : 'DMPs'"
|
||||
[hasFootContent]="this.isAuthenticated()" [footContent]="this.isAuthenticated() ? 'Open My DMPs' : 'Open DMPs'" routelLink='/dmps'
|
||||
footerIcon="open_in_new" linearColor="linear-gradient(60deg, #ef5350, #e53935)" boxShadow="0 4px 20px 0px rgba(0, 0, 0, 0.14), 0 7px 10px -5px rgba(244, 67, 54, 0.4)">
|
||||
</app-figurecard>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
|
||||
<app-figurecard title={{dashboardStatisticsData.totalDataSetCount}} headerIcon="subject" [category]="this.isAuthenticated() ? 'My Datasets' : 'Datasets'"
|
||||
[hasFootContent]="this.isAuthenticated()" [footContent]="this.isAuthenticated() ? 'Open My Datasets' : 'Open Datasets'"
|
||||
routelLink='/datasets' footerIcon="open_in_new" linearColor="linear-gradient(60deg, #26c6da, #00acc1)" boxShadow="0 4px 20px 0px rgba(0, 0, 0, 0.14), 0 7px 10px -5px rgba(0, 188, 212, 0.4)">
|
||||
</app-figurecard>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="this.isAuthenticated()" class="row" style="margin-top: 30px">
|
||||
<div class="col-lg-9 col-md-12 col-sm-12 col-xs-12 col-md-offset-1">
|
||||
<app-recent-activity></app-recent-activity>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,68 +1,68 @@
|
||||
<div class="container row">
|
||||
<div class="col-md-3">
|
||||
<mat-card class="example-card">
|
||||
<mat-card-header>
|
||||
<mat-card-title>
|
||||
{{'RECENT-ACTIVITY.MY-TITLE-PROJECT' | translate}}
|
||||
</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<mat-nav-list *ngIf="projectActivities!=null">
|
||||
<mat-list-item (click)="redirect(activity.id,RecentActivityTypes.PROJECT)" *ngFor="let activity of projectActivities">
|
||||
<p mat-line>
|
||||
{{activity.label}}
|
||||
</p>
|
||||
<p mat-line>
|
||||
{{activity.timestamp | date:'shortDate'}}
|
||||
</p>
|
||||
</mat-list-item>
|
||||
</mat-nav-list>
|
||||
</mat-card-content>
|
||||
<div class="col-md-3">
|
||||
<mat-card class="example-card">
|
||||
<mat-card-header>
|
||||
<mat-card-title>
|
||||
{{'RECENT-ACTIVITY.MY-TITLE-PROJECT' | translate}}
|
||||
</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<mat-nav-list *ngIf="projectActivities!=null">
|
||||
<mat-list-item (click)="redirect(activity.id,RecentActivityTypes.PROJECT)" *ngFor="let activity of projectActivities">
|
||||
<p mat-line>
|
||||
{{activity.label}}
|
||||
</p>
|
||||
<p mat-line>
|
||||
{{activity.timestamp | date:'shortDate'}}
|
||||
</p>
|
||||
</mat-list-item>
|
||||
</mat-nav-list>
|
||||
</mat-card-content>
|
||||
|
||||
</mat-card>
|
||||
</mat-card>
|
||||
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<mat-card class="example-card">
|
||||
<mat-card-header>
|
||||
<mat-card-title>
|
||||
{{'RECENT-ACTIVITY.MY-TITLE-DMP' | translate}}
|
||||
</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<mat-nav-list *ngIf="dmpActivities!=null">
|
||||
<mat-list-item (click)="redirect(activity.id,RecentActivityTypes.DMP)" *ngFor="let activity of dmpActivities">
|
||||
<p mat-line>
|
||||
{{activity.label}}
|
||||
</p>
|
||||
<p mat-line>
|
||||
{{activity.timestamp | date:'shortDate'}}
|
||||
</p>
|
||||
</mat-list-item>
|
||||
</mat-nav-list>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<mat-card class="example-card">
|
||||
<mat-card-header>
|
||||
<mat-card-title>
|
||||
{{'RECENT-ACTIVITY.MY-TITLE-DATASET' | translate}}
|
||||
</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<mat-nav-list *ngIf="datasetActivities!=null">
|
||||
<mat-list-item (click)="redirect(activity.id,RecentActivityTypes.DATASET)" *ngFor="let activity of datasetActivities">
|
||||
<p mat-line>
|
||||
{{activity.label}}
|
||||
</p>
|
||||
<p mat-line>
|
||||
{{activity.timestamp | date:'shortDate'}}
|
||||
</p>
|
||||
</mat-list-item>
|
||||
</mat-nav-list>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<mat-card class="example-card">
|
||||
<mat-card-header>
|
||||
<mat-card-title>
|
||||
{{'RECENT-ACTIVITY.MY-TITLE-DMP' | translate}}
|
||||
</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<mat-nav-list *ngIf="dmpActivities!=null">
|
||||
<mat-list-item (click)="redirect(activity.id,RecentActivityTypes.DMP)" *ngFor="let activity of dmpActivities">
|
||||
<p mat-line>
|
||||
{{activity.label}}
|
||||
</p>
|
||||
<p mat-line>
|
||||
{{activity.timestamp | date:'shortDate'}}
|
||||
</p>
|
||||
</mat-list-item>
|
||||
</mat-nav-list>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<mat-card class="example-card">
|
||||
<mat-card-header>
|
||||
<mat-card-title>
|
||||
{{'RECENT-ACTIVITY.MY-TITLE-DATASET' | translate}}
|
||||
</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<mat-nav-list *ngIf="datasetActivities!=null">
|
||||
<mat-list-item (click)="redirect(activity.id,RecentActivityTypes.DATASET)" *ngFor="let activity of datasetActivities">
|
||||
<p mat-line>
|
||||
{{activity.label}}
|
||||
</p>
|
||||
<p mat-line>
|
||||
{{activity.timestamp | date:'shortDate'}}
|
||||
</p>
|
||||
</mat-list-item>
|
||||
</mat-nav-list>
|
||||
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue