Commit 0562ac3a by Tuukka Kivilahti

commit before mergin onja's changes

1 parent 4f6f5ef2
package-lock=false
......@@ -44,7 +44,7 @@
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.7.0",
"@angular-devkit/build-angular": "~0.7.2",
"@angular/cdk": "^6.4.2",
"@angular/cli": "6.1.2",
"@angular/compiler-cli": "6.1.1",
......
/**
* Created by tuukka on 04/02/17.
*/
import gql from "graphql-tag";
export class VipProductDelivery {
/*
public Integer id;
public Integer delivererId;
public BigDecimal quantity;
public Date deliveryTime;
public String notes;
*/
static fragments = gql`
fragment vipProductDeliveryPrimitives on VipProductDelivery {
deliverytime
id
notes
quantity
}
`;
id: number;
delivererId: number;
......
import {VipProductDelivery} from './vip-product-delivery.model';
import gql from "graphql-tag";
/**
* Created by tuukka on 04/02/17.
*/
......@@ -7,17 +8,14 @@ import {VipProductDelivery} from './vip-product-delivery.model';
export class VipProduct {
/*
public Integer id;
public String name;
public Integer productId;
public String notes;
public BigDecimal quantity;
public BigDecimal delivered;
public List<VipProductDeliveryPojo> deliveries = new ArrayList<>();
*/
static fragments = gql`
fragment vipProductPrimitives on VipProduct {
id
name
notes
quantity
}
`;
id: number;
name: string;
......
import {VipProduct} from './vip-product.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.
*/
......@@ -8,17 +10,14 @@ import {User} from '../../../shared/models/user.model';
export class Vip {
/*
public Integer id;
public String description;
public String shortdescr;
public Date created;
public Integer eventuserId;
public Integer creatorId;
public Integer hostId;
public List<VipProductPojo> products = new ArrayList<>();
*/
static fragments = gql`
fragment vipPrimitives on Vip {
created
description
id
shortdescr
}
`;
id: number;
description: string;
......@@ -35,3 +34,9 @@ export class Vip {
}
}
export const VipFragmentsCombined = gql`
${Vip.fragments}
${VipProduct.fragments}
${VipProductDelivery.fragments}
`;
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 {UserService} from '../../shared/services/user.service';
import {Observable} from 'rxjs/Observable';
......@@ -9,11 +9,46 @@ import 'rxjs/add/observable/forkJoin';
import 'rxjs/add/operator/first';
import {HttpClient} from '@angular/common/http';
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()
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 {
* get 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) {
return this.http.get(MOYA_REST_URL + 'v3/vip/all')
.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 @@
// vim magic: %s/^\s*\w\+\s\+\(\w\+\)\s\+\(\w\+\)\s*.*;$/ \2: \L\1;/
import gql from "graphql-tag";
export enum UserGender {
MALE,
FEMALE,
......@@ -12,10 +14,33 @@ export enum UserGender {
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;
login: string;
eventuserId: number;
userId: number;
id: number;
firstname: string;
lastname: string;
password: string;
......@@ -23,12 +48,12 @@ export class User {
birthday: Date;
gender: UserGender;
phoneNumber: string;
phone: string;
email: string;
streetAddress: string;
zipCode: string;
postOffice: string;
zip: string;
town: string;
constructor() { }
......
......@@ -12,8 +12,9 @@
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
"es2018",
"dom",
"esnext.asynciterable"
],
"module": "es2015",
"baseUrl": "./"
......
......@@ -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_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 {
@Column(name = "zip")
private String zip = "";
@Column(name = "postal_town")
private String postalTown = "";
@Column(name = "town")
private String town = "";
......
......@@ -9,6 +9,7 @@ import fi.codecrew.moya.graphql.util.PropertyFetchWrapper;
import fi.codecrew.moya.model.*;
import fi.codecrew.moya.utilities.SearchQuery;
import fi.codecrew.moya.utilities.SearchResult;
import fi.codecrew.moya.utilities.jpa.ModelInterface;
import graphql.*;
import graphql.schema.*;
import graphql.schema.idl.SchemaPrinter;
......@@ -326,7 +327,7 @@ public class MoyaGraphQLServlet extends HttpServlet {
b.addField(User_.email);
b.addField(User_.address);
b.addField(User_.zip);
b.addField(User_.postalTown);
//b.addField(User_.postalTown);
b.addField(User_.town);
b.addField(User_.phone);
b.addField(User_.gender);
......@@ -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);
b.addField(LanEvent_.id);
......@@ -505,6 +529,7 @@ public class MoyaGraphQLServlet extends HttpServlet {
{
EntityGQLBuilder<CompoEntry> b = builder.createEntity(CompoEntry.class);
b.addField(CompoEntry_.id);
b.addField(CompoEntry_.created);
b.addField(CompoEntry_.creator);
......@@ -559,16 +584,6 @@ public class MoyaGraphQLServlet extends HttpServlet {
b.addField(LanEvent_.ticketSalesBegin);
b.addField(LanEvent_.domains);
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;
}
......@@ -583,7 +598,34 @@ public class MoyaGraphQLServlet extends HttpServlet {
.name("moyaQuery")
.field(getUserSearchField(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();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!