Skip to content

Instantly share code, notes, and snippets.

View sebastienblanc's full-sized avatar

Sebastien Blanc sebastienblanc

View GitHub Profile
"use strict";
scaffoldtester.factory( "dataService", function() {
return {
customerPipe: AeroGear.Pipeline({
name: "customers",
settings: {
baseURL: "rest/"
}
}).pipes.customers,
$scope.save = function() {
$scope.customer.$update(function(){
$scope.get();
});
};
self.original = data;
customerStore.save(data);
var customer = customerStore.read(parseInt($routeParams.CustomerId))[0];
$scope.customer = customer;
//are self.original and $scope.customer tyhe same object ?
new-project --named scaffoldagtesters;
persistence setup --provider HIBERNATE --container JBOSS_AS7;
validation setup --provider JAVA_EE;
entity --named Customer;
field string --named firstName;
field temporal --type DATE --named dateOfBirth;
entity --named DiscountVoucher;
field string --named voucherCode;
entity --named StoreOrder;
field string --named product;

1. Install Forge

Instructions can be found here : http://forge.jboss.org/docs/using/

2. Create a Forge script

To go faster and avoid typing too much commands you can use a forge script, copy/paste the following in a text file and save it as scaffold.fsh (or whatever name you want)

new-project --named scaffoldtester;
persistence setup --provider HIBERNATE --container JBOSS_AS7;
validation setup --provider JAVA_EE;
AeroGear.Notifier.addChannel(String channel);
AeroGear.Notifier.myChannel.onMessage(data);
AeroGear.Notifier.myChannel.publishMessage(data);
/this code is inside a module script, I want to copy the resources folder from the module to the web folder of the project
vertx.fileSystem.copy("mods/org.aerogear.vertxgo-v0.1/resources", "web",true) { ar ->
if (ar.succeeded()) {
log.info("Copy was successful")
} else {
log.error("Failed to copy", ar.exception)
}
}

This is my route :

route().from("/customers/{id}")
.on(RequestMethod.GET)
.consumes(JSON).produces(JSON)
.to(CustomerEndpoint.class)
.findById(Long.parseLong(param("id"));

This the method of my endpoint :

class Routes extends AbstractRoutingModule
{
void configuration()
{
route() from "/customers" on RequestMethod.GET consumes JSON produces JSON to CustomerEndpoint.class listAll()
}
}
route().from("/customers").on(RequestMethod.GET).consumes(JSON).produces(JSON).to(CustomerEndpoint.class).listAll();
route().from("/customers").on(RequestMethod.POST).consumes(JSON).produces(JSON).to(CustomerEndpoint.class).create(param(Customer.class));
route().from("/customers/{id}").on(RequestMethod.DELETE).consumes(JSON).produces(JSON).to(CustomerEndpoint.class).deleteById(param("id", Long.class));
route().from("/customers/{id}").on(RequestMethod.GET).consumes(JSON).produces(JSON).to(CustomerEndpoint.class).findById(param("id", Long.class));
route().from("/customers/{id}").on(RequestMethod.PUT).consumes(JSON).produces(JSON).to(CustomerEndpoint.class).update(param("id", Long.class), param(Customer.class));
route().from("/discountvouchers").on(RequestMethod.GET).consumes(JSON).produces(JSON).to(DiscountVoucherEndpoint.class).listAll();
route().from("/discountvouchers").on(RequestMethod.POST).consumes(JSON).produces(JSON).to(DiscountVoucherEndpoint.class).create(par