Commit 0562ac3a by Tuukka Kivilahti

commit before mergin onja's changes

1 parent 4f6f5ef2
package-lock=false
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
"zone.js": "^0.8.26" "zone.js": "^0.8.26"
}, },
"devDependencies": { "devDependencies": {
"@angular-devkit/build-angular": "~0.7.0", "@angular-devkit/build-angular": "~0.7.2",
"@angular/cdk": "^6.4.2", "@angular/cdk": "^6.4.2",
"@angular/cli": "6.1.2", "@angular/cli": "6.1.2",
"@angular/compiler-cli": "6.1.1", "@angular/compiler-cli": "6.1.1",
......
/** /**
* Created by tuukka on 04/02/17. * Created by tuukka on 04/02/17.
*/ */
import gql from "graphql-tag";
export class VipProductDelivery { export class VipProductDelivery {
/* static fragments = gql`
public Integer id; fragment vipProductDeliveryPrimitives on VipProductDelivery {
public Integer delivererId; deliverytime
public BigDecimal quantity; id
public Date deliveryTime; notes
public String notes; quantity
*/ }
`;
id: number; id: number;
delivererId: number; delivererId: number;
......
import {VipProductDelivery} from './vip-product-delivery.model'; import {VipProductDelivery} from './vip-product-delivery.model';
import gql from "graphql-tag";
/** /**
* Created by tuukka on 04/02/17. * Created by tuukka on 04/02/17.
*/ */
...@@ -7,17 +8,14 @@ import {VipProductDelivery} from './vip-product-delivery.model'; ...@@ -7,17 +8,14 @@ import {VipProductDelivery} from './vip-product-delivery.model';
export class VipProduct { export class VipProduct {
/* static fragments = gql`
fragment vipProductPrimitives on VipProduct {
public Integer id; id
public String name; name
public Integer productId; notes
public String notes; quantity
public BigDecimal quantity; }
public BigDecimal delivered; `;
public List<VipProductDeliveryPojo> deliveries = new ArrayList<>();
*/
id: number; id: number;
name: string; name: string;
......
import {VipProduct} from './vip-product.model'; import {VipProduct} from './vip-product.model';
import {User} from '../../../shared/models/user.model'; import {User} from '../../../shared/models/user.model';
import gql from "graphql-tag";
import {VipProductDelivery} from "./vip-product-delivery.model";
/** /**
* Created by tuukka on 04/02/17. * Created by tuukka on 04/02/17.
*/ */
...@@ -8,17 +10,14 @@ import {User} from '../../../shared/models/user.model'; ...@@ -8,17 +10,14 @@ import {User} from '../../../shared/models/user.model';
export class Vip { export class Vip {
/* static fragments = gql`
fragment vipPrimitives on Vip {
public Integer id; created
public String description; description
public String shortdescr; id
public Date created; shortdescr
public Integer eventuserId; }
public Integer creatorId; `;
public Integer hostId;
public List<VipProductPojo> products = new ArrayList<>();
*/
id: number; id: number;
description: string; description: string;
...@@ -35,3 +34,9 @@ export class Vip { ...@@ -35,3 +34,9 @@ export class Vip {
} }
} }
export const VipFragmentsCombined = gql`
${Vip.fragments}
${VipProduct.fragments}
${VipProductDelivery.fragments}
`;
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {Vip} from './models/vip.model'; import {Vip, VipFragmentsCombined} from './models/vip.model';
import {User} from '../../shared/models/user.model'; import {User} from '../../shared/models/user.model';
import {UserService} from '../../shared/services/user.service'; import {UserService} from '../../shared/services/user.service';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
...@@ -9,11 +9,46 @@ import 'rxjs/add/observable/forkJoin'; ...@@ -9,11 +9,46 @@ import 'rxjs/add/observable/forkJoin';
import 'rxjs/add/operator/first'; import 'rxjs/add/operator/first';
import {HttpClient} from '@angular/common/http'; import {HttpClient} from '@angular/common/http';
import {MOYA_REST_URL} from "../../shared/config/moya.config"; import {MOYA_REST_URL} from "../../shared/config/moya.config";
import gql from 'graphql-tag';
import {EventUser} from "../../shared/models/event-user.model";
import {Apollo} from "apollo-angular";
import "rxjs-compat/add/operator/map";
export const Q_VIPS_N_DATA = gql`
query Vips() {
vips {
...vipPrimitives
products {
...vipProductPrimitives
deliveries {
...vipProductDeliveryPrimitives
}
}
creator {
...eventUserPrimitives
user {
...userPrimitives
}
}
}
}
${VipFragmentsCombined}
${EventUser.fragments}
${User.fragments}
`;
@Injectable() @Injectable()
export class ViplistService { export class ViplistService {
constructor(private http: HttpClient, private userService: UserService) {
constructor(private apollo: Apollo, private http: HttpClient, private userService: UserService) {
} }
...@@ -22,15 +57,19 @@ export class ViplistService { ...@@ -22,15 +57,19 @@ export class ViplistService {
* get vips * get vips
* @param searchString: searchString, skip to return all vips * @param searchString: searchString, skip to return all vips
*/ */
public get(searchString?: string): Observable<Array<Vip>> { public get(): Observable<Array<Vip>> {
return this.apollo.watchQuery<Array<Vip>>({query: Q_VIPS_N_DATA}).valueChanges.map(x => x.data);
//Vip .map(x => x as Vip);
if (!searchString) { if (!searchString) {
return this.http.get(MOYA_REST_URL + 'v3/vip/all') return this.http.get(MOYA_REST_URL + 'v3/vip/all')
.switchMap(res => Observable.forkJoin(...(res as Array<any>).map(apiRow => this.hostPopulator(apiRow)))); .switchMap(res => Observable.forkJoin(...(res as Array<any>).map(apiRow => this.hostPopulator(apiRow))));
} }
return this.http.get(MOYA_REST_URL + 'v3/vip/search/' + searchString)
.switchMap(v => Observable.forkJoin(...(v as Array<any>).map(x => this.hostPopulator(x))));
} }
......
import {User} from "./user.model";
import gql from "graphql-tag";
export enum UserGender {
MALE,
FEMALE,
UNSPECIFIED
}
export class EventUser {
static fragments = gql`
fragment eventUserPrimitives on EventUser {
id
eventusercreated
}
`;
id: number;
eventusercreated: Date;
user: User;
constructor() { }
}
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
// vim magic: %s/^\s*\w\+\s\+\(\w\+\)\s\+\(\w\+\)\s*.*;$/ \2: \L\1;/ // vim magic: %s/^\s*\w\+\s\+\(\w\+\)\s\+\(\w\+\)\s*.*;$/ \2: \L\1;/
import gql from "graphql-tag";
export enum UserGender { export enum UserGender {
MALE, MALE,
FEMALE, FEMALE,
...@@ -12,10 +14,33 @@ export enum UserGender { ...@@ -12,10 +14,33 @@ export enum UserGender {
export class User { export class User {
static fragments = gql`
fragment userPrimitives on User {
address
allergiesFreetext
birthday
email
firstnames
gender
id:
lastname
login
nick
phone
town
shirtSize
town
zip
}
`;
nick: string; nick: string;
login: string; login: string;
eventuserId: number; id: number;
userId: number;
firstname: string; firstname: string;
lastname: string; lastname: string;
password: string; password: string;
...@@ -23,12 +48,12 @@ export class User { ...@@ -23,12 +48,12 @@ export class User {
birthday: Date; birthday: Date;
gender: UserGender; gender: UserGender;
phoneNumber: string; phone: string;
email: string; email: string;
streetAddress: string; streetAddress: string;
zipCode: string; zip: string;
postOffice: string; town: string;
constructor() { } constructor() { }
......
...@@ -12,10 +12,11 @@ ...@@ -12,10 +12,11 @@
"node_modules/@types" "node_modules/@types"
], ],
"lib": [ "lib": [
"es2017", "es2018",
"dom" "dom",
"esnext.asynciterable"
], ],
"module": "es2015", "module": "es2015",
"baseUrl": "./" "baseUrl": "./"
} }
} }
\ No newline at end of file
...@@ -626,6 +626,13 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -626,6 +626,13 @@ public class BootstrapBean implements BootstrapBeanLocal {
"ALTER TABLE compo_voting_roles ADD CONSTRAINT FK_compo_voting_roles_scheme_id FOREIGN KEY (scheme_id) REFERENCES compo_voting_schemes (id)", "ALTER TABLE compo_voting_roles ADD CONSTRAINT FK_compo_voting_roles_scheme_id FOREIGN KEY (scheme_id) REFERENCES compo_voting_schemes (id)",
"ALTER TABLE compo_voting_roles ADD CONSTRAINT FK_compo_voting_roles_role_id FOREIGN KEY (role_id) REFERENCES roles (id)", "ALTER TABLE compo_voting_roles ADD CONSTRAINT FK_compo_voting_roles_role_id FOREIGN KEY (role_id) REFERENCES roles (id)",
}); });
dbUpdates.add(new String[]{
"ALTER TABLE users DROP COLUMN postal_town;"
});
} }
......
...@@ -96,9 +96,6 @@ public class User extends GenericEntity implements IUser { ...@@ -96,9 +96,6 @@ public class User extends GenericEntity implements IUser {
@Column(name = "zip") @Column(name = "zip")
private String zip = ""; private String zip = "";
@Column(name = "postal_town")
private String postalTown = "";
@Column(name = "town") @Column(name = "town")
private String town = ""; private String town = "";
......
...@@ -9,6 +9,7 @@ import fi.codecrew.moya.graphql.util.PropertyFetchWrapper; ...@@ -9,6 +9,7 @@ import fi.codecrew.moya.graphql.util.PropertyFetchWrapper;
import fi.codecrew.moya.model.*; import fi.codecrew.moya.model.*;
import fi.codecrew.moya.utilities.SearchQuery; import fi.codecrew.moya.utilities.SearchQuery;
import fi.codecrew.moya.utilities.SearchResult; import fi.codecrew.moya.utilities.SearchResult;
import fi.codecrew.moya.utilities.jpa.ModelInterface;
import graphql.*; import graphql.*;
import graphql.schema.*; import graphql.schema.*;
import graphql.schema.idl.SchemaPrinter; import graphql.schema.idl.SchemaPrinter;
...@@ -221,19 +222,19 @@ public class MoyaGraphQLServlet extends HttpServlet { ...@@ -221,19 +222,19 @@ public class MoyaGraphQLServlet extends HttpServlet {
return stringWriter.toString(); return stringWriter.toString();
}).description("Returns the object as a string."); }).description("Returns the object as a string.");
b.addField(Map.Entry.class) b.addField(Map.Entry.class)
.argument(newArgument().name("keys").defaultValue(Collections.emptyMap()).type(GraphQLList.list(GraphQLString))) .argument(newArgument().name("keys").defaultValue(Collections.emptyMap()).type(GraphQLList.list(GraphQLString)))
.name("path") .name("path")
.description("Returngs values from given keys as key, value pairs") .description("Returngs values from given keys as key, value pairs")
.dataFetcher(environment -> { .dataFetcher(environment -> {
Map<String, String> ret = new HashMap<>(); Map<String, String> ret = new HashMap<>();
final JsonObject jsonObj = environment.getSource(); final JsonObject jsonObj = environment.getSource();
((List<String>) environment.getArgument("keys")).forEach(key -> { ((List<String>) environment.getArgument("keys")).forEach(key -> {
if (jsonObj.containsKey(key)) ret.put(key, jsonObj.getString(key)); if (jsonObj.containsKey(key)) ret.put(key, jsonObj.getString(key));
});
return ret.entrySet();
}); });
return ret.entrySet();
});
} }
{ {
EntityGQLBuilder<Role> b = builder.createEntity(Role.class); EntityGQLBuilder<Role> b = builder.createEntity(Role.class);
...@@ -326,7 +327,7 @@ public class MoyaGraphQLServlet extends HttpServlet { ...@@ -326,7 +327,7 @@ public class MoyaGraphQLServlet extends HttpServlet {
b.addField(User_.email); b.addField(User_.email);
b.addField(User_.address); b.addField(User_.address);
b.addField(User_.zip); b.addField(User_.zip);
b.addField(User_.postalTown); //b.addField(User_.postalTown);
b.addField(User_.town); b.addField(User_.town);
b.addField(User_.phone); b.addField(User_.phone);
b.addField(User_.gender); b.addField(User_.gender);
...@@ -334,25 +335,25 @@ public class MoyaGraphQLServlet extends HttpServlet { ...@@ -334,25 +335,25 @@ public class MoyaGraphQLServlet extends HttpServlet {
b.addField().name("shirtSize").type(GraphQLString).dataFetcher(new JSONPropertyDataFetcher("meta", "shirtSize")); b.addField().name("shirtSize").type(GraphQLString).dataFetcher(new JSONPropertyDataFetcher("meta", "shirtSize"));
b.addField().name("allergiesFreetext").type(GraphQLString).dataFetcher(new JSONPropertyDataFetcher("meta", "allergies")); b.addField().name("allergiesFreetext").type(GraphQLString).dataFetcher(new JSONPropertyDataFetcher("meta", "allergies"));
b.addListField(UsersAllergy.class) b.addListField(UsersAllergy.class)
.name("allergies") .name("allergies")
.argument(newArgument() .argument(newArgument()
.description("By default, show only allergies, user has selected") .description("By default, show only allergies, user has selected")
.type(GraphQLBoolean) .type(GraphQLBoolean)
.defaultValue(true) .defaultValue(true)
.name("onlySelected")) .name("onlySelected"))
.dataFetcher(environment -> { .dataFetcher(environment -> {
List<UsersAllergy> allergies = allergybean.getUserAllergies((User) environment.getSource()); List<UsersAllergy> allergies = allergybean.getUserAllergies((User) environment.getSource());
logger.warn("Got allergies for user {}", allergies); logger.warn("Got allergies for user {}", allergies);
if (environment.getArgument("onlySelected")) { if (environment.getArgument("onlySelected")) {
logger.warn("Filtering allergies"); logger.warn("Filtering allergies");
return allergies.stream().sorted(ENTITY_ID_SORTER).filter(a -> a.isSelected()).collect(toList()); return allergies.stream().sorted(ENTITY_ID_SORTER).filter(a -> a.isSelected()).collect(toList());
} }
return allergies; return allergies;
}); });
b.addListField(EventUser.class) b.addListField(EventUser.class)
.dataFetcher(environment -> userbean.findAllEventusers(environment.getSource()).stream().sorted(ENTITY_ID_SORTER).collect(toList())) .dataFetcher(environment -> userbean.findAllEventusers(environment.getSource()).stream().sorted(ENTITY_ID_SORTER).collect(toList()))
.description("Only users themselves can fetch eventusers for other events. If another user tries to fetch this data, an exception will be thrown"); .description("Only users themselves can fetch eventusers for other events. If another user tries to fetch this data, an exception will be thrown");
} }
...@@ -367,9 +368,9 @@ public class MoyaGraphQLServlet extends HttpServlet { ...@@ -367,9 +368,9 @@ public class MoyaGraphQLServlet extends HttpServlet {
b.addField(UsersAllergy_.selected); b.addField(UsersAllergy_.selected);
b.addField().type(GraphQLString) b.addField().type(GraphQLString)
.name("allergyname") .name("allergyname")
.dataFetcher(environment -> ((UsersAllergy) environment.getSource()).getAllergy().getName().getDefaultValue()) .dataFetcher(environment -> ((UsersAllergy) environment.getSource()).getAllergy().getName().getDefaultValue())
.description("Shorthand for { allergy {name {defaultvalue}}}"); .description("Shorthand for { allergy {name {defaultvalue}}}");
} }
{ {
...@@ -473,6 +474,29 @@ public class MoyaGraphQLServlet extends HttpServlet { ...@@ -473,6 +474,29 @@ public class MoyaGraphQLServlet extends HttpServlet {
{ {
EntityGQLBuilder<VipProduct> b = builder.createEntity(VipProduct.class);
b.addField(VipProduct_.id);
b.addField(VipProduct_.deliveries);
b.addField(VipProduct_.name);
b.addField(VipProduct_.notes);
b.addField(VipProduct_.product);
b.addField(VipProduct_.quantity);
b.addField(VipProduct_.vip);
}
{
EntityGQLBuilder<VipProductDelivery> b = builder.createEntity(VipProductDelivery.class);
b.addField(VipProductDelivery_.id);
b.addField(VipProductDelivery_.deliverer);
b.addField(VipProductDelivery_.deliveryTime);
b.addField(VipProductDelivery_.notes);
b.addField(VipProductDelivery_.quantity);
b.addField(VipProductDelivery_.vipProduct);
}
{
EntityGQLBuilder<LanEvent> b = builder.createEntity(SIMPLE_EVENT_TYPE_NAME); EntityGQLBuilder<LanEvent> b = builder.createEntity(SIMPLE_EVENT_TYPE_NAME);
b.addField(LanEvent_.id); b.addField(LanEvent_.id);
...@@ -505,6 +529,7 @@ public class MoyaGraphQLServlet extends HttpServlet { ...@@ -505,6 +529,7 @@ public class MoyaGraphQLServlet extends HttpServlet {
{ {
EntityGQLBuilder<CompoEntry> b = builder.createEntity(CompoEntry.class); EntityGQLBuilder<CompoEntry> b = builder.createEntity(CompoEntry.class);
b.addField(CompoEntry_.id); b.addField(CompoEntry_.id);
b.addField(CompoEntry_.created); b.addField(CompoEntry_.created);
b.addField(CompoEntry_.creator); b.addField(CompoEntry_.creator);
...@@ -559,16 +584,6 @@ public class MoyaGraphQLServlet extends HttpServlet { ...@@ -559,16 +584,6 @@ public class MoyaGraphQLServlet extends HttpServlet {
b.addField(LanEvent_.ticketSalesBegin); b.addField(LanEvent_.ticketSalesBegin);
b.addField(LanEvent_.domains); b.addField(LanEvent_.domains);
b.addField(LanEvent_.meta); b.addField(LanEvent_.meta);
b.addListField(EventMap.class).dataFetcher(environment -> placebean.getMaps().stream().sorted(ENTITY_ID_SORTER).collect(toList()));
b.addListField(Role.class).dataFetcher(environment -> rolebean.listRoles().stream().sorted(ENTITY_ID_SORTER).collect(toList()));
b.addListField(Product.class).dataFetcher(environment -> productbean.findProductsForEvent().stream().sorted(ENTITY_ID_SORTER).collect(toList()));
b.addListField(Compo.class).dataFetcher(environment -> votebean.getCompoList(true).stream().sorted(ENTITY_ID_SORTER).collect(toList()));
b.addField(LanEvent_.id);
b.addListField(Vip.class).dataFetcher(enviroment -> vipBean.getAvailableVips());
} }
return builder; return builder;
} }
...@@ -580,10 +595,37 @@ public class MoyaGraphQLServlet extends HttpServlet { ...@@ -580,10 +595,37 @@ public class MoyaGraphQLServlet extends HttpServlet {
schemaBld.additionalTypes(builder.getTypes()); schemaBld.additionalTypes(builder.getTypes());
schemaBld.query(GraphQLObjectType.newObject() schemaBld.query(GraphQLObjectType.newObject()
.name("moyaQuery") .name("moyaQuery")
.field(getUserSearchField(builder)) .field(getUserSearchField(builder))
.field(getEventSearchQuery(builder)) .field(getEventSearchQuery(builder))
.field(getSingleUserQuery(builder))); .field(getSingleUserQuery(builder))
.field(
newFieldDefinition()
.name("eventmaps")
.type(GraphQLList.list(builder.typeFor(EventMap.class)))
.dataFetcher(environment -> placebean.getMaps().stream().sorted(ENTITY_ID_SORTER).collect(toList())))
.field(
newFieldDefinition()
.name("roles")
.type(GraphQLList.list(builder.typeFor(Role.class)))
.dataFetcher(environment -> rolebean.listRoles().stream().sorted(ENTITY_ID_SORTER).collect(toList())))
.field(
newFieldDefinition()
.name("products")
.type(GraphQLList.list(builder.typeFor(Product.class)))
.dataFetcher(environment -> productbean.findProductsForEvent().stream().sorted(ENTITY_ID_SORTER).collect(toList())))
.field(
newFieldDefinition()
.name("compos")
.type(GraphQLList.list(builder.typeFor(Compo.class)))
.dataFetcher(environment -> votebean.getCompoList(true).stream().sorted(ENTITY_ID_SORTER).collect(toList())))
.field(
newFieldDefinition()
.name("vips")
.type(GraphQLList.list(builder.typeFor(Vip.class)))
.dataFetcher(environment -> vipBean.getAvailableVips()))
);
return schemaBld.build(); return schemaBld.build();
...@@ -592,63 +634,63 @@ public class MoyaGraphQLServlet extends HttpServlet { ...@@ -592,63 +634,63 @@ public class MoyaGraphQLServlet extends HttpServlet {
private GraphQLFieldDefinition getSingleUserQuery(GraphQLBuilder builder) { private GraphQLFieldDefinition getSingleUserQuery(GraphQLBuilder builder) {
return newFieldDefinition() return newFieldDefinition()
.name("user") .name("user")
.argument(newArgument().name("id").type(GraphQLInt).description("Id of the global user object. If id is 0, currently logged in user is used")) .argument(newArgument().name("id").type(GraphQLInt).description("Id of the global user object. If id is 0, currently logged in user is used"))
.type(builder.typeFor(User.class)) .type(builder.typeFor(User.class))
.dataFetcher(environment -> { .dataFetcher(environment -> {
Integer id = environment.getArgument("userId"); Integer id = environment.getArgument("userId");
EventUser user; EventUser user;
if (id == null || id.equals(0)) { if (id == null || id.equals(0)) {
user = permbean.getCurrentUser(); user = permbean.getCurrentUser();
} else { } else {
user = userbean.findByUserId(id, false); user = userbean.findByUserId(id, false);
} }
if (user == null) { if (user == null) {
throw new NullPointerException("User not found with id " + id); throw new NullPointerException("User not found with id " + id);
} }
return user.getUser(); return user.getUser();
}).build(); }).build();
} }
private GraphQLFieldDefinition.Builder getEventSearchQuery(GraphQLBuilder builder) { private GraphQLFieldDefinition.Builder getEventSearchQuery(GraphQLBuilder builder) {
return newFieldDefinition() return newFieldDefinition()
.name("currentevent") .name("currentevent")
.type(builder.typeFor(LanEvent.class)) .type(builder.typeFor(LanEvent.class))
.dataFetcher(environment -> eventbean.getCurrentEvent()); .dataFetcher(environment -> eventbean.getCurrentEvent());
} }
private GraphQLFieldDefinition.Builder getUserSearchField(GraphQLBuilder builder) { private GraphQLFieldDefinition.Builder getUserSearchField(GraphQLBuilder builder) {
return newFieldDefinition() return newFieldDefinition()
.type(new GraphQLList(builder.typeFor(EventUser.class))) .type(new GraphQLList(builder.typeFor(EventUser.class)))
.name("usersearch") .name("usersearch")
.description("Search users. Using this method requires admin acccess to the database") .description("Search users. Using this method requires admin acccess to the database")
//.argument(newArgument().name("reason").type(GraphQLString).description("Reason for the data request. Reason and requested fields are stored to audit log.")) //.argument(newArgument().name("reason").type(GraphQLString).description("Reason for the data request. Reason and requested fields are stored to audit log."))
.argument(newArgument().name("roles").defaultValue(Collections.emptyList()).description("(Optional) Filter users that belong to a role").type(GraphQLList.list(GraphQLInt))) .argument(newArgument().name("roles").defaultValue(Collections.emptyList()).description("(Optional) Filter users that belong to a role").type(GraphQLList.list(GraphQLInt)))
.argument(newArgument().name("search").type(GraphQLString).defaultValue("").description("(Optional) Filter users that contain the search parameter in their firstname, lastname, nick or email").type(GraphQLString)) .argument(newArgument().name("search").type(GraphQLString).defaultValue("").description("(Optional) Filter users that contain the search parameter in their firstname, lastname, nick or email").type(GraphQLString))
.argument(newArgument().name("page").type(GraphQLInt).defaultValue(0).description("Pagination page ( 0 is the first page)")) .argument(newArgument().name("page").type(GraphQLInt).defaultValue(0).description("Pagination page ( 0 is the first page)"))
.argument(newArgument().name("pagesize").type(GraphQLInt).defaultValue(0).description("Pagination pagesize (0 disables pagination)")) .argument(newArgument().name("pagesize").type(GraphQLInt).defaultValue(0).description("Pagination pagesize (0 disables pagination)"))
.dataFetcher((DataFetcher<List<EventUser>>) environment -> { .dataFetcher((DataFetcher<List<EventUser>>) environment -> {
/* /*
String reason = environment.getArgument("reason"); String reason = environment.getArgument("reason");
if (reason == null || reason.isEmpty()) { if (reason == null || reason.isEmpty()) {
throw new GRPDException("Query did not provide a reason for the request"); throw new GRPDException("Query did not provide a reason for the request");
}*/ }*/
UserSearchQuery query = new UserSearchQuery(environment.getArgument("page"), environment.getArgument("pagesize"), null, null, SearchQuery.QuerySortOrder.UNSORTED); UserSearchQuery query = new UserSearchQuery(environment.getArgument("page"), environment.getArgument("pagesize"), null, null, SearchQuery.QuerySortOrder.UNSORTED);
String searchArg = environment.getArgument("search"); String searchArg = environment.getArgument("search");
if (searchArg != null && !searchArg.isEmpty()) { if (searchArg != null && !searchArg.isEmpty()) {
query.setSearch(searchArg); query.setSearch(searchArg);
} }
List<Integer> roleArgument = environment.getArgument("roles"); List<Integer> roleArgument = environment.getArgument("roles");
if (roleArgument != null && !roleArgument.isEmpty()) { if (roleArgument != null && !roleArgument.isEmpty()) {
query.setFilterRoles(roleArgument.stream().map(id -> rolebean.find(id)).filter(x -> x != null).collect(toList())); query.setFilterRoles(roleArgument.stream().map(id -> rolebean.find(id)).filter(x -> x != null).collect(toList()));
} }
SearchResult<EventUser> ret = userbean.getThisEventsUsers(query); SearchResult<EventUser> ret = userbean.getThisEventsUsers(query);
return ret.getResults(); return ret.getResults();
}); });
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!