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,8 +12,9 @@ ...@@ -12,8 +12,9 @@
"node_modules/@types" "node_modules/@types"
], ],
"lib": [ "lib": [
"es2017", "es2018",
"dom" "dom",
"esnext.asynciterable"
], ],
"module": "es2015", "module": "es2015",
"baseUrl": "./" "baseUrl": "./"
......
...@@ -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;
...@@ -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);
...@@ -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;
} }
...@@ -583,7 +598,34 @@ public class MoyaGraphQLServlet extends HttpServlet { ...@@ -583,7 +598,34 @@ public class MoyaGraphQLServlet extends HttpServlet {
.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();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!