http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/bootstrap.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/bootstrap.tmpl b/tools/generator-polygene/app/templates/Heroes/bootstrap.tmpl new file mode 100644 index 0000000..e3a9d06 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/bootstrap.tmpl @@ -0,0 +1,68 @@ +<%# + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * +-%> +package <%= packageName %>.bootstrap; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.function.Function; + +import org.apache.polygene.api.structure.Application; +import org.apache.polygene.api.structure.Module; + +import org.apache.polygene.bootstrap.ApplicationAssembly; +import org.apache.polygene.bootstrap.AssemblyException; +import org.apache.polygene.bootstrap.LayerAssembly; +import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.bootstrap.layered.LayeredApplicationAssembler; + +import <%= packageName %>.bootstrap.connectivity.ConnectivityLayer; +import <%= packageName %>.bootstrap.domain.DomainLayer; +import <%= packageName %>.bootstrap.config.ConfigurationLayer; +import <%= packageName %>.bootstrap.infrastructure.InfrastructureLayer; + +public class HeroesApplicationAssembler extends LayeredApplicationAssembler +{ + private static final String NAME = "Heroes"; + private static final String VERSION = "1.0.alpha"; + + public HeroesApplicationAssembler( Application.Mode mode ) + throws AssemblyException + { + super( NAME, VERSION, mode ); + } + + @Override + protected void assembleLayers( ApplicationAssembly assembly ) + throws AssemblyException + { + LayerAssembly configLayer = createLayer( ConfigurationLayer.class ); + ModuleAssembly configModule = assemblerOf( ConfigurationLayer.class ).configModule(); + LayerAssembly domainLayer = createLayer( DomainLayer.class ); + Function<Application, Module> typeFinder = DomainLayer.typeFinder(); + LayerAssembly infraLayer = new InfrastructureLayer( configModule, typeFinder ).assemble( assembly.layer( InfrastructureLayer.NAME ) ); + LayerAssembly connectivityLayer = createLayer( ConnectivityLayer.class ); + connectivityLayer.uses( domainLayer ); + domainLayer.uses( infraLayer ); + infraLayer.uses( configLayer ); + } +} +
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/web.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/web.tmpl b/tools/generator-polygene/app/templates/Heroes/web.tmpl new file mode 100644 index 0000000..dda4f37 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/web.tmpl @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<%# + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + ~ + ~ +%> +<web-app xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" + version="2.5"> + + <display-name><%= polygene.name %></display-name> + + + <servlet> + <servlet-name>Restlet</servlet-name> + <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class> + <init-param> + <param-name>org.apache.polygene.runtime.mode</param-name> + <param-value>development</param-value> + </init-param> + <init-param> + <!-- Application class name --> + <param-name>org.restlet.application</param-name> + <param-value><%= packageName %>.app.Heroes</param-value> + </init-param> + <init-param> + <!-- Protocols to be bound to--> + <param-name>org.restlet.clients</param-name> + <param-value>HTTP HTTPS</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + + <servlet-mapping> + <servlet-name>Restlet</servlet-name> + <url-pattern>/api/1/*</url-pattern> + </servlet-mapping> + +</web-app> http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/app.component.css ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/app.component.css b/tools/generator-polygene/app/templates/Heroes/webapp/app/app.component.css new file mode 100644 index 0000000..cb651f5 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/app.component.css @@ -0,0 +1,34 @@ +nav a { + padding: 5px 10px; + text-decoration: none; + margin-top: 10px; + display: inline-block; + background-color: #eee; + border-radius: 4px; +} +nav a:visited, a:link { + color: #607D8B; +} +nav a:hover { + color: #039be5; + background-color: #CFD8DC; +} +nav a.router-link-active { + color: #039be5; +} +h1 { + font-size: 1.2em; + color: #999; + margin-bottom: 0; +} +h2 { + font-size: 2em; + margin-top: 0; + padding-top: 0; +} + +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/app.component.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/app.component.js b/tools/generator-polygene/app/templates/Heroes/webapp/app/app.component.js new file mode 100644 index 0000000..18aeea4 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/app.component.js @@ -0,0 +1,41 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var core_1 = require('angular2/core'); +var router_1 = require('angular2/router'); +var heroes_component_1 = require('./heroes.component'); +var hero_detail_component_1 = require('./hero-detail.component'); +var dashboard_component_1 = require('./dashboard.component'); +var hero_service_1 = require('./hero.service'); +var AppComponent = (function () { + function AppComponent() { + this.title = 'Tour of Heroes'; + } + AppComponent = __decorate([ + core_1.Component({ + selector: 'my-app', + template: "\n <h1>{{title}}</h1>\n <nav>\n <a [routerLink]=\"['Dashboard']\">Dashboard</a>\n <a [routerLink]=\"['Heroes']\">Heroes</a>\n </nav>\n <router-outlet></router-outlet>\n ", + styleUrls: ['app/app.component.css'], + directives: [router_1.ROUTER_DIRECTIVES], + providers: [hero_service_1.HeroService] + }), + router_1.RouteConfig([ + // {path: '/', redirectTo: ['Dashboard'] }, + { path: '/dashboard', name: 'Dashboard', component: dashboard_component_1.DashboardComponent, useAsDefault: true }, + { path: '/heroes', name: 'Heroes', component: heroes_component_1.HeroesComponent }, + { path: '/detail/:id', name: 'HeroDetail', component: hero_detail_component_1.HeroDetailComponent } + ]) + ], AppComponent); + return AppComponent; +}()); +exports.AppComponent = AppComponent; +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ +//# sourceMappingURL=app.component.js.map \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/app.component.js.map ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/app.component.js.map b/tools/generator-polygene/app/templates/Heroes/webapp/app/app.component.js.map new file mode 100644 index 0000000..bade57d --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/app.component.js.map @@ -0,0 +1 @@ +{"version":3,"file":"app.component.js","sourceRoot":"","sources":["app.component.ts"],"names":[],"mappings":";;;;;;;AAAA,qBAAwB,eAAe,CAAC,CAAA;AACxC,uBAA6C,iBAAiB,CAAC,CAAA;AAC/D,iCAA8B,oBAAoB,CAAC,CAAA;AACnD,sCAAkC,yBAAyB,CAAC,CAAA;AAC5D,oCAAiC,uBAAuB,CAAC,CAAA;AACzD,6BAA0B,gBAAgB,CAAC,CAAA;AAsB3C;IAAA;QACE,UAAK,GAAG,gBAAgB,CAAC;IAC3B,CAAC;IAtBD;QAAC,gBAAS,CAAC;YACT,QAAQ,EAAE,QAAQ;YAClB,QAAQ,EAAE,kMAOT;YACD,SAAS,EAAE,CAAC,uBAAuB,CAAC;YACpC,UAAU,EAAE,CAAC,0BAAiB,CAAC;YAC/B,SAAS,EAAE,CAAC,0BAAW,CAAC;SACzB,CAAC;QACD,oBAAW,CAAC;YACX,2CAA2C;YAC3C,EAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,wCAAkB,EAAE,YAAY,EAAE,IAAI,EAAC;YAC1F,EAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,kCAAe,EAAC;YAC7D,EAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,2CAAmB,EAAC;SAC1E,CAAC;oBAAA;IAGF,mBAAC;AAAD,CAAC,AAFD,IAEC;AAFY,oBAAY,eAExB,CAAA;AAGD;;;;EAIE"} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/app.component.ts ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/app.component.ts b/tools/generator-polygene/app/templates/Heroes/webapp/app/app.component.ts new file mode 100644 index 0000000..222874b --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/app.component.ts @@ -0,0 +1,37 @@ +import {Component} from 'angular2/core'; +import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router'; +import {HeroesComponent} from './heroes.component'; +import {HeroDetailComponent} from './hero-detail.component'; +import {DashboardComponent} from './dashboard.component'; +import {HeroService} from './hero.service'; + +@Component({ + selector: 'my-app', + template: ` + <h1>{{title}}</h1> + <nav> + <a [routerLink]="['Dashboard']">Dashboard</a> + <a [routerLink]="['Heroes']">Heroes</a> + </nav> + <router-outlet></router-outlet> + `, + styleUrls: ['app/app.component.css'], + directives: [ROUTER_DIRECTIVES], + providers: [HeroService] +}) +@RouteConfig([ + // {path: '/', redirectTo: ['Dashboard'] }, + {path: '/dashboard', name: 'Dashboard', component: DashboardComponent, useAsDefault: true}, + {path: '/heroes', name: 'Heroes', component: HeroesComponent}, + {path: '/detail/:id', name: 'HeroDetail', component: HeroDetailComponent} +]) +export class AppComponent { + title = 'Tour of Heroes'; +} + + +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/dashboard.component.css ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/dashboard.component.css b/tools/generator-polygene/app/templates/Heroes/webapp/app/dashboard.component.css new file mode 100644 index 0000000..b9d3215 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/dashboard.component.css @@ -0,0 +1,67 @@ +[class*='col-'] { + float: left; +} +*, *:after, *:before { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +h3 { + text-align: center; margin-bottom: 0; +} +[class*='col-'] { + padding-right: 20px; + padding-bottom: 20px; +} +[class*='col-']:last-of-type { + padding-right: 0; +} +.grid { + margin: 0; +} +.col-1-4 { + width: 25%; +} +.module { + padding: 20px; + text-align: center; + color: #eee; + max-height: 120px; + min-width: 120px; + background-color: #607D8B; + border-radius: 2px; +} +h4 { + position: relative; +} +.module:hover { + background-color: #EEE; + cursor: pointer; + color: #607d8b; +} +.grid-pad { + padding: 10px 0; +} +.grid-pad > [class*='col-']:last-of-type { + padding-right: 20px; +} +@media (max-width: 600px) { + .module { + font-size: 10px; + max-height: 75px; } +} +@media (max-width: 1024px) { + .grid { + margin: 0; + } + .module { + min-width: 60px; + } +} + + +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/dashboard.component.html ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/dashboard.component.html b/tools/generator-polygene/app/templates/Heroes/webapp/app/dashboard.component.html new file mode 100644 index 0000000..3fc7517 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/dashboard.component.html @@ -0,0 +1,15 @@ +<h3>Top Heroes</h3> +<div class="grid grid-pad"> + <div *ngFor="#hero of heroes" class="col-1-4" (click)="gotoDetail(hero)"> + <div class="module hero"> + <h4>{{hero.name}}</h4> + </div> + </div> +</div> + + +<!-- +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +--> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/dashboard.component.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/dashboard.component.js b/tools/generator-polygene/app/templates/Heroes/webapp/app/dashboard.component.js new file mode 100644 index 0000000..9c69780 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/dashboard.component.js @@ -0,0 +1,38 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var core_1 = require('angular2/core'); +var DashboardComponent = (function () { + function DashboardComponent(_heroService, _router) { + this._heroService = _heroService; + this._router = _router; + this.heroes = []; + } + DashboardComponent.prototype.ngOnInit = function () { + var _this = this; + this._heroService.getHeroes().then(function (heroes) { return _this.heroes = heroes.slice(1, 5); }); + }; + DashboardComponent.prototype.gotoDetail = function (hero) { + var link = ['HeroDetail', { id: hero.id }]; + this._router.navigate(link); + }; + DashboardComponent = __decorate([ + core_1.Component({ + selector: 'my-dashboard', + templateUrl: 'app/dashboard.component.html', + styleUrls: ['app/dashboard.component.css'] + }) + ], DashboardComponent); + return DashboardComponent; +}()); +exports.DashboardComponent = DashboardComponent; +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ +//# sourceMappingURL=dashboard.component.js.map \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/dashboard.component.js.map ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/dashboard.component.js.map b/tools/generator-polygene/app/templates/Heroes/webapp/app/dashboard.component.js.map new file mode 100644 index 0000000..5bc16f0 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/dashboard.component.js.map @@ -0,0 +1 @@ +{"version":3,"file":"dashboard.component.js","sourceRoot":"","sources":["dashboard.component.ts"],"names":[],"mappings":";;;;;;;AAAA,qBAAgC,eAAe,CAAC,CAAA;AAUhD;IAGE,4BAAoB,YAAyB,EAAU,OAAe;QAAlD,iBAAY,GAAZ,YAAY,CAAa;QAAU,YAAO,GAAP,OAAO,CAAQ;QAFtE,WAAM,GAAW,EAAE,CAAC;IAEsD,CAAC;IAE3E,qCAAQ,GAAR;QAAA,iBAEC;QADC,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,UAAA,MAAM,IAAI,OAAA,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAC,CAAC,CAAC,EAA/B,CAA+B,CAAC,CAAC;IAChF,CAAC;IAED,uCAAU,GAAV,UAAW,IAAU;QACnB,IAAI,IAAI,GAAG,CAAC,YAAY,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3C,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAjBH;QAAC,gBAAS,CAAC;YACT,QAAQ,EAAE,cAAc;YACxB,WAAW,EAAE,8BAA8B;YAC3C,SAAS,EAAE,CAAC,6BAA6B,CAAC;SAC3C,CAAC;0BAAA;IAcF,yBAAC;AAAD,CAAC,AAbD,IAaC;AAbY,0BAAkB,qBAa9B,CAAA;AAGD;;;;EAIE"} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/dashboard.component.ts ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/dashboard.component.ts b/tools/generator-polygene/app/templates/Heroes/webapp/app/dashboard.component.ts new file mode 100644 index 0000000..c8160d1 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/dashboard.component.ts @@ -0,0 +1,31 @@ +import {Component, OnInit} from 'angular2/core'; +import {Router} from 'angular2/router'; +import {Hero} from './hero'; +import {HeroService} from './hero.service'; + +@Component({ + selector: 'my-dashboard', + templateUrl: 'app/dashboard.component.html', + styleUrls: ['app/dashboard.component.css'] +}) +export class DashboardComponent implements OnInit { + heroes: Hero[] = []; + + constructor(private _heroService: HeroService, private _router: Router) { } + + ngOnInit() { + this._heroService.getHeroes().then(heroes => this.heroes = heroes.slice(1,5)); + } + + gotoDetail(hero: Hero) { + let link = ['HeroDetail', { id: hero.id }]; + this._router.navigate(link); + } +} + + +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/hero-detail.component.css ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/hero-detail.component.css b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero-detail.component.css new file mode 100644 index 0000000..2a0e285 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero-detail.component.css @@ -0,0 +1,36 @@ +label { + display: inline-block; + width: 3em; + margin: .5em 0; + color: #607D8B; + font-weight: bold; +} +input { + height: 2em; + font-size: 1em; + padding-left: .4em; +} +button { + margin-top: 20px; + font-family: Arial; + background-color: #eee; + border: none; + padding: 5px 10px; + border-radius: 4px; + cursor: pointer; cursor: hand; +} +button:hover { + background-color: #cfd8dc; +} +button:disabled { + background-color: #eee; + color: #ccc; + cursor: auto; +} + + +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/hero-detail.component.html ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/hero-detail.component.html b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero-detail.component.html new file mode 100644 index 0000000..1e85e75 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero-detail.component.html @@ -0,0 +1,16 @@ +<div *ngIf="hero"> + <h2>{{hero.name}} details!</h2> + <div> + <label>id: </label>{{hero.id}}</div> + <div> + <label>name: </label> + <input [(ngModel)]="hero.name" placeholder="name"/> + </div> + <button (click)="goBack()">Back</button> +</div> + +<!-- +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +--> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/hero-detail.component.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/hero-detail.component.js b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero-detail.component.js new file mode 100644 index 0000000..56d5fa5 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero-detail.component.js @@ -0,0 +1,37 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var core_1 = require('angular2/core'); +var HeroDetailComponent = (function () { + function HeroDetailComponent(_heroService, _routeParams) { + this._heroService = _heroService; + this._routeParams = _routeParams; + } + HeroDetailComponent.prototype.ngOnInit = function () { + var _this = this; + var id = +this._routeParams.get('id'); + this._heroService.getHero(id).then(function (hero) { return _this.hero = hero; }); + }; + HeroDetailComponent.prototype.goBack = function () { + window.history.back(); + }; + HeroDetailComponent = __decorate([ + core_1.Component({ + selector: 'my-hero-detail', + templateUrl: 'app/hero-detail.component.html', + styleUrls: ['app/hero-detail.component.css'] + }) + ], HeroDetailComponent); + return HeroDetailComponent; +}()); +exports.HeroDetailComponent = HeroDetailComponent; +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ +//# sourceMappingURL=hero-detail.component.js.map \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/hero-detail.component.js.map ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/hero-detail.component.js.map b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero-detail.component.js.map new file mode 100644 index 0000000..3928563 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero-detail.component.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hero-detail.component.js","sourceRoot":"","sources":["hero-detail.component.ts"],"names":[],"mappings":";;;;;;;AAAA,qBAAgC,eAAe,CAAC,CAAA;AAWhD;IAGE,6BAAoB,YAAyB,EACnC,YAAyB;QADf,iBAAY,GAAZ,YAAY,CAAa;QACnC,iBAAY,GAAZ,YAAY,CAAa;IACnC,CAAC;IAED,sCAAQ,GAAR;QAAA,iBAGC;QAFC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,UAAA,IAAI,IAAI,OAAA,KAAI,CAAC,IAAI,GAAG,IAAI,EAAhB,CAAgB,CAAC,CAAC;IAC/D,CAAC;IAED,oCAAM,GAAN;QACE,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC;IAnBH;QAAC,gBAAS,CAAC;YACT,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,gCAAgC;YAC7C,SAAS,EAAE,CAAC,+BAA+B,CAAC;SAC7C,CAAC;2BAAA;IAgBF,0BAAC;AAAD,CAAC,AAfD,IAeC;AAfY,2BAAmB,sBAe/B,CAAA;AAGD;;;;EAIE"} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/hero-detail.component.ts ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/hero-detail.component.ts b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero-detail.component.ts new file mode 100644 index 0000000..0181847 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero-detail.component.ts @@ -0,0 +1,34 @@ +import {Component, OnInit} from 'angular2/core'; +import {RouteParams} from 'angular2/router'; + +import {Hero} from './hero'; +import {HeroService} from './hero.service'; + +@Component({ + selector: 'my-hero-detail', + templateUrl: 'app/hero-detail.component.html', + styleUrls: ['app/hero-detail.component.css'] +}) +export class HeroDetailComponent implements OnInit { + hero: Hero; + + constructor(private _heroService: HeroService, + private _routeParams: RouteParams) { + } + + ngOnInit() { + let id = +this._routeParams.get('id'); + this._heroService.getHero(id).then(hero => this.hero = hero); + } + + goBack() { + window.history.back(); + } +} + + +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.js b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.js new file mode 100644 index 0000000..0c6fe2e --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.js @@ -0,0 +1,13 @@ +"use strict"; +var Hero = (function () { + function Hero() { + } + return Hero; +}()); +exports.Hero = Hero; +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ +//# sourceMappingURL=hero.js.map \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.js.map ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.js.map b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.js.map new file mode 100644 index 0000000..4a29533 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hero.js","sourceRoot":"","sources":["hero.ts"],"names":[],"mappings":";AAAA;IAAA;IAGA,CAAC;IAAD,WAAC;AAAD,CAAC,AAHD,IAGC;AAHY,YAAI,OAGhB,CAAA;AAGD;;;;EAIE"} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.service.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.service.js b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.service.js new file mode 100644 index 0000000..3f92669 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.service.js @@ -0,0 +1,30 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var core_1 = require('angular2/core'); +var mock_heroes_1 = require('./mock-heroes'); +var HeroService = (function () { + function HeroService() { + } + HeroService.prototype.getHeroes = function () { + return Promise.resolve(mock_heroes_1.HEROES); + }; + HeroService.prototype.getHero = function (id) { + return Promise.resolve(mock_heroes_1.HEROES).then(function (heroes) { return heroes.filter(function (hero) { return hero.id === id; })[0]; }); + }; + HeroService = __decorate([ + core_1.Injectable() + ], HeroService); + return HeroService; +}()); +exports.HeroService = HeroService; +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ +//# sourceMappingURL=hero.service.js.map \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.service.js.map ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.service.js.map b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.service.js.map new file mode 100644 index 0000000..2485ba7 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.service.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hero.service.js","sourceRoot":"","sources":["hero.service.ts"],"names":[],"mappings":";;;;;;;AAAA,qBAAyB,eAAe,CAAC,CAAA;AACzC,4BAAyB,eAAe,CAAC,CAAA;AAGzC;IAAA;IAUA,CAAC;IATC,+BAAS,GAAT;QACE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,oBAAM,CAAC,CAAC;IACjC,CAAC;IAEF,6BAAO,GAAP,UAAQ,EAAU;QACf,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,oBAAM,CAAC,CAAC,IAAI,CACjC,UAAA,MAAM,IAAI,OAAA,MAAM,CAAC,MAAM,CAAC,UAAA,IAAI,IAAI,OAAA,IAAI,CAAC,EAAE,KAAK,EAAE,EAAd,CAAc,CAAC,CAAC,CAAC,CAAC,EAAxC,CAAwC,CACnD,CAAC;IACJ,CAAC;IAVH;QAAC,iBAAU,EAAE;mBAAA;IAWb,kBAAC;AAAD,CAAC,AAVD,IAUC;AAVY,mBAAW,cAUvB,CAAA;AAGD;;;;EAIE"} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.service.ts ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.service.ts b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.service.ts new file mode 100644 index 0000000..aee78a1 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.service.ts @@ -0,0 +1,22 @@ +import {Injectable} from 'angular2/core'; +import {HEROES} from './mock-heroes'; + +@Injectable() +export class HeroService { + getHeroes() { + return Promise.resolve(HEROES); + } + + getHero(id: number) { + return Promise.resolve(HEROES).then( + heroes => heroes.filter(hero => hero.id === id)[0] + ); + } +} + + +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.ts ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.ts b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.ts new file mode 100644 index 0000000..812726c --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/hero.ts @@ -0,0 +1,11 @@ +export class Hero { + id: number; + name: string; +} + + +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/heroes.component.css ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/heroes.component.css b/tools/generator-polygene/app/templates/Heroes/webapp/app/heroes.component.css new file mode 100644 index 0000000..98e7ecc --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/heroes.component.css @@ -0,0 +1,66 @@ +.selected { + background-color: #CFD8DC !important; + color: white; +} +.heroes { + margin: 0 0 2em 0; + list-style-type: none; + padding: 0; + width: 15em; +} +.heroes li { + cursor: pointer; + position: relative; + left: 0; + background-color: #EEE; + margin: .5em; + padding: .3em 0; + height: 1.6em; + border-radius: 4px; +} +.heroes li:hover { + color: #607D8B; + background-color: #DDD; + left: .1em; +} +.heroes li.selected:hover { + background-color: #BBD8DC !important; + color: white; +} +.heroes .text { + position: relative; + top: -3px; +} +.heroes .badge { + display: inline-block; + font-size: small; + color: white; + padding: 0.8em 0.7em 0 0.7em; + background-color: #607D8B; + line-height: 1em; + position: relative; + left: -1px; + top: -4px; + height: 1.8em; + margin-right: .8em; + border-radius: 4px 0 0 4px; +} +button { + font-family: Arial; + background-color: #eee; + border: none; + padding: 5px 10px; + border-radius: 4px; + cursor: pointer; + cursor: hand; +} +button:hover { + background-color: #cfd8dc; +} + + +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/heroes.component.html ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/heroes.component.html b/tools/generator-polygene/app/templates/Heroes/webapp/app/heroes.component.html new file mode 100644 index 0000000..0688e6a --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/heroes.component.html @@ -0,0 +1,21 @@ +<div> + <h2>My Heroes</h2> + <ul class="heroes"> + <li *ngFor="#hero of heroes" + [class.selected]="hero === selectedHero" + (click)="onSelect(hero)"> + <span class="badge">{{hero.id}}</span> {{hero.name}} + </li> + </ul> + <div *ngIf="selectedHero"> + <h2>{{selectedHero.name | uppercase}} is my hero</h2> + <button (click)="gotoDetail()">View Details</button> + </div> +</div> + + +<!-- +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +--> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/heroes.component.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/heroes.component.js b/tools/generator-polygene/app/templates/Heroes/webapp/app/heroes.component.js new file mode 100644 index 0000000..a4c1363 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/heroes.component.js @@ -0,0 +1,42 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var core_1 = require('angular2/core'); +var hero_detail_component_1 = require('./hero-detail.component'); +var HeroesComponent = (function () { + function HeroesComponent(_heroService, _router) { + this._heroService = _heroService; + this._router = _router; + } + HeroesComponent.prototype.getHeroes = function () { + var _this = this; + this._heroService.getHeroes().then(function (heroes) { return _this.heroes = heroes; }); + }; + HeroesComponent.prototype.gotoDetail = function () { + this._router.navigate(['HeroDetail', { id: this.selectedHero.id }]); + }; + HeroesComponent.prototype.ngOnInit = function () { + this.getHeroes(); + }; + HeroesComponent.prototype.onSelect = function (hero) { this.selectedHero = hero; }; + HeroesComponent = __decorate([ + core_1.Component({ + selector: 'my-heroes', + templateUrl: 'app/heroes.component.html', + styleUrls: ['app/heroes.component.css'], + directives: [hero_detail_component_1.HeroDetailComponent] + }) + ], HeroesComponent); + return HeroesComponent; +}()); +exports.HeroesComponent = HeroesComponent; +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ +//# sourceMappingURL=heroes.component.js.map \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/heroes.component.js.map ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/heroes.component.js.map b/tools/generator-polygene/app/templates/Heroes/webapp/app/heroes.component.js.map new file mode 100644 index 0000000..ca03d9d --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/heroes.component.js.map @@ -0,0 +1 @@ +{"version":3,"file":"heroes.component.js","sourceRoot":"","sources":["heroes.component.ts"],"names":[],"mappings":";;;;;;;AAAA,qBAAgC,eAAe,CAAC,CAAA;AAGhD,sCAAkC,yBAAyB,CAAC,CAAA;AAS5D;IAIE,yBAAoB,YAAyB,EAAU,OAAe;QAAlD,iBAAY,GAAZ,YAAY,CAAa;QAAU,YAAO,GAAP,OAAO,CAAQ;IAAI,CAAC;IAE3E,mCAAS,GAAT;QAAA,iBAEC;QADC,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,UAAA,MAAM,IAAI,OAAA,KAAI,CAAC,MAAM,GAAG,MAAM,EAApB,CAAoB,CAAC,CAAC;IACrE,CAAC;IAED,oCAAU,GAAV;QACE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,YAAY,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IACtE,CAAC;IAED,kCAAQ,GAAR;QACE,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAED,kCAAQ,GAAR,UAAS,IAAU,IAAI,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC;IAxBpD;QAAC,gBAAS,CAAC;YACT,QAAQ,EAAE,WAAW;YACrB,WAAW,EAAE,2BAA2B;YACxC,SAAS,EAAE,CAAC,0BAA0B,CAAC;YACvC,UAAU,EAAE,CAAC,2CAAmB,CAAC;SAClC,CAAC;uBAAA;IAoBF,sBAAC;AAAD,CAAC,AAnBD,IAmBC;AAnBY,uBAAe,kBAmB3B,CAAA;AAGD;;;;EAIE"} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/heroes.component.ts ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/heroes.component.ts b/tools/generator-polygene/app/templates/Heroes/webapp/app/heroes.component.ts new file mode 100644 index 0000000..0002025 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/heroes.component.ts @@ -0,0 +1,39 @@ +import {Component, OnInit} from 'angular2/core'; +import {Router} from 'angular2/router'; +import {HeroService} from './hero.service'; +import {HeroDetailComponent} from './hero-detail.component'; +import {Hero} from './hero'; + +@Component({ + selector: 'my-heroes', + templateUrl: 'app/heroes.component.html', + styleUrls: ['app/heroes.component.css'], + directives: [HeroDetailComponent] +}) +export class HeroesComponent implements OnInit { + heroes: Hero[]; + selectedHero: Hero; + + constructor(private _heroService: HeroService, private _router: Router) { } + + getHeroes() { + this._heroService.getHeroes().then(heroes => this.heroes = heroes); + } + + gotoDetail() { + this._router.navigate(['HeroDetail', { id: this.selectedHero.id }]); + } + + ngOnInit() { + this.getHeroes(); + } + + onSelect(hero: Hero) { this.selectedHero = hero; } +} + + +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/main.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/main.js b/tools/generator-polygene/app/templates/Heroes/webapp/app/main.js new file mode 100644 index 0000000..9b4c297 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/main.js @@ -0,0 +1,15 @@ +"use strict"; +var browser_1 = require('angular2/platform/browser'); +var router_1 = require('angular2/router'); +var hero_service_1 = require('./hero.service'); +var app_component_1 = require('./app.component'); +browser_1.bootstrap(app_component_1.AppComponent, [ + router_1.ROUTER_PROVIDERS, + hero_service_1.HeroService +]); +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ +//# sourceMappingURL=main.js.map \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/main.js.map ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/main.js.map b/tools/generator-polygene/app/templates/Heroes/webapp/app/main.js.map new file mode 100644 index 0000000..c830f42 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/main.js.map @@ -0,0 +1 @@ +{"version":3,"file":"main.js","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":";AAAA,wBAAwB,2BAA2B,CAAC,CAAA;AACpD,uBAA+B,iBAAiB,CAAC,CAAA;AACjD,6BAA0B,gBAAgB,CAAC,CAAA;AAC3C,8BAA2B,iBAAiB,CAAC,CAAA;AAE7C,mBAAS,CAAC,4BAAY,EAAE;IACtB,yBAAgB;IAChB,0BAAW;CACZ,CAAC,CAAC;AAGH;;;;EAIE"} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/main.ts ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/main.ts b/tools/generator-polygene/app/templates/Heroes/webapp/app/main.ts new file mode 100644 index 0000000..95e2d0b --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/main.ts @@ -0,0 +1,16 @@ +import {bootstrap} from 'angular2/platform/browser'; +import {ROUTER_PROVIDERS} from 'angular2/router'; +import {HeroService} from './hero.service'; +import {AppComponent} from './app.component'; + +bootstrap(AppComponent, [ + ROUTER_PROVIDERS, + HeroService +]); + + +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/mock-heroes.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/mock-heroes.js b/tools/generator-polygene/app/templates/Heroes/webapp/app/mock-heroes.js new file mode 100644 index 0000000..9fe1f8a --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/mock-heroes.js @@ -0,0 +1,19 @@ +"use strict"; +exports.HEROES = [ + { "id": 11, "name": "Mr. Nice" }, + { "id": 12, "name": "Narco" }, + { "id": 13, "name": "Bombasto" }, + { "id": 14, "name": "Celeritas" }, + { "id": 15, "name": "Magneta" }, + { "id": 16, "name": "RubberMan" }, + { "id": 17, "name": "Dynama" }, + { "id": 18, "name": "Dr IQ" }, + { "id": 19, "name": "Magma" }, + { "id": 20, "name": "Tornado" } +]; +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ +//# sourceMappingURL=mock-heroes.js.map \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/mock-heroes.js.map ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/mock-heroes.js.map b/tools/generator-polygene/app/templates/Heroes/webapp/app/mock-heroes.js.map new file mode 100644 index 0000000..dc81a97 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/mock-heroes.js.map @@ -0,0 +1 @@ +{"version":3,"file":"mock-heroes.js","sourceRoot":"","sources":["mock-heroes.ts"],"names":[],"mappings":";AAEW,cAAM,GAAW;IAC3B,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAC;IAC9B,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAC;IAC3B,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAC;IAC9B,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAC;IAC/B,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAC;IAC7B,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAC;IAC/B,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAC;IAC5B,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAC;IAC3B,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAC;IAC3B,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAC;CAC7B,CAAC;AAGF;;;;EAIE"} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/app/mock-heroes.ts ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/app/mock-heroes.ts b/tools/generator-polygene/app/templates/Heroes/webapp/app/mock-heroes.ts new file mode 100644 index 0000000..673cf53 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/app/mock-heroes.ts @@ -0,0 +1,21 @@ +import { Hero } from './hero'; + +export var HEROES: Hero[] = [ + {"id": 11, "name": "Mr. Nice"}, + {"id": 12, "name": "Narco"}, + {"id": 13, "name": "Bombasto"}, + {"id": 14, "name": "Celeritas"}, + {"id": 15, "name": "Magneta"}, + {"id": 16, "name": "RubberMan"}, + {"id": 17, "name": "Dynama"}, + {"id": 18, "name": "Dr IQ"}, + {"id": 19, "name": "Magma"}, + {"id": 20, "name": "Tornado"} +]; + + +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/index.html ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/index.html b/tools/generator-polygene/app/templates/Heroes/webapp/index.html new file mode 100644 index 0000000..753dd48 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/index.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<html> + <head> + <script>document.write('<base href="' + document.location + '" />');</script> + <title>Angular 2 Tour of Heroes</title> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel="stylesheet" href="styles.css"> + + <!-- IE required polyfills, in this exact order --> + <script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.0/es6-shim.min.js"></script> + <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.26/system-polyfills.js"></script> + <script src="https://npmcdn.com/[email protected]/es6/dev/src/testing/shims_for_IE.js"></script> + + <script src="https://code.angularjs.org/2.0.0-beta.15/angular2-polyfills.js"></script> + <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.26/system.js"></script> + <script src="https://npmcdn.com/[email protected]/lib/typescript.js"></script> + <script src="https://code.angularjs.org/2.0.0-beta.15/Rx.js"></script> + <script src="https://code.angularjs.org/2.0.0-beta.15/angular2.dev.js"></script> + <script src="https://code.angularjs.org/2.0.0-beta.15/router.dev.js"></script> + <script> + System.config({ + transpiler: 'typescript', + typescriptOptions: { emitDecoratorMetadata: true }, + packages: {'app': {defaultExtension: 'ts'}} + }); + System.import('app/main') + .then(null, console.error.bind(console)); + </script> + </head> + + <body> + <my-app>Loading...</my-app> + </body> +</html> + + +<!-- +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +--> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/Heroes/webapp/styles.css ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/Heroes/webapp/styles.css b/tools/generator-polygene/app/templates/Heroes/webapp/styles.css new file mode 100644 index 0000000..1774fd6 --- /dev/null +++ b/tools/generator-polygene/app/templates/Heroes/webapp/styles.css @@ -0,0 +1,149 @@ +/* Master Styles */ +h1 { + color: #369; + font-family: Arial, Helvetica, sans-serif; + font-size: 250%; +} +h2, h3 { + color: #444; + font-family: Arial, Helvetica, sans-serif; + font-weight: lighter; +} +body { + margin: 2em; +} +body, input[text], button { + color: #888; + font-family: Cambria, Georgia; +} +a { + cursor: pointer; + cursor: hand; +} +button { + font-family: Arial; + background-color: #eee; + border: none; + padding: 5px 10px; + border-radius: 4px; + cursor: pointer; + cursor: hand; +} +button:hover { + background-color: #cfd8dc; +} +button:disabled { + background-color: #eee; + color: #aaa; + cursor: auto; +} + +/* Navigation link styles */ +nav a { + padding: 5px 10px; + text-decoration: none; + margin-top: 10px; + display: inline-block; + background-color: #eee; + border-radius: 4px; +} +nav a:visited, a:link { + color: #607D8B; +} +nav a:hover { + color: #039be5; + background-color: #CFD8DC; +} +nav a.router-link-active { + color: #039be5; +} + +/* items class */ +.items { + margin: 0 0 2em 0; + list-style-type: none; + padding: 0; + width: 24em; +} +.items li { + cursor: pointer; + position: relative; + left: 0; + background-color: #EEE; + margin: .5em; + padding: .3em 0; + height: 1.6em; + border-radius: 4px; +} +.items li:hover { + color: #607D8B; + background-color: #DDD; + left: .1em; +} +.items li.selected:hover { + background-color: #BBD8DC; + color: white; +} +.items .text { + position: relative; + top: -3px; +} +.items { + margin: 0 0 2em 0; + list-style-type: none; + padding: 0; + width: 24em; +} +.items li { + cursor: pointer; + position: relative; + left: 0; + background-color: #EEE; + margin: .5em; + padding: .3em 0; + height: 1.6em; + border-radius: 4px; +} +.items li:hover { + color: #607D8B; + background-color: #DDD; + left: .1em; +} +.items li.selected { + background-color: #CFD8DC; + color: white; +} + +.items li.selected:hover { + background-color: #BBD8DC; +} +.items .text { + position: relative; + top: -3px; +} +.items .badge { + display: inline-block; + font-size: small; + color: white; + padding: 0.8em 0.7em 0 0.7em; + background-color: #607D8B; + line-height: 1em; + position: relative; + left: -1px; + top: -4px; + height: 1.8em; + margin-right: .8em; + border-radius: 4px 0 0 4px; +} + +/* everywhere else */ +* { + font-family: Arial, Helvetica, sans-serif; +} + + +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/InfrastructureLayer/bootstrap.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/InfrastructureLayer/bootstrap.tmpl b/tools/generator-polygene/app/templates/InfrastructureLayer/bootstrap.tmpl new file mode 100644 index 0000000..a1206a9 --- /dev/null +++ b/tools/generator-polygene/app/templates/InfrastructureLayer/bootstrap.tmpl @@ -0,0 +1,55 @@ +<%# + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * +-%> +package <%= packageName %>.bootstrap.infrastructure; + +import java.util.function.Function; +import org.apache.polygene.api.structure.Application; +import org.apache.polygene.api.structure.Module; +import org.apache.polygene.bootstrap.AssemblyException; +import org.apache.polygene.bootstrap.LayerAssembly; +import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.bootstrap.layered.LayerAssembler; +import org.apache.polygene.bootstrap.layered.LayeredLayerAssembler; + +public class InfrastructureLayer extends LayeredLayerAssembler + implements LayerAssembler +{ + public static final String NAME = "Infrastructure Layer"; + private final ModuleAssembly configModule; + private final Function<Application, Module> typeFinder; + + public InfrastructureLayer( ModuleAssembly configModule, Function<Application, Module> typeFinder ) + { + this.configModule = configModule; + this.typeFinder = typeFinder; + } + + @Override + public LayerAssembly assemble( LayerAssembly layer ) + throws AssemblyException + { + createModule( layer, FileConfigurationModule.class ); + + new <%= polygene.entitystore %>StorageModule( configModule ).assemble( layer, layer.module( <%= polygene.entitystore %>StorageModule.NAME ) ); + new <%= polygene.indexing %>IndexingModule( configModule ).assemble( layer, layer.module( <%= polygene.indexing %>IndexingModule.NAME ) ); + new <%= polygene.serialization %>SerializationModule( typeFinder ).assemble( layer, layer.module( <%= polygene.serialization %>SerializationModule.NAME ) ); + return layer; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/JacksonSerializationModule/bootstrap.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/JacksonSerializationModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/JacksonSerializationModule/bootstrap.tmpl new file mode 100644 index 0000000..dd1d17c --- /dev/null +++ b/tools/generator-polygene/app/templates/JacksonSerializationModule/bootstrap.tmpl @@ -0,0 +1,53 @@ +<%# + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * +-%> +package <%= packageName %>.bootstrap.infrastructure; + +import java.util.function.Function; +import org.apache.polygene.api.common.Visibility; +import org.apache.polygene.api.structure.Application; +import org.apache.polygene.api.structure.Module; +import org.apache.polygene.bootstrap.AssemblyException; +import org.apache.polygene.bootstrap.LayerAssembly; +import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.bootstrap.layered.ModuleAssembler; +import org.apache.polygene.valueserialization.jackson.JacksonValueSerializationAssembler; + +public class JacksonSerializationModule + implements ModuleAssembler +{ + public static final String NAME = "Jackson Serialization Module"; + private final Function<Application, Module> typeFinder; + + public JacksonSerializationModule( Function<Application, Module> typeFinder ) + { + this.typeFinder = typeFinder; + } + + @Override + public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module ) + throws AssemblyException + { + new JacksonValueSerializationAssembler() + .visibleIn( Visibility.application ) + .withValuesModuleFinder( typeFinder ) + .assemble( module ); + return module; + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/NoCachingModule/bootstrap.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/NoCachingModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/NoCachingModule/bootstrap.tmpl new file mode 100644 index 0000000..b5ebe24 --- /dev/null +++ b/tools/generator-polygene/app/templates/NoCachingModule/bootstrap.tmpl @@ -0,0 +1,46 @@ +<%# + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * +-%> +package <%= packageName %>.bootstrap.infrastructure; + +import org.apache.polygene.api.common.Visibility; +import org.apache.polygene.bootstrap.AssemblyException; +import org.apache.polygene.bootstrap.LayerAssembly; +import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.bootstrap.layered.ModuleAssembler; +import org.apache.polygene.entitystore.file.assembly.FileEntityStoreAssembler; + +public class NoCachingModule + implements ModuleAssembler +{ + public static final String NAME = "No Caching Module"; + private final ModuleAssembly configModule; + + public NoCachingModule( ModuleAssembly configModule ) + { + this.configModule = configModule; + } + + @Override + public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module ) + throws AssemblyException + { + return module; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/RDFIndexingModule/bootstrap.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/RDFIndexingModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/RDFIndexingModule/bootstrap.tmpl new file mode 100644 index 0000000..8376a2b --- /dev/null +++ b/tools/generator-polygene/app/templates/RDFIndexingModule/bootstrap.tmpl @@ -0,0 +1,50 @@ +<%# + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * +-%> +package <%= packageName %>.bootstrap.infrastructure; + +import org.apache.polygene.api.common.Visibility; +import org.apache.polygene.bootstrap.AssemblyException; +import org.apache.polygene.bootstrap.LayerAssembly; +import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.bootstrap.layered.ModuleAssembler; +import org.apache.polygene.index.rdf.assembly.RdfNativeSesameStoreAssembler; +import org.apache.polygene.library.rdf.repository.NativeConfiguration; + +public class RdfIndexingModule + implements ModuleAssembler +{ + public static final String NAME = "Rdf Indexing Module"; + private final ModuleAssembly configModule; + + public RdfIndexingModule( ModuleAssembly configModule ) + { + this.configModule = configModule; + } + + @Override + public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module ) + throws AssemblyException + { + configModule.entities( NativeConfiguration.class ).visibleIn( Visibility.application ); + new RdfNativeSesameStoreAssembler(Visibility.application, Visibility.module).assemble( module ); + return module; + } +} + http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/RestApiModule/HardcodedSecurityRepositoryMixin.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/RestApiModule/HardcodedSecurityRepositoryMixin.tmpl b/tools/generator-polygene/app/templates/RestApiModule/HardcodedSecurityRepositoryMixin.tmpl new file mode 100644 index 0000000..fc73bf6 --- /dev/null +++ b/tools/generator-polygene/app/templates/RestApiModule/HardcodedSecurityRepositoryMixin.tmpl @@ -0,0 +1,54 @@ +<%# + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * +-%> +package <%= packageName %>.model.security; + +import java.util.Collections; +import java.util.List; +import org.apache.polygene.api.unitofwork.concern.UnitOfWorkPropagation; + +public class HardcodedSecurityRepositoryMixin + implements SecurityRepository +{ + + @Override + public boolean verifyPassword( String userName, String password ) + { + if( userName.equals("admin") && password.equals("secret") ) + { + return true; + } + if( userName.equals("user") && password.equals("123") ) + { + return true; + } + return false; + } + + @UnitOfWorkPropagation + public List<String> findRoleNamesOfUser( String name ) + { + if( "admin".equals( name ) ) + { + return Collections.singletonList("admin"); + } + return Collections.singletonList("user"); + } +} + http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/RestApiModule/SecurityRepository.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/RestApiModule/SecurityRepository.tmpl b/tools/generator-polygene/app/templates/RestApiModule/SecurityRepository.tmpl new file mode 100644 index 0000000..f007485 --- /dev/null +++ b/tools/generator-polygene/app/templates/RestApiModule/SecurityRepository.tmpl @@ -0,0 +1,36 @@ +<%# + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * +-%> +package <%= packageName %>.model.security; + +import java.util.List; +import org.apache.polygene.api.concern.Concerns; +import org.apache.polygene.api.unitofwork.concern.UnitOfWorkConcern; +import org.apache.polygene.api.unitofwork.concern.UnitOfWorkPropagation; + +@Concerns( UnitOfWorkConcern.class ) +public interface SecurityRepository +{ + @UnitOfWorkPropagation + boolean verifyPassword( String user, String password ); + + @UnitOfWorkPropagation + List<String> findRoleNamesOfUser( String name ); +} + http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/RestApiModule/SimpleEnroler.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/RestApiModule/SimpleEnroler.tmpl b/tools/generator-polygene/app/templates/RestApiModule/SimpleEnroler.tmpl new file mode 100644 index 0000000..3b21a9d --- /dev/null +++ b/tools/generator-polygene/app/templates/RestApiModule/SimpleEnroler.tmpl @@ -0,0 +1,52 @@ +<%# + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * +-%> +package <%= packageName %>.rest.security; + +import java.util.ArrayList; +import java.util.List; +import org.apache.polygene.api.injection.scope.Service; +import org.apache.polygene.api.injection.scope.Uses; +import org.restlet.Application; +import org.restlet.data.ClientInfo; +import org.restlet.security.Enroler; +import org.restlet.security.Role; +import <%= packageName %>.model.security.SecurityRepository; + + +public class SimpleEnroler + implements Enroler +{ + @Service + private SecurityRepository repository; + + @Uses + private Application application; + + @Override + public void enrole( ClientInfo clientInfo ) + { + org.restlet.security.User user = clientInfo.getUser(); + String name = user.getName(); + List<String> roleList = repository.findRoleNamesOfUser( name ); + List<Role> restletRoles = new ArrayList<>(); + roleList.stream().map( roleName -> Role.get( application, roleName ) ); + clientInfo.setRoles( restletRoles ); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/RestApiModule/SimpleVerifier.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/RestApiModule/SimpleVerifier.tmpl b/tools/generator-polygene/app/templates/RestApiModule/SimpleVerifier.tmpl new file mode 100644 index 0000000..e8b7e11 --- /dev/null +++ b/tools/generator-polygene/app/templates/RestApiModule/SimpleVerifier.tmpl @@ -0,0 +1,46 @@ +<%# + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * +-%> +package <%= packageName %>.rest.security; + +import org.apache.polygene.api.injection.scope.Service; +import org.restlet.security.SecretVerifier; +import org.restlet.security.Verifier; +import <%= packageName %>.model.security.SecurityRepository; + +public class SimpleVerifier extends SecretVerifier + implements Verifier +{ + @Service + private SecurityRepository repository; + + @Override + public int verify( String user, char[] secret ) + { + if( user == null || secret == null ) + { + return RESULT_UNKNOWN; + } + if( repository.verifyPassword( user, String.valueOf( secret ) ) ) + { + return RESULT_VALID; + } + return RESULT_INVALID; + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/RestApiModule/bootstrap.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/RestApiModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/RestApiModule/bootstrap.tmpl new file mode 100644 index 0000000..202776d --- /dev/null +++ b/tools/generator-polygene/app/templates/RestApiModule/bootstrap.tmpl @@ -0,0 +1,56 @@ +<%# + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * +-%> +package <%= packageName %>.bootstrap.connectivity; + +import <%= packageName %>.rest.security.SimpleEnroler; +import <%= packageName %>.rest.security.SimpleVerifier; +import org.apache.polygene.bootstrap.AssemblyException; +import org.apache.polygene.bootstrap.LayerAssembly; +import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.bootstrap.layered.ModuleAssembler; +import org.apache.polygene.library.restlet.assembly.RestletCrudConnectivityAssembler; +import org.apache.polygene.library.restlet.resource.EntryPoint; +<% if( hasFeature('sample (heroes) web application') ) { %> +import <%= packageName %>.model.heroes.Hero; +<% } -%> + +public class RestApiModule + implements ModuleAssembler +{ + public static String NAME; + + @Override + public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module ) + throws AssemblyException + { + module.objects( SimpleVerifier.class, SimpleEnroler.class); + + new RestletCrudConnectivityAssembler().assemble( module ); + module.values( EntryPoint.class ); +<% if( hasFeature('sample (heroes) web application') ) { -%> + module.values( Hero.class ); + module.services( Hero.class ); +<% } else { -%> + module.values( /* add value types */ ); + module.services( /* add services */ ); +<% } -%> + return module; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/SecurityModule/HardcodedSecurityRepositoryMixin.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/SecurityModule/HardcodedSecurityRepositoryMixin.tmpl b/tools/generator-polygene/app/templates/SecurityModule/HardcodedSecurityRepositoryMixin.tmpl new file mode 100644 index 0000000..91c66e6 --- /dev/null +++ b/tools/generator-polygene/app/templates/SecurityModule/HardcodedSecurityRepositoryMixin.tmpl @@ -0,0 +1,51 @@ +<%# + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * +-%> +package <%= packageName %>.model.security; + +import java.util.Collections; +import java.util.List; +import org.apache.polygene.api.unitofwork.concern.UnitOfWorkPropagation; + +public class HardcodedSecurityRepositoryMixin + implements SecurityRepository +{ + + @Override + public boolean verifyPassword( String userName, String password ) + { + if( userName.equals("admin") && password.equals("secret") ) { + return true; + } + if( userName.equals("user") && password.equals("123") ) { + return true; + } + return false; + } + + @UnitOfWorkPropagation + public List<String> findRoleNamesOfUser( String name ) + { + if( "admin".equals( name ) ) + { + return Collections.singletonList("admin"); + } + return Collections.singletonList("user"); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/SecurityModule/SecurityRepository.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/SecurityModule/SecurityRepository.tmpl b/tools/generator-polygene/app/templates/SecurityModule/SecurityRepository.tmpl new file mode 100644 index 0000000..c503999 --- /dev/null +++ b/tools/generator-polygene/app/templates/SecurityModule/SecurityRepository.tmpl @@ -0,0 +1,35 @@ +<%# + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * +-%> +package <%= packageName %>.model.security; + +import java.util.List; +import org.apache.polygene.api.concern.Concerns; +import org.apache.polygene.api.unitofwork.concern.UnitOfWorkConcern; +import org.apache.polygene.api.unitofwork.concern.UnitOfWorkPropagation; + +@Concerns( UnitOfWorkConcern.class ) +public interface SecurityRepository +{ + @UnitOfWorkPropagation + boolean verifyPassword( String user, String password ); + + @UnitOfWorkPropagation + List<String> findRoleNamesOfUser( String name ); +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/SecurityModule/bootstrap.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/SecurityModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/SecurityModule/bootstrap.tmpl new file mode 100644 index 0000000..b944612 --- /dev/null +++ b/tools/generator-polygene/app/templates/SecurityModule/bootstrap.tmpl @@ -0,0 +1,46 @@ +<%# + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * +-%> +package <%= packageName %>.bootstrap.domain; + +import org.apache.polygene.api.common.Visibility; +import org.apache.polygene.bootstrap.AssemblyException; +import org.apache.polygene.bootstrap.LayerAssembly; +import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.bootstrap.layered.ModuleAssembler; +import <%= packageName %>.model.security.SecurityRepository; +import <%= packageName %>.model.security.HardcodedSecurityRepositoryMixin; + +public class SecurityModule + implements ModuleAssembler +{ + public static String NAME; + + @Override + public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module ) + throws AssemblyException + { + module.services( SecurityRepository.class ) + .withMixins( HardcodedSecurityRepositoryMixin.class ) + .visibleIn( Visibility.application ) + .instantiateOnStartup(); + + return module; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/StorageModule/bootstrap.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/StorageModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/StorageModule/bootstrap.tmpl new file mode 100644 index 0000000..467fadd --- /dev/null +++ b/tools/generator-polygene/app/templates/StorageModule/bootstrap.tmpl @@ -0,0 +1,51 @@ +<%# + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * +-%> +package <%= packageName %>.bootstrap.infrastructure; + +import org.apache.polygene.api.common.Visibility; +import org.apache.polygene.bootstrap.AssemblyException; +import org.apache.polygene.bootstrap.LayerAssembly; +import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.bootstrap.layered.ModuleAssembler; +import org.apache.polygene.entitystore.<%- polygene.entitystore.toLowerCase() %>.assembly.<%- polygene.entitystore %>EntityStoreAssembler; + +public class <%- polygene.entitystore %>StorageModule + implements ModuleAssembler +{ + public static final String NAME = "<%- polygene.entitystore %> Storage Module"; + private final ModuleAssembly configModule; + + public <%- polygene.entitystore %>StorageModule( ModuleAssembly configModule ) + { + this.configModule = configModule; + } + + @Override + public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module ) + throws AssemblyException + { + new <%- polygene.entitystore %>EntityStoreAssembler() + .visibleIn( Visibility.application ) + .withConfig( configModule, Visibility.application ) + .identifiedBy( "<%- polygene.entitystore %>store" ) + .assemble( module ); + return module; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/generator-polygene/app/templates/buildtool/gradle-app.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/buildtool/gradle-app.tmpl b/tools/generator-polygene/app/templates/buildtool/gradle-app.tmpl new file mode 100644 index 0000000..f307e8b --- /dev/null +++ b/tools/generator-polygene/app/templates/buildtool/gradle-app.tmpl @@ -0,0 +1,41 @@ +<%# + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * +-%> + +plugins { + id 'war' + id "org.akhikhl.gretty" version "1.4.0" +} + +dependencies { + compile project( ":bootstrap" ) + compile project( ":model" ) + compile project( ":rest" ) + + compile "org.apache.polygene.core:org.apache.polygene.core.spi:$polygeneVersion" + compile "org.apache.polygene.core:org.apache.polygene.core.bootstrap:$polygeneVersion" + compile "org.apache.polygene.library:org.apache.polygene.library.servlet:$polygeneVersion" + + compile "javax.servlet:servlet-api:2.5" + compile "org.restlet.jee:org.restlet:2.3.4" + + runtime "org.apache.polygene.core:org.apache.polygene.core.runtime:$polygeneVersion" + runtime "org.restlet.jee:org.restlet.ext.servlet:2.3.4" + +}
