repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResource.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/ActivateOrderCommand.java
// public class ActivateOrderCommand extends Command {
//
// public final OrderId orderId;
//
// public ActivateOrderCommand(OrderId orderId) {
// checkArgument(orderId != null, "OrderId cannot be null");
// this.orderId = orderId;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java
// public class CommandFactory {
//
// public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
// List<OrderLine> itemsToOrder = getOrderLines(request.cart);
// CustomerInformation customerInformation = getCustomerInformation(request);
// long totalPrice = request.cart.totalPrice;
// return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice);
// }
//
// public ActivateOrderCommand toCommand(ActivateOrderRequest request) {
// return new ActivateOrderCommand(new OrderId(request.orderId));
// }
//
// private List<OrderLine> getOrderLines(CartDto cart) {
// List<OrderLine> itemsToOrder = new ArrayList<>();
// for (LineItemDto lineItem : cart.lineItems) {
// ProductId productId = new ProductId(lineItem.productId);
// String title = lineItem.title;
// int quantity = lineItem.quantity;
// long price = lineItem.price;
// itemsToOrder.add(new OrderLine(productId, title, quantity, price));
// }
// return itemsToOrder;
// }
//
// private CustomerInformation getCustomerInformation(PlaceOrderRequest request) {
// return new CustomerInformation(request.customerName, request.customerEmail, request.customerAddress);
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/PlaceOrderCommand.java
// public class PlaceOrderCommand extends Command {
//
// public final OrderId orderId;
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long totalAmount;
//
// public PlaceOrderCommand(OrderId orderId, CustomerInformation customerInformation, List<OrderLine> orderLines, long totalAmount) {
// checkArgument(orderId != null, "OrderId cannot be null");
// checkArgument(customerInformation != null, "CustomerInformation cannot be null");
// checkArgument(orderLines != null, "Items cannot be null");
// checkArgument(!orderLines.isEmpty(), "Item list cannot be empty");
// checkArgument(totalAmount > 0, "Total amount must be > 0");
// this.orderId = orderId;
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.totalAmount = totalAmount;
// }
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.command.ActivateOrderCommand;
import se.citerus.cqrs.bookstore.ordercontext.order.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.order.command.PlaceOrderCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("order-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class OrderResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final CommandBus commandBus;
private final CommandFactory commandFactory = new CommandFactory();
public OrderResource(CommandBus commandBus) {
this.commandBus = commandBus;
}
@POST
public void placeOrder(@Valid PlaceOrderRequest placeOrderRequest) {
logger.info("Placing customer order: " + placeOrderRequest); | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/ActivateOrderCommand.java
// public class ActivateOrderCommand extends Command {
//
// public final OrderId orderId;
//
// public ActivateOrderCommand(OrderId orderId) {
// checkArgument(orderId != null, "OrderId cannot be null");
// this.orderId = orderId;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java
// public class CommandFactory {
//
// public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
// List<OrderLine> itemsToOrder = getOrderLines(request.cart);
// CustomerInformation customerInformation = getCustomerInformation(request);
// long totalPrice = request.cart.totalPrice;
// return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice);
// }
//
// public ActivateOrderCommand toCommand(ActivateOrderRequest request) {
// return new ActivateOrderCommand(new OrderId(request.orderId));
// }
//
// private List<OrderLine> getOrderLines(CartDto cart) {
// List<OrderLine> itemsToOrder = new ArrayList<>();
// for (LineItemDto lineItem : cart.lineItems) {
// ProductId productId = new ProductId(lineItem.productId);
// String title = lineItem.title;
// int quantity = lineItem.quantity;
// long price = lineItem.price;
// itemsToOrder.add(new OrderLine(productId, title, quantity, price));
// }
// return itemsToOrder;
// }
//
// private CustomerInformation getCustomerInformation(PlaceOrderRequest request) {
// return new CustomerInformation(request.customerName, request.customerEmail, request.customerAddress);
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/PlaceOrderCommand.java
// public class PlaceOrderCommand extends Command {
//
// public final OrderId orderId;
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long totalAmount;
//
// public PlaceOrderCommand(OrderId orderId, CustomerInformation customerInformation, List<OrderLine> orderLines, long totalAmount) {
// checkArgument(orderId != null, "OrderId cannot be null");
// checkArgument(customerInformation != null, "CustomerInformation cannot be null");
// checkArgument(orderLines != null, "Items cannot be null");
// checkArgument(!orderLines.isEmpty(), "Item list cannot be empty");
// checkArgument(totalAmount > 0, "Total amount must be > 0");
// this.orderId = orderId;
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.totalAmount = totalAmount;
// }
//
// }
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResource.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.command.ActivateOrderCommand;
import se.citerus.cqrs.bookstore.ordercontext.order.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.order.command.PlaceOrderCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("order-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class OrderResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final CommandBus commandBus;
private final CommandFactory commandFactory = new CommandFactory();
public OrderResource(CommandBus commandBus) {
this.commandBus = commandBus;
}
@POST
public void placeOrder(@Valid PlaceOrderRequest placeOrderRequest) {
logger.info("Placing customer order: " + placeOrderRequest); | PlaceOrderCommand placeOrderCommand = commandFactory.toCommand(placeOrderRequest); |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResource.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/ActivateOrderCommand.java
// public class ActivateOrderCommand extends Command {
//
// public final OrderId orderId;
//
// public ActivateOrderCommand(OrderId orderId) {
// checkArgument(orderId != null, "OrderId cannot be null");
// this.orderId = orderId;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java
// public class CommandFactory {
//
// public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
// List<OrderLine> itemsToOrder = getOrderLines(request.cart);
// CustomerInformation customerInformation = getCustomerInformation(request);
// long totalPrice = request.cart.totalPrice;
// return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice);
// }
//
// public ActivateOrderCommand toCommand(ActivateOrderRequest request) {
// return new ActivateOrderCommand(new OrderId(request.orderId));
// }
//
// private List<OrderLine> getOrderLines(CartDto cart) {
// List<OrderLine> itemsToOrder = new ArrayList<>();
// for (LineItemDto lineItem : cart.lineItems) {
// ProductId productId = new ProductId(lineItem.productId);
// String title = lineItem.title;
// int quantity = lineItem.quantity;
// long price = lineItem.price;
// itemsToOrder.add(new OrderLine(productId, title, quantity, price));
// }
// return itemsToOrder;
// }
//
// private CustomerInformation getCustomerInformation(PlaceOrderRequest request) {
// return new CustomerInformation(request.customerName, request.customerEmail, request.customerAddress);
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/PlaceOrderCommand.java
// public class PlaceOrderCommand extends Command {
//
// public final OrderId orderId;
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long totalAmount;
//
// public PlaceOrderCommand(OrderId orderId, CustomerInformation customerInformation, List<OrderLine> orderLines, long totalAmount) {
// checkArgument(orderId != null, "OrderId cannot be null");
// checkArgument(customerInformation != null, "CustomerInformation cannot be null");
// checkArgument(orderLines != null, "Items cannot be null");
// checkArgument(!orderLines.isEmpty(), "Item list cannot be empty");
// checkArgument(totalAmount > 0, "Total amount must be > 0");
// this.orderId = orderId;
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.totalAmount = totalAmount;
// }
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.command.ActivateOrderCommand;
import se.citerus.cqrs.bookstore.ordercontext.order.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.order.command.PlaceOrderCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("order-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class OrderResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final CommandBus commandBus;
private final CommandFactory commandFactory = new CommandFactory();
public OrderResource(CommandBus commandBus) {
this.commandBus = commandBus;
}
@POST
public void placeOrder(@Valid PlaceOrderRequest placeOrderRequest) {
logger.info("Placing customer order: " + placeOrderRequest);
PlaceOrderCommand placeOrderCommand = commandFactory.toCommand(placeOrderRequest);
commandBus.dispatch(placeOrderCommand);
}
@POST
@Path("activations") | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/ActivateOrderCommand.java
// public class ActivateOrderCommand extends Command {
//
// public final OrderId orderId;
//
// public ActivateOrderCommand(OrderId orderId) {
// checkArgument(orderId != null, "OrderId cannot be null");
// this.orderId = orderId;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java
// public class CommandFactory {
//
// public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
// List<OrderLine> itemsToOrder = getOrderLines(request.cart);
// CustomerInformation customerInformation = getCustomerInformation(request);
// long totalPrice = request.cart.totalPrice;
// return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice);
// }
//
// public ActivateOrderCommand toCommand(ActivateOrderRequest request) {
// return new ActivateOrderCommand(new OrderId(request.orderId));
// }
//
// private List<OrderLine> getOrderLines(CartDto cart) {
// List<OrderLine> itemsToOrder = new ArrayList<>();
// for (LineItemDto lineItem : cart.lineItems) {
// ProductId productId = new ProductId(lineItem.productId);
// String title = lineItem.title;
// int quantity = lineItem.quantity;
// long price = lineItem.price;
// itemsToOrder.add(new OrderLine(productId, title, quantity, price));
// }
// return itemsToOrder;
// }
//
// private CustomerInformation getCustomerInformation(PlaceOrderRequest request) {
// return new CustomerInformation(request.customerName, request.customerEmail, request.customerAddress);
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/PlaceOrderCommand.java
// public class PlaceOrderCommand extends Command {
//
// public final OrderId orderId;
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long totalAmount;
//
// public PlaceOrderCommand(OrderId orderId, CustomerInformation customerInformation, List<OrderLine> orderLines, long totalAmount) {
// checkArgument(orderId != null, "OrderId cannot be null");
// checkArgument(customerInformation != null, "CustomerInformation cannot be null");
// checkArgument(orderLines != null, "Items cannot be null");
// checkArgument(!orderLines.isEmpty(), "Item list cannot be empty");
// checkArgument(totalAmount > 0, "Total amount must be > 0");
// this.orderId = orderId;
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.totalAmount = totalAmount;
// }
//
// }
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResource.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.command.ActivateOrderCommand;
import se.citerus.cqrs.bookstore.ordercontext.order.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.order.command.PlaceOrderCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("order-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class OrderResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final CommandBus commandBus;
private final CommandFactory commandFactory = new CommandFactory();
public OrderResource(CommandBus commandBus) {
this.commandBus = commandBus;
}
@POST
public void placeOrder(@Valid PlaceOrderRequest placeOrderRequest) {
logger.info("Placing customer order: " + placeOrderRequest);
PlaceOrderCommand placeOrderCommand = commandFactory.toCommand(placeOrderRequest);
commandBus.dispatch(placeOrderCommand);
}
@POST
@Path("activations") | public void activateOrder(@Valid ActivateOrderRequest activationRequest) { |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResource.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/ActivateOrderCommand.java
// public class ActivateOrderCommand extends Command {
//
// public final OrderId orderId;
//
// public ActivateOrderCommand(OrderId orderId) {
// checkArgument(orderId != null, "OrderId cannot be null");
// this.orderId = orderId;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java
// public class CommandFactory {
//
// public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
// List<OrderLine> itemsToOrder = getOrderLines(request.cart);
// CustomerInformation customerInformation = getCustomerInformation(request);
// long totalPrice = request.cart.totalPrice;
// return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice);
// }
//
// public ActivateOrderCommand toCommand(ActivateOrderRequest request) {
// return new ActivateOrderCommand(new OrderId(request.orderId));
// }
//
// private List<OrderLine> getOrderLines(CartDto cart) {
// List<OrderLine> itemsToOrder = new ArrayList<>();
// for (LineItemDto lineItem : cart.lineItems) {
// ProductId productId = new ProductId(lineItem.productId);
// String title = lineItem.title;
// int quantity = lineItem.quantity;
// long price = lineItem.price;
// itemsToOrder.add(new OrderLine(productId, title, quantity, price));
// }
// return itemsToOrder;
// }
//
// private CustomerInformation getCustomerInformation(PlaceOrderRequest request) {
// return new CustomerInformation(request.customerName, request.customerEmail, request.customerAddress);
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/PlaceOrderCommand.java
// public class PlaceOrderCommand extends Command {
//
// public final OrderId orderId;
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long totalAmount;
//
// public PlaceOrderCommand(OrderId orderId, CustomerInformation customerInformation, List<OrderLine> orderLines, long totalAmount) {
// checkArgument(orderId != null, "OrderId cannot be null");
// checkArgument(customerInformation != null, "CustomerInformation cannot be null");
// checkArgument(orderLines != null, "Items cannot be null");
// checkArgument(!orderLines.isEmpty(), "Item list cannot be empty");
// checkArgument(totalAmount > 0, "Total amount must be > 0");
// this.orderId = orderId;
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.totalAmount = totalAmount;
// }
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.command.ActivateOrderCommand;
import se.citerus.cqrs.bookstore.ordercontext.order.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.order.command.PlaceOrderCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("order-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class OrderResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final CommandBus commandBus;
private final CommandFactory commandFactory = new CommandFactory();
public OrderResource(CommandBus commandBus) {
this.commandBus = commandBus;
}
@POST
public void placeOrder(@Valid PlaceOrderRequest placeOrderRequest) {
logger.info("Placing customer order: " + placeOrderRequest);
PlaceOrderCommand placeOrderCommand = commandFactory.toCommand(placeOrderRequest);
commandBus.dispatch(placeOrderCommand);
}
@POST
@Path("activations")
public void activateOrder(@Valid ActivateOrderRequest activationRequest) {
logger.info("Activating orderId: " + activationRequest.orderId); | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/ActivateOrderCommand.java
// public class ActivateOrderCommand extends Command {
//
// public final OrderId orderId;
//
// public ActivateOrderCommand(OrderId orderId) {
// checkArgument(orderId != null, "OrderId cannot be null");
// this.orderId = orderId;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java
// public class CommandFactory {
//
// public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
// List<OrderLine> itemsToOrder = getOrderLines(request.cart);
// CustomerInformation customerInformation = getCustomerInformation(request);
// long totalPrice = request.cart.totalPrice;
// return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice);
// }
//
// public ActivateOrderCommand toCommand(ActivateOrderRequest request) {
// return new ActivateOrderCommand(new OrderId(request.orderId));
// }
//
// private List<OrderLine> getOrderLines(CartDto cart) {
// List<OrderLine> itemsToOrder = new ArrayList<>();
// for (LineItemDto lineItem : cart.lineItems) {
// ProductId productId = new ProductId(lineItem.productId);
// String title = lineItem.title;
// int quantity = lineItem.quantity;
// long price = lineItem.price;
// itemsToOrder.add(new OrderLine(productId, title, quantity, price));
// }
// return itemsToOrder;
// }
//
// private CustomerInformation getCustomerInformation(PlaceOrderRequest request) {
// return new CustomerInformation(request.customerName, request.customerEmail, request.customerAddress);
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/PlaceOrderCommand.java
// public class PlaceOrderCommand extends Command {
//
// public final OrderId orderId;
// public final CustomerInformation customerInformation;
// public final List<OrderLine> orderLines;
// public final long totalAmount;
//
// public PlaceOrderCommand(OrderId orderId, CustomerInformation customerInformation, List<OrderLine> orderLines, long totalAmount) {
// checkArgument(orderId != null, "OrderId cannot be null");
// checkArgument(customerInformation != null, "CustomerInformation cannot be null");
// checkArgument(orderLines != null, "Items cannot be null");
// checkArgument(!orderLines.isEmpty(), "Item list cannot be empty");
// checkArgument(totalAmount > 0, "Total amount must be > 0");
// this.orderId = orderId;
// this.customerInformation = customerInformation;
// this.orderLines = Collections.unmodifiableList(orderLines);
// this.totalAmount = totalAmount;
// }
//
// }
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/OrderResource.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.command.ActivateOrderCommand;
import se.citerus.cqrs.bookstore.ordercontext.order.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.order.command.PlaceOrderCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("order-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class OrderResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final CommandBus commandBus;
private final CommandFactory commandFactory = new CommandFactory();
public OrderResource(CommandBus commandBus) {
this.commandBus = commandBus;
}
@POST
public void placeOrder(@Valid PlaceOrderRequest placeOrderRequest) {
logger.info("Placing customer order: " + placeOrderRequest);
PlaceOrderCommand placeOrderCommand = commandFactory.toCommand(placeOrderRequest);
commandBus.dispatch(placeOrderCommand);
}
@POST
@Path("activations")
public void activateOrder(@Valid ActivateOrderRequest activationRequest) {
logger.info("Activating orderId: " + activationRequest.orderId); | ActivateOrderCommand command = commandFactory.toCommand(activationRequest); |
citerus/bookstore-cqrs-example | shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CartDtoFactory.java | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/domain/Cart.java
// public class Cart {
//
// public final String cartId;
//
// private final Map<ProductId, LineItem> lineItems = new LinkedHashMap<>();
//
// public Cart(String cartId) {
// this.cartId = cartId;
// }
//
// public void add(Item item) {
// LineItem lineItem = lineItems.get(item.productId);
// if (lineItem == null) {
// lineItem = new LineItem(item);
// } else {
// lineItem.increaseQuantity();
// }
// lineItems.put(item.productId, lineItem);
// }
//
// public Collection<LineItem> getItems() {
// return Collections.unmodifiableCollection(lineItems.values());
// }
//
// public int getLineCount() {
// return lineItems.size();
// }
//
// public long getTotalPrice() {
// long totalPrice = 0;
// for (LineItem lineItem : lineItems.values()) {
// totalPrice += lineItem.getTotalPrice();
// }
// return totalPrice;
// }
//
// public int getTotalQuantity() {
// int totalQuantity = 0;
// for (LineItem lineItem : lineItems.values()) {
// totalQuantity += lineItem.getQuantity();
// }
// return totalQuantity;
// }
//
// public void remove(ProductId productId) {
// LineItem lineItem = lineItems.get(productId);
// if (lineItem != null) {
// lineItem.decreaseQuantity();
// if (lineItem.getQuantity() == 0) {
// lineItems.remove(productId);
// }
// }
// }
//
// public void removeAll(ProductId productId) {
// lineItems.remove(productId);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/domain/Item.java
// public class Item extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final long price;
//
// public Item(ProductId productId, String title, long price) {
// this.productId = productId;
// this.title = title;
// this.price = price;
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/domain/LineItem.java
// public class LineItem extends ValueObject {
//
// private final Item item;
// private int quantity;
//
// public LineItem(Item item) {
// this.item = item;
// this.quantity = 1;
// }
//
// public void increaseQuantity() {
// this.quantity++;
// }
//
// public void decreaseQuantity() {
// if (quantity > 0) quantity--;
// }
//
// public int getQuantity() {
// return quantity;
// }
//
// public long getPrice() {
// return item.price;
// }
//
// public long getTotalPrice() {
// return item.price * quantity;
// }
//
// public Item getItem() {
// return item;
// }
//
// }
| import se.citerus.cqrs.bookstore.shopping.domain.Cart;
import se.citerus.cqrs.bookstore.shopping.domain.Item;
import se.citerus.cqrs.bookstore.shopping.domain.LineItem;
import java.util.ArrayList;
import java.util.List; | package se.citerus.cqrs.bookstore.shopping.api;
public class CartDtoFactory {
public static CartDto fromCart(Cart cart) {
List<LineItemDto> lineItems = new ArrayList<>();
| // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/domain/Cart.java
// public class Cart {
//
// public final String cartId;
//
// private final Map<ProductId, LineItem> lineItems = new LinkedHashMap<>();
//
// public Cart(String cartId) {
// this.cartId = cartId;
// }
//
// public void add(Item item) {
// LineItem lineItem = lineItems.get(item.productId);
// if (lineItem == null) {
// lineItem = new LineItem(item);
// } else {
// lineItem.increaseQuantity();
// }
// lineItems.put(item.productId, lineItem);
// }
//
// public Collection<LineItem> getItems() {
// return Collections.unmodifiableCollection(lineItems.values());
// }
//
// public int getLineCount() {
// return lineItems.size();
// }
//
// public long getTotalPrice() {
// long totalPrice = 0;
// for (LineItem lineItem : lineItems.values()) {
// totalPrice += lineItem.getTotalPrice();
// }
// return totalPrice;
// }
//
// public int getTotalQuantity() {
// int totalQuantity = 0;
// for (LineItem lineItem : lineItems.values()) {
// totalQuantity += lineItem.getQuantity();
// }
// return totalQuantity;
// }
//
// public void remove(ProductId productId) {
// LineItem lineItem = lineItems.get(productId);
// if (lineItem != null) {
// lineItem.decreaseQuantity();
// if (lineItem.getQuantity() == 0) {
// lineItems.remove(productId);
// }
// }
// }
//
// public void removeAll(ProductId productId) {
// lineItems.remove(productId);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/domain/Item.java
// public class Item extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final long price;
//
// public Item(ProductId productId, String title, long price) {
// this.productId = productId;
// this.title = title;
// this.price = price;
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/domain/LineItem.java
// public class LineItem extends ValueObject {
//
// private final Item item;
// private int quantity;
//
// public LineItem(Item item) {
// this.item = item;
// this.quantity = 1;
// }
//
// public void increaseQuantity() {
// this.quantity++;
// }
//
// public void decreaseQuantity() {
// if (quantity > 0) quantity--;
// }
//
// public int getQuantity() {
// return quantity;
// }
//
// public long getPrice() {
// return item.price;
// }
//
// public long getTotalPrice() {
// return item.price * quantity;
// }
//
// public Item getItem() {
// return item;
// }
//
// }
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CartDtoFactory.java
import se.citerus.cqrs.bookstore.shopping.domain.Cart;
import se.citerus.cqrs.bookstore.shopping.domain.Item;
import se.citerus.cqrs.bookstore.shopping.domain.LineItem;
import java.util.ArrayList;
import java.util.List;
package se.citerus.cqrs.bookstore.shopping.api;
public class CartDtoFactory {
public static CartDto fromCart(Cart cart) {
List<LineItemDto> lineItems = new ArrayList<>();
| for (LineItem lineItem : cart.getItems()) { |
citerus/bookstore-cqrs-example | shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CartDtoFactory.java | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/domain/Cart.java
// public class Cart {
//
// public final String cartId;
//
// private final Map<ProductId, LineItem> lineItems = new LinkedHashMap<>();
//
// public Cart(String cartId) {
// this.cartId = cartId;
// }
//
// public void add(Item item) {
// LineItem lineItem = lineItems.get(item.productId);
// if (lineItem == null) {
// lineItem = new LineItem(item);
// } else {
// lineItem.increaseQuantity();
// }
// lineItems.put(item.productId, lineItem);
// }
//
// public Collection<LineItem> getItems() {
// return Collections.unmodifiableCollection(lineItems.values());
// }
//
// public int getLineCount() {
// return lineItems.size();
// }
//
// public long getTotalPrice() {
// long totalPrice = 0;
// for (LineItem lineItem : lineItems.values()) {
// totalPrice += lineItem.getTotalPrice();
// }
// return totalPrice;
// }
//
// public int getTotalQuantity() {
// int totalQuantity = 0;
// for (LineItem lineItem : lineItems.values()) {
// totalQuantity += lineItem.getQuantity();
// }
// return totalQuantity;
// }
//
// public void remove(ProductId productId) {
// LineItem lineItem = lineItems.get(productId);
// if (lineItem != null) {
// lineItem.decreaseQuantity();
// if (lineItem.getQuantity() == 0) {
// lineItems.remove(productId);
// }
// }
// }
//
// public void removeAll(ProductId productId) {
// lineItems.remove(productId);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/domain/Item.java
// public class Item extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final long price;
//
// public Item(ProductId productId, String title, long price) {
// this.productId = productId;
// this.title = title;
// this.price = price;
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/domain/LineItem.java
// public class LineItem extends ValueObject {
//
// private final Item item;
// private int quantity;
//
// public LineItem(Item item) {
// this.item = item;
// this.quantity = 1;
// }
//
// public void increaseQuantity() {
// this.quantity++;
// }
//
// public void decreaseQuantity() {
// if (quantity > 0) quantity--;
// }
//
// public int getQuantity() {
// return quantity;
// }
//
// public long getPrice() {
// return item.price;
// }
//
// public long getTotalPrice() {
// return item.price * quantity;
// }
//
// public Item getItem() {
// return item;
// }
//
// }
| import se.citerus.cqrs.bookstore.shopping.domain.Cart;
import se.citerus.cqrs.bookstore.shopping.domain.Item;
import se.citerus.cqrs.bookstore.shopping.domain.LineItem;
import java.util.ArrayList;
import java.util.List; | package se.citerus.cqrs.bookstore.shopping.api;
public class CartDtoFactory {
public static CartDto fromCart(Cart cart) {
List<LineItemDto> lineItems = new ArrayList<>();
for (LineItem lineItem : cart.getItems()) {
LineItemDto itemDto = toLineItemDto(lineItem);
lineItems.add(itemDto);
}
CartDto cartDto = new CartDto();
cartDto.cartId = cart.cartId;
cartDto.totalPrice = cart.getTotalPrice();
cartDto.totalQuantity = cart.getTotalQuantity();
cartDto.lineItems = lineItems;
return cartDto;
}
private static LineItemDto toLineItemDto(LineItem lineItem) {
long price = lineItem.getTotalPrice();
int quantity = lineItem.getQuantity(); | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/domain/Cart.java
// public class Cart {
//
// public final String cartId;
//
// private final Map<ProductId, LineItem> lineItems = new LinkedHashMap<>();
//
// public Cart(String cartId) {
// this.cartId = cartId;
// }
//
// public void add(Item item) {
// LineItem lineItem = lineItems.get(item.productId);
// if (lineItem == null) {
// lineItem = new LineItem(item);
// } else {
// lineItem.increaseQuantity();
// }
// lineItems.put(item.productId, lineItem);
// }
//
// public Collection<LineItem> getItems() {
// return Collections.unmodifiableCollection(lineItems.values());
// }
//
// public int getLineCount() {
// return lineItems.size();
// }
//
// public long getTotalPrice() {
// long totalPrice = 0;
// for (LineItem lineItem : lineItems.values()) {
// totalPrice += lineItem.getTotalPrice();
// }
// return totalPrice;
// }
//
// public int getTotalQuantity() {
// int totalQuantity = 0;
// for (LineItem lineItem : lineItems.values()) {
// totalQuantity += lineItem.getQuantity();
// }
// return totalQuantity;
// }
//
// public void remove(ProductId productId) {
// LineItem lineItem = lineItems.get(productId);
// if (lineItem != null) {
// lineItem.decreaseQuantity();
// if (lineItem.getQuantity() == 0) {
// lineItems.remove(productId);
// }
// }
// }
//
// public void removeAll(ProductId productId) {
// lineItems.remove(productId);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/domain/Item.java
// public class Item extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final long price;
//
// public Item(ProductId productId, String title, long price) {
// this.productId = productId;
// this.title = title;
// this.price = price;
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/domain/LineItem.java
// public class LineItem extends ValueObject {
//
// private final Item item;
// private int quantity;
//
// public LineItem(Item item) {
// this.item = item;
// this.quantity = 1;
// }
//
// public void increaseQuantity() {
// this.quantity++;
// }
//
// public void decreaseQuantity() {
// if (quantity > 0) quantity--;
// }
//
// public int getQuantity() {
// return quantity;
// }
//
// public long getPrice() {
// return item.price;
// }
//
// public long getTotalPrice() {
// return item.price * quantity;
// }
//
// public Item getItem() {
// return item;
// }
//
// }
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/api/CartDtoFactory.java
import se.citerus.cqrs.bookstore.shopping.domain.Cart;
import se.citerus.cqrs.bookstore.shopping.domain.Item;
import se.citerus.cqrs.bookstore.shopping.domain.LineItem;
import java.util.ArrayList;
import java.util.List;
package se.citerus.cqrs.bookstore.shopping.api;
public class CartDtoFactory {
public static CartDto fromCart(Cart cart) {
List<LineItemDto> lineItems = new ArrayList<>();
for (LineItem lineItem : cart.getItems()) {
LineItemDto itemDto = toLineItemDto(lineItem);
lineItems.add(itemDto);
}
CartDto cartDto = new CartDto();
cartDto.cartId = cart.cartId;
cartDto.totalPrice = cart.getTotalPrice();
cartDto.totalQuantity = cart.getTotalQuantity();
cartDto.lineItems = lineItems;
return cartDto;
}
private static LineItemDto toLineItemDto(LineItem lineItem) {
long price = lineItem.getTotalPrice();
int quantity = lineItem.getQuantity(); | Item item = lineItem.getItem(); |
citerus/bookstore-cqrs-example | order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/PublisherContractResource.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/RegisterPublisherContractRequest.java
// public class RegisterPublisherContractRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// @NotNull
// public String publisherName;
//
// @Min(1)
// public double feePercentage;
//
// @Min(1)
// public long limit;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/CommandFactory.java
// public class CommandFactory {
//
// public RegisterPublisherContractCommand toCommand(PublisherContractId contractId, RegisterPublisherContractRequest request) {
// return new RegisterPublisherContractCommand(contractId, request.publisherName, request.feePercentage, request.limit);
// }
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/RegisterPublisherContractCommand.java
// public class RegisterPublisherContractCommand extends Command {
//
// public final PublisherContractId publisherContractId;
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public RegisterPublisherContractCommand(PublisherContractId publisherContractId, String publisherName, double feePercentage, long limit) {
// checkArgument(publisherContractId != null, "PublisherContractId cannot be null");
// checkArgument(publisherName != null, "PublisherName cannot be null");
// checkArgument(feePercentage > 0, "Fee must be a positive number");
// checkArgument(limit > 0, "Limit must be a positive number");
//
// this.publisherContractId = publisherContractId;
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.RegisterPublisherContractRequest;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.command.RegisterPublisherContractCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("publisher-contract-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class PublisherContractResource {
private final Logger logger = LoggerFactory.getLogger(getClass()); | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/RegisterPublisherContractRequest.java
// public class RegisterPublisherContractRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// @NotNull
// public String publisherName;
//
// @Min(1)
// public double feePercentage;
//
// @Min(1)
// public long limit;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/CommandFactory.java
// public class CommandFactory {
//
// public RegisterPublisherContractCommand toCommand(PublisherContractId contractId, RegisterPublisherContractRequest request) {
// return new RegisterPublisherContractCommand(contractId, request.publisherName, request.feePercentage, request.limit);
// }
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/RegisterPublisherContractCommand.java
// public class RegisterPublisherContractCommand extends Command {
//
// public final PublisherContractId publisherContractId;
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public RegisterPublisherContractCommand(PublisherContractId publisherContractId, String publisherName, double feePercentage, long limit) {
// checkArgument(publisherContractId != null, "PublisherContractId cannot be null");
// checkArgument(publisherName != null, "PublisherName cannot be null");
// checkArgument(feePercentage > 0, "Fee must be a positive number");
// checkArgument(limit > 0, "Limit must be a positive number");
//
// this.publisherContractId = publisherContractId;
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/PublisherContractResource.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.RegisterPublisherContractRequest;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.command.RegisterPublisherContractCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("publisher-contract-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class PublisherContractResource {
private final Logger logger = LoggerFactory.getLogger(getClass()); | private final CommandBus commandBus; |
citerus/bookstore-cqrs-example | order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/PublisherContractResource.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/RegisterPublisherContractRequest.java
// public class RegisterPublisherContractRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// @NotNull
// public String publisherName;
//
// @Min(1)
// public double feePercentage;
//
// @Min(1)
// public long limit;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/CommandFactory.java
// public class CommandFactory {
//
// public RegisterPublisherContractCommand toCommand(PublisherContractId contractId, RegisterPublisherContractRequest request) {
// return new RegisterPublisherContractCommand(contractId, request.publisherName, request.feePercentage, request.limit);
// }
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/RegisterPublisherContractCommand.java
// public class RegisterPublisherContractCommand extends Command {
//
// public final PublisherContractId publisherContractId;
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public RegisterPublisherContractCommand(PublisherContractId publisherContractId, String publisherName, double feePercentage, long limit) {
// checkArgument(publisherContractId != null, "PublisherContractId cannot be null");
// checkArgument(publisherName != null, "PublisherName cannot be null");
// checkArgument(feePercentage > 0, "Fee must be a positive number");
// checkArgument(limit > 0, "Limit must be a positive number");
//
// this.publisherContractId = publisherContractId;
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.RegisterPublisherContractRequest;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.command.RegisterPublisherContractCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("publisher-contract-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class PublisherContractResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final CommandBus commandBus; | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/RegisterPublisherContractRequest.java
// public class RegisterPublisherContractRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// @NotNull
// public String publisherName;
//
// @Min(1)
// public double feePercentage;
//
// @Min(1)
// public long limit;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/CommandFactory.java
// public class CommandFactory {
//
// public RegisterPublisherContractCommand toCommand(PublisherContractId contractId, RegisterPublisherContractRequest request) {
// return new RegisterPublisherContractCommand(contractId, request.publisherName, request.feePercentage, request.limit);
// }
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/RegisterPublisherContractCommand.java
// public class RegisterPublisherContractCommand extends Command {
//
// public final PublisherContractId publisherContractId;
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public RegisterPublisherContractCommand(PublisherContractId publisherContractId, String publisherName, double feePercentage, long limit) {
// checkArgument(publisherContractId != null, "PublisherContractId cannot be null");
// checkArgument(publisherName != null, "PublisherName cannot be null");
// checkArgument(feePercentage > 0, "Fee must be a positive number");
// checkArgument(limit > 0, "Limit must be a positive number");
//
// this.publisherContractId = publisherContractId;
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/PublisherContractResource.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.RegisterPublisherContractRequest;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.command.RegisterPublisherContractCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("publisher-contract-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class PublisherContractResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final CommandBus commandBus; | private final CommandFactory commandFactory = new CommandFactory(); |
citerus/bookstore-cqrs-example | order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/PublisherContractResource.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/RegisterPublisherContractRequest.java
// public class RegisterPublisherContractRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// @NotNull
// public String publisherName;
//
// @Min(1)
// public double feePercentage;
//
// @Min(1)
// public long limit;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/CommandFactory.java
// public class CommandFactory {
//
// public RegisterPublisherContractCommand toCommand(PublisherContractId contractId, RegisterPublisherContractRequest request) {
// return new RegisterPublisherContractCommand(contractId, request.publisherName, request.feePercentage, request.limit);
// }
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/RegisterPublisherContractCommand.java
// public class RegisterPublisherContractCommand extends Command {
//
// public final PublisherContractId publisherContractId;
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public RegisterPublisherContractCommand(PublisherContractId publisherContractId, String publisherName, double feePercentage, long limit) {
// checkArgument(publisherContractId != null, "PublisherContractId cannot be null");
// checkArgument(publisherName != null, "PublisherName cannot be null");
// checkArgument(feePercentage > 0, "Fee must be a positive number");
// checkArgument(limit > 0, "Limit must be a positive number");
//
// this.publisherContractId = publisherContractId;
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.RegisterPublisherContractRequest;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.command.RegisterPublisherContractCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("publisher-contract-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class PublisherContractResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final CommandBus commandBus;
private final CommandFactory commandFactory = new CommandFactory();
public PublisherContractResource(CommandBus commandBus) {
this.commandBus = commandBus;
}
@POST | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/RegisterPublisherContractRequest.java
// public class RegisterPublisherContractRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// @NotNull
// public String publisherName;
//
// @Min(1)
// public double feePercentage;
//
// @Min(1)
// public long limit;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/CommandFactory.java
// public class CommandFactory {
//
// public RegisterPublisherContractCommand toCommand(PublisherContractId contractId, RegisterPublisherContractRequest request) {
// return new RegisterPublisherContractCommand(contractId, request.publisherName, request.feePercentage, request.limit);
// }
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/RegisterPublisherContractCommand.java
// public class RegisterPublisherContractCommand extends Command {
//
// public final PublisherContractId publisherContractId;
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public RegisterPublisherContractCommand(PublisherContractId publisherContractId, String publisherName, double feePercentage, long limit) {
// checkArgument(publisherContractId != null, "PublisherContractId cannot be null");
// checkArgument(publisherName != null, "PublisherName cannot be null");
// checkArgument(feePercentage > 0, "Fee must be a positive number");
// checkArgument(limit > 0, "Limit must be a positive number");
//
// this.publisherContractId = publisherContractId;
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/PublisherContractResource.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.RegisterPublisherContractRequest;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.command.RegisterPublisherContractCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("publisher-contract-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class PublisherContractResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final CommandBus commandBus;
private final CommandFactory commandFactory = new CommandFactory();
public PublisherContractResource(CommandBus commandBus) {
this.commandBus = commandBus;
}
@POST | public void registerContract(@Valid RegisterPublisherContractRequest request) { |
citerus/bookstore-cqrs-example | order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/PublisherContractResource.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/RegisterPublisherContractRequest.java
// public class RegisterPublisherContractRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// @NotNull
// public String publisherName;
//
// @Min(1)
// public double feePercentage;
//
// @Min(1)
// public long limit;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/CommandFactory.java
// public class CommandFactory {
//
// public RegisterPublisherContractCommand toCommand(PublisherContractId contractId, RegisterPublisherContractRequest request) {
// return new RegisterPublisherContractCommand(contractId, request.publisherName, request.feePercentage, request.limit);
// }
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/RegisterPublisherContractCommand.java
// public class RegisterPublisherContractCommand extends Command {
//
// public final PublisherContractId publisherContractId;
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public RegisterPublisherContractCommand(PublisherContractId publisherContractId, String publisherName, double feePercentage, long limit) {
// checkArgument(publisherContractId != null, "PublisherContractId cannot be null");
// checkArgument(publisherName != null, "PublisherName cannot be null");
// checkArgument(feePercentage > 0, "Fee must be a positive number");
// checkArgument(limit > 0, "Limit must be a positive number");
//
// this.publisherContractId = publisherContractId;
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.RegisterPublisherContractRequest;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.command.RegisterPublisherContractCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("publisher-contract-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class PublisherContractResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final CommandBus commandBus;
private final CommandFactory commandFactory = new CommandFactory();
public PublisherContractResource(CommandBus commandBus) {
this.commandBus = commandBus;
}
@POST
public void registerContract(@Valid RegisterPublisherContractRequest request) { | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/RegisterPublisherContractRequest.java
// public class RegisterPublisherContractRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// @NotNull
// public String publisherName;
//
// @Min(1)
// public double feePercentage;
//
// @Min(1)
// public long limit;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/CommandFactory.java
// public class CommandFactory {
//
// public RegisterPublisherContractCommand toCommand(PublisherContractId contractId, RegisterPublisherContractRequest request) {
// return new RegisterPublisherContractCommand(contractId, request.publisherName, request.feePercentage, request.limit);
// }
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/RegisterPublisherContractCommand.java
// public class RegisterPublisherContractCommand extends Command {
//
// public final PublisherContractId publisherContractId;
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public RegisterPublisherContractCommand(PublisherContractId publisherContractId, String publisherName, double feePercentage, long limit) {
// checkArgument(publisherContractId != null, "PublisherContractId cannot be null");
// checkArgument(publisherName != null, "PublisherName cannot be null");
// checkArgument(feePercentage > 0, "Fee must be a positive number");
// checkArgument(limit > 0, "Limit must be a positive number");
//
// this.publisherContractId = publisherContractId;
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/PublisherContractResource.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.RegisterPublisherContractRequest;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.command.RegisterPublisherContractCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("publisher-contract-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class PublisherContractResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final CommandBus commandBus;
private final CommandFactory commandFactory = new CommandFactory();
public PublisherContractResource(CommandBus commandBus) {
this.commandBus = commandBus;
}
@POST
public void registerContract(@Valid RegisterPublisherContractRequest request) { | PublisherContractId publisherContractId = new PublisherContractId(request.publisherContractId); |
citerus/bookstore-cqrs-example | order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/PublisherContractResource.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/RegisterPublisherContractRequest.java
// public class RegisterPublisherContractRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// @NotNull
// public String publisherName;
//
// @Min(1)
// public double feePercentage;
//
// @Min(1)
// public long limit;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/CommandFactory.java
// public class CommandFactory {
//
// public RegisterPublisherContractCommand toCommand(PublisherContractId contractId, RegisterPublisherContractRequest request) {
// return new RegisterPublisherContractCommand(contractId, request.publisherName, request.feePercentage, request.limit);
// }
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/RegisterPublisherContractCommand.java
// public class RegisterPublisherContractCommand extends Command {
//
// public final PublisherContractId publisherContractId;
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public RegisterPublisherContractCommand(PublisherContractId publisherContractId, String publisherName, double feePercentage, long limit) {
// checkArgument(publisherContractId != null, "PublisherContractId cannot be null");
// checkArgument(publisherName != null, "PublisherName cannot be null");
// checkArgument(feePercentage > 0, "Fee must be a positive number");
// checkArgument(limit > 0, "Limit must be a positive number");
//
// this.publisherContractId = publisherContractId;
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.RegisterPublisherContractRequest;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.command.RegisterPublisherContractCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("publisher-contract-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class PublisherContractResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final CommandBus commandBus;
private final CommandFactory commandFactory = new CommandFactory();
public PublisherContractResource(CommandBus commandBus) {
this.commandBus = commandBus;
}
@POST
public void registerContract(@Valid RegisterPublisherContractRequest request) {
PublisherContractId publisherContractId = new PublisherContractId(request.publisherContractId);
logger.info("Registering contract: " + publisherContractId); | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
//
// void dispatch(Command command);
//
// <T extends CommandHandler> T register(T handler);
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/RegisterPublisherContractRequest.java
// public class RegisterPublisherContractRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// @NotNull
// public String publisherName;
//
// @Min(1)
// public double feePercentage;
//
// @Min(1)
// public long limit;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/CommandFactory.java
// public class CommandFactory {
//
// public RegisterPublisherContractCommand toCommand(PublisherContractId contractId, RegisterPublisherContractRequest request) {
// return new RegisterPublisherContractCommand(contractId, request.publisherName, request.feePercentage, request.limit);
// }
//
// }
//
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/RegisterPublisherContractCommand.java
// public class RegisterPublisherContractCommand extends Command {
//
// public final PublisherContractId publisherContractId;
// public final String publisherName;
// public final double feePercentage;
// public final long limit;
//
// public RegisterPublisherContractCommand(PublisherContractId publisherContractId, String publisherName, double feePercentage, long limit) {
// checkArgument(publisherContractId != null, "PublisherContractId cannot be null");
// checkArgument(publisherName != null, "PublisherName cannot be null");
// checkArgument(feePercentage > 0, "Fee must be a positive number");
// checkArgument(limit > 0, "Limit must be a positive number");
//
// this.publisherContractId = publisherContractId;
// this.publisherName = publisherName;
// this.feePercentage = feePercentage;
// this.limit = limit;
// }
//
// }
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/resource/PublisherContractResource.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.ordercontext.api.RegisterPublisherContractRequest;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.command.CommandFactory;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.command.RegisterPublisherContractCommand;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.ordercontext.resource;
@Path("publisher-contract-requests")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class PublisherContractResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final CommandBus commandBus;
private final CommandFactory commandFactory = new CommandFactory();
public PublisherContractResource(CommandBus commandBus) {
this.commandBus = commandBus;
}
@POST
public void registerContract(@Valid RegisterPublisherContractRequest request) {
PublisherContractId publisherContractId = new PublisherContractId(request.publisherContractId);
logger.info("Registering contract: " + publisherContractId); | RegisterPublisherContractCommand command = commandFactory.toCommand(publisherContractId, request); |
citerus/bookstore-cqrs-example | product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
| import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product; | package se.citerus.cqrs.bookstore.productcatalog.api;
public class ProductDtoFactory {
public static ProductDto fromProduct(Product product) {
return toProduct(product, toBook(product.book));
}
private static ProductDto toProduct(Product product, BookDto bookDto) {
ProductDto productDto = new ProductDto();
productDto.productId = product.productId;
productDto.price = product.price;
productDto.publisherContractId = product.publisherContractId;
productDto.book = bookDto;
return productDto;
}
| // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
package se.citerus.cqrs.bookstore.productcatalog.api;
public class ProductDtoFactory {
public static ProductDto fromProduct(Product product) {
return toProduct(product, toBook(product.book));
}
private static ProductDto toProduct(Product product, BookDto bookDto) {
ProductDto productDto = new ProductDto();
productDto.productId = product.productId;
productDto.price = product.price;
productDto.publisherContractId = product.publisherContractId;
productDto.book = bookDto;
return productDto;
}
| private static BookDto toBook(Book book) { |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepositoryTest.java | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderLineProjection.java
// public class OrderLineProjection {
//
// public ProductId productId;
//
// public String title;
//
// public int quantity;
//
// public long unitPrice;
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
//
// private final OrderId orderId;
// private final long orderPlacedTimestamp;
// private final long orderAmount;
// private final String customerName;
// private final List<OrderLineProjection> orderLines;
// private OrderStatus status;
//
// public OrderProjection(@JsonProperty("orderId") OrderId orderId,
// @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
// @JsonProperty("customerName") String customerName,
// @JsonProperty("orderAmount") long orderAmount,
// @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
// @JsonProperty("status") OrderStatus status) {
// this.orderId = orderId;
// this.orderPlacedTimestamp = orderPlacedTimestamp;
// this.customerName = customerName;
// this.orderAmount = orderAmount;
// this.orderLines = new ArrayList<>(orderLines);
// this.status = status;
// }
//
// public List<OrderLineProjection> getOrderLines() {
// return orderLines;
// }
//
// public OrderId getOrderId() {
// return orderId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public long getOrderAmount() {
// return orderAmount;
// }
//
// public OrderStatus getStatus() {
// return status;
// }
//
// public void setStatus(OrderStatus status) {
// this.status = status;
// }
//
// public long getOrderPlacedTimestamp() {
// return orderPlacedTimestamp;
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjectionRepository.java
// public interface OrderProjectionRepository {
//
// void save(OrderProjection orderProjection);
//
// OrderProjection getById(OrderId orderId);
//
// List<OrderProjection> listOrdersByTimestamp();
//
// }
| import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderLineProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjectionRepository;
import java.util.Collections;
import java.util.Iterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.PLACED; | package se.citerus.cqrs.bookstore.ordercontext.infrastructure;
public class InMemOrderProjectionRepositoryTest {
@Test
public void sortingOfOrders() { | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderLineProjection.java
// public class OrderLineProjection {
//
// public ProductId productId;
//
// public String title;
//
// public int quantity;
//
// public long unitPrice;
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
//
// private final OrderId orderId;
// private final long orderPlacedTimestamp;
// private final long orderAmount;
// private final String customerName;
// private final List<OrderLineProjection> orderLines;
// private OrderStatus status;
//
// public OrderProjection(@JsonProperty("orderId") OrderId orderId,
// @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
// @JsonProperty("customerName") String customerName,
// @JsonProperty("orderAmount") long orderAmount,
// @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
// @JsonProperty("status") OrderStatus status) {
// this.orderId = orderId;
// this.orderPlacedTimestamp = orderPlacedTimestamp;
// this.customerName = customerName;
// this.orderAmount = orderAmount;
// this.orderLines = new ArrayList<>(orderLines);
// this.status = status;
// }
//
// public List<OrderLineProjection> getOrderLines() {
// return orderLines;
// }
//
// public OrderId getOrderId() {
// return orderId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public long getOrderAmount() {
// return orderAmount;
// }
//
// public OrderStatus getStatus() {
// return status;
// }
//
// public void setStatus(OrderStatus status) {
// this.status = status;
// }
//
// public long getOrderPlacedTimestamp() {
// return orderPlacedTimestamp;
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjectionRepository.java
// public interface OrderProjectionRepository {
//
// void save(OrderProjection orderProjection);
//
// OrderProjection getById(OrderId orderId);
//
// List<OrderProjection> listOrdersByTimestamp();
//
// }
// Path: order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepositoryTest.java
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderLineProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjectionRepository;
import java.util.Collections;
import java.util.Iterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.PLACED;
package se.citerus.cqrs.bookstore.ordercontext.infrastructure;
public class InMemOrderProjectionRepositoryTest {
@Test
public void sortingOfOrders() { | OrderProjectionRepository repository = new InMemOrderProjectionRepository(); |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepositoryTest.java | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderLineProjection.java
// public class OrderLineProjection {
//
// public ProductId productId;
//
// public String title;
//
// public int quantity;
//
// public long unitPrice;
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
//
// private final OrderId orderId;
// private final long orderPlacedTimestamp;
// private final long orderAmount;
// private final String customerName;
// private final List<OrderLineProjection> orderLines;
// private OrderStatus status;
//
// public OrderProjection(@JsonProperty("orderId") OrderId orderId,
// @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
// @JsonProperty("customerName") String customerName,
// @JsonProperty("orderAmount") long orderAmount,
// @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
// @JsonProperty("status") OrderStatus status) {
// this.orderId = orderId;
// this.orderPlacedTimestamp = orderPlacedTimestamp;
// this.customerName = customerName;
// this.orderAmount = orderAmount;
// this.orderLines = new ArrayList<>(orderLines);
// this.status = status;
// }
//
// public List<OrderLineProjection> getOrderLines() {
// return orderLines;
// }
//
// public OrderId getOrderId() {
// return orderId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public long getOrderAmount() {
// return orderAmount;
// }
//
// public OrderStatus getStatus() {
// return status;
// }
//
// public void setStatus(OrderStatus status) {
// this.status = status;
// }
//
// public long getOrderPlacedTimestamp() {
// return orderPlacedTimestamp;
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjectionRepository.java
// public interface OrderProjectionRepository {
//
// void save(OrderProjection orderProjection);
//
// OrderProjection getById(OrderId orderId);
//
// List<OrderProjection> listOrdersByTimestamp();
//
// }
| import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderLineProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjectionRepository;
import java.util.Collections;
import java.util.Iterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.PLACED; | package se.citerus.cqrs.bookstore.ordercontext.infrastructure;
public class InMemOrderProjectionRepositoryTest {
@Test
public void sortingOfOrders() {
OrderProjectionRepository repository = new InMemOrderProjectionRepository();
| // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderLineProjection.java
// public class OrderLineProjection {
//
// public ProductId productId;
//
// public String title;
//
// public int quantity;
//
// public long unitPrice;
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
//
// private final OrderId orderId;
// private final long orderPlacedTimestamp;
// private final long orderAmount;
// private final String customerName;
// private final List<OrderLineProjection> orderLines;
// private OrderStatus status;
//
// public OrderProjection(@JsonProperty("orderId") OrderId orderId,
// @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
// @JsonProperty("customerName") String customerName,
// @JsonProperty("orderAmount") long orderAmount,
// @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
// @JsonProperty("status") OrderStatus status) {
// this.orderId = orderId;
// this.orderPlacedTimestamp = orderPlacedTimestamp;
// this.customerName = customerName;
// this.orderAmount = orderAmount;
// this.orderLines = new ArrayList<>(orderLines);
// this.status = status;
// }
//
// public List<OrderLineProjection> getOrderLines() {
// return orderLines;
// }
//
// public OrderId getOrderId() {
// return orderId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public long getOrderAmount() {
// return orderAmount;
// }
//
// public OrderStatus getStatus() {
// return status;
// }
//
// public void setStatus(OrderStatus status) {
// this.status = status;
// }
//
// public long getOrderPlacedTimestamp() {
// return orderPlacedTimestamp;
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjectionRepository.java
// public interface OrderProjectionRepository {
//
// void save(OrderProjection orderProjection);
//
// OrderProjection getById(OrderId orderId);
//
// List<OrderProjection> listOrdersByTimestamp();
//
// }
// Path: order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepositoryTest.java
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderLineProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjectionRepository;
import java.util.Collections;
import java.util.Iterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.PLACED;
package se.citerus.cqrs.bookstore.ordercontext.infrastructure;
public class InMemOrderProjectionRepositoryTest {
@Test
public void sortingOfOrders() {
OrderProjectionRepository repository = new InMemOrderProjectionRepository();
| repository.save(new OrderProjection(OrderId.<OrderId>randomId(), 1, "Test Person", 0, Collections.<OrderLineProjection>emptyList(), PLACED)); |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepositoryTest.java | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderLineProjection.java
// public class OrderLineProjection {
//
// public ProductId productId;
//
// public String title;
//
// public int quantity;
//
// public long unitPrice;
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
//
// private final OrderId orderId;
// private final long orderPlacedTimestamp;
// private final long orderAmount;
// private final String customerName;
// private final List<OrderLineProjection> orderLines;
// private OrderStatus status;
//
// public OrderProjection(@JsonProperty("orderId") OrderId orderId,
// @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
// @JsonProperty("customerName") String customerName,
// @JsonProperty("orderAmount") long orderAmount,
// @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
// @JsonProperty("status") OrderStatus status) {
// this.orderId = orderId;
// this.orderPlacedTimestamp = orderPlacedTimestamp;
// this.customerName = customerName;
// this.orderAmount = orderAmount;
// this.orderLines = new ArrayList<>(orderLines);
// this.status = status;
// }
//
// public List<OrderLineProjection> getOrderLines() {
// return orderLines;
// }
//
// public OrderId getOrderId() {
// return orderId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public long getOrderAmount() {
// return orderAmount;
// }
//
// public OrderStatus getStatus() {
// return status;
// }
//
// public void setStatus(OrderStatus status) {
// this.status = status;
// }
//
// public long getOrderPlacedTimestamp() {
// return orderPlacedTimestamp;
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjectionRepository.java
// public interface OrderProjectionRepository {
//
// void save(OrderProjection orderProjection);
//
// OrderProjection getById(OrderId orderId);
//
// List<OrderProjection> listOrdersByTimestamp();
//
// }
| import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderLineProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjectionRepository;
import java.util.Collections;
import java.util.Iterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.PLACED; | package se.citerus.cqrs.bookstore.ordercontext.infrastructure;
public class InMemOrderProjectionRepositoryTest {
@Test
public void sortingOfOrders() {
OrderProjectionRepository repository = new InMemOrderProjectionRepository();
| // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderLineProjection.java
// public class OrderLineProjection {
//
// public ProductId productId;
//
// public String title;
//
// public int quantity;
//
// public long unitPrice;
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
//
// private final OrderId orderId;
// private final long orderPlacedTimestamp;
// private final long orderAmount;
// private final String customerName;
// private final List<OrderLineProjection> orderLines;
// private OrderStatus status;
//
// public OrderProjection(@JsonProperty("orderId") OrderId orderId,
// @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
// @JsonProperty("customerName") String customerName,
// @JsonProperty("orderAmount") long orderAmount,
// @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
// @JsonProperty("status") OrderStatus status) {
// this.orderId = orderId;
// this.orderPlacedTimestamp = orderPlacedTimestamp;
// this.customerName = customerName;
// this.orderAmount = orderAmount;
// this.orderLines = new ArrayList<>(orderLines);
// this.status = status;
// }
//
// public List<OrderLineProjection> getOrderLines() {
// return orderLines;
// }
//
// public OrderId getOrderId() {
// return orderId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public long getOrderAmount() {
// return orderAmount;
// }
//
// public OrderStatus getStatus() {
// return status;
// }
//
// public void setStatus(OrderStatus status) {
// this.status = status;
// }
//
// public long getOrderPlacedTimestamp() {
// return orderPlacedTimestamp;
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjectionRepository.java
// public interface OrderProjectionRepository {
//
// void save(OrderProjection orderProjection);
//
// OrderProjection getById(OrderId orderId);
//
// List<OrderProjection> listOrdersByTimestamp();
//
// }
// Path: order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepositoryTest.java
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderLineProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjectionRepository;
import java.util.Collections;
import java.util.Iterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.PLACED;
package se.citerus.cqrs.bookstore.ordercontext.infrastructure;
public class InMemOrderProjectionRepositoryTest {
@Test
public void sortingOfOrders() {
OrderProjectionRepository repository = new InMemOrderProjectionRepository();
| repository.save(new OrderProjection(OrderId.<OrderId>randomId(), 1, "Test Person", 0, Collections.<OrderLineProjection>emptyList(), PLACED)); |
citerus/bookstore-cqrs-example | order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepositoryTest.java | // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderLineProjection.java
// public class OrderLineProjection {
//
// public ProductId productId;
//
// public String title;
//
// public int quantity;
//
// public long unitPrice;
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
//
// private final OrderId orderId;
// private final long orderPlacedTimestamp;
// private final long orderAmount;
// private final String customerName;
// private final List<OrderLineProjection> orderLines;
// private OrderStatus status;
//
// public OrderProjection(@JsonProperty("orderId") OrderId orderId,
// @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
// @JsonProperty("customerName") String customerName,
// @JsonProperty("orderAmount") long orderAmount,
// @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
// @JsonProperty("status") OrderStatus status) {
// this.orderId = orderId;
// this.orderPlacedTimestamp = orderPlacedTimestamp;
// this.customerName = customerName;
// this.orderAmount = orderAmount;
// this.orderLines = new ArrayList<>(orderLines);
// this.status = status;
// }
//
// public List<OrderLineProjection> getOrderLines() {
// return orderLines;
// }
//
// public OrderId getOrderId() {
// return orderId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public long getOrderAmount() {
// return orderAmount;
// }
//
// public OrderStatus getStatus() {
// return status;
// }
//
// public void setStatus(OrderStatus status) {
// this.status = status;
// }
//
// public long getOrderPlacedTimestamp() {
// return orderPlacedTimestamp;
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjectionRepository.java
// public interface OrderProjectionRepository {
//
// void save(OrderProjection orderProjection);
//
// OrderProjection getById(OrderId orderId);
//
// List<OrderProjection> listOrdersByTimestamp();
//
// }
| import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderLineProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjectionRepository;
import java.util.Collections;
import java.util.Iterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.PLACED; | package se.citerus.cqrs.bookstore.ordercontext.infrastructure;
public class InMemOrderProjectionRepositoryTest {
@Test
public void sortingOfOrders() {
OrderProjectionRepository repository = new InMemOrderProjectionRepository();
| // Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderLineProjection.java
// public class OrderLineProjection {
//
// public ProductId productId;
//
// public String title;
//
// public int quantity;
//
// public long unitPrice;
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
//
// private final OrderId orderId;
// private final long orderPlacedTimestamp;
// private final long orderAmount;
// private final String customerName;
// private final List<OrderLineProjection> orderLines;
// private OrderStatus status;
//
// public OrderProjection(@JsonProperty("orderId") OrderId orderId,
// @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
// @JsonProperty("customerName") String customerName,
// @JsonProperty("orderAmount") long orderAmount,
// @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
// @JsonProperty("status") OrderStatus status) {
// this.orderId = orderId;
// this.orderPlacedTimestamp = orderPlacedTimestamp;
// this.customerName = customerName;
// this.orderAmount = orderAmount;
// this.orderLines = new ArrayList<>(orderLines);
// this.status = status;
// }
//
// public List<OrderLineProjection> getOrderLines() {
// return orderLines;
// }
//
// public OrderId getOrderId() {
// return orderId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public long getOrderAmount() {
// return orderAmount;
// }
//
// public OrderStatus getStatus() {
// return status;
// }
//
// public void setStatus(OrderStatus status) {
// this.status = status;
// }
//
// public long getOrderPlacedTimestamp() {
// return orderPlacedTimestamp;
// }
//
// }
//
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjectionRepository.java
// public interface OrderProjectionRepository {
//
// void save(OrderProjection orderProjection);
//
// OrderProjection getById(OrderId orderId);
//
// List<OrderProjection> listOrdersByTimestamp();
//
// }
// Path: order-context-parent/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepositoryTest.java
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderLineProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjectionRepository;
import java.util.Collections;
import java.util.Iterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderStatus.PLACED;
package se.citerus.cqrs.bookstore.ordercontext.infrastructure;
public class InMemOrderProjectionRepositoryTest {
@Test
public void sortingOfOrders() {
OrderProjectionRepository repository = new InMemOrderProjectionRepository();
| repository.save(new OrderProjection(OrderId.<OrderId>randomId(), 1, "Test Person", 0, Collections.<OrderLineProjection>emptyList(), PLACED)); |
citerus/bookstore-cqrs-example | order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/DefaultRepository.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public class GenericId {
//
// public final String id;
//
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
//
// public GenericId(String id) {
// this.id = id;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return id;
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/Repository.java
// public interface Repository {
//
// <AR extends AggregateRoot> void save(AR aggregateRoot);
//
// <AR extends AggregateRoot, ID extends GenericId> AR load(ID id, Class<AR> aggregateType);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventBus.java
// public interface DomainEventBus {
//
// void publish(List<DomainEvent> events);
//
// void republish(List<DomainEvent> events);
//
// <T extends DomainEventListener> T register(T listener);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
| import se.citerus.cqrs.bookstore.GenericId;
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.domain.Repository;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventBus;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import java.util.List;
import static java.lang.String.format; | package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class DefaultRepository implements Repository {
private final DomainEventBus domainEventBus; | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public class GenericId {
//
// public final String id;
//
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
//
// public GenericId(String id) {
// this.id = id;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return id;
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/Repository.java
// public interface Repository {
//
// <AR extends AggregateRoot> void save(AR aggregateRoot);
//
// <AR extends AggregateRoot, ID extends GenericId> AR load(ID id, Class<AR> aggregateType);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventBus.java
// public interface DomainEventBus {
//
// void publish(List<DomainEvent> events);
//
// void republish(List<DomainEvent> events);
//
// <T extends DomainEventListener> T register(T listener);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
// Path: order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/DefaultRepository.java
import se.citerus.cqrs.bookstore.GenericId;
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.domain.Repository;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventBus;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import java.util.List;
import static java.lang.String.format;
package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class DefaultRepository implements Repository {
private final DomainEventBus domainEventBus; | private final DomainEventStore domainEventStore; |
citerus/bookstore-cqrs-example | order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/DefaultRepository.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public class GenericId {
//
// public final String id;
//
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
//
// public GenericId(String id) {
// this.id = id;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return id;
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/Repository.java
// public interface Repository {
//
// <AR extends AggregateRoot> void save(AR aggregateRoot);
//
// <AR extends AggregateRoot, ID extends GenericId> AR load(ID id, Class<AR> aggregateType);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventBus.java
// public interface DomainEventBus {
//
// void publish(List<DomainEvent> events);
//
// void republish(List<DomainEvent> events);
//
// <T extends DomainEventListener> T register(T listener);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
| import se.citerus.cqrs.bookstore.GenericId;
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.domain.Repository;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventBus;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import java.util.List;
import static java.lang.String.format; | package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class DefaultRepository implements Repository {
private final DomainEventBus domainEventBus;
private final DomainEventStore domainEventStore;
public DefaultRepository(DomainEventBus domainEventBus, DomainEventStore domainEventStore) {
this.domainEventBus = domainEventBus;
this.domainEventStore = domainEventStore;
}
@Override | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public class GenericId {
//
// public final String id;
//
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
//
// public GenericId(String id) {
// this.id = id;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return id;
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/Repository.java
// public interface Repository {
//
// <AR extends AggregateRoot> void save(AR aggregateRoot);
//
// <AR extends AggregateRoot, ID extends GenericId> AR load(ID id, Class<AR> aggregateType);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventBus.java
// public interface DomainEventBus {
//
// void publish(List<DomainEvent> events);
//
// void republish(List<DomainEvent> events);
//
// <T extends DomainEventListener> T register(T listener);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
// Path: order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/DefaultRepository.java
import se.citerus.cqrs.bookstore.GenericId;
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.domain.Repository;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventBus;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import java.util.List;
import static java.lang.String.format;
package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class DefaultRepository implements Repository {
private final DomainEventBus domainEventBus;
private final DomainEventStore domainEventStore;
public DefaultRepository(DomainEventBus domainEventBus, DomainEventStore domainEventStore) {
this.domainEventBus = domainEventBus;
this.domainEventStore = domainEventStore;
}
@Override | public <AR extends AggregateRoot> void save(AR aggregateRoot) { |
citerus/bookstore-cqrs-example | order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/DefaultRepository.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public class GenericId {
//
// public final String id;
//
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
//
// public GenericId(String id) {
// this.id = id;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return id;
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/Repository.java
// public interface Repository {
//
// <AR extends AggregateRoot> void save(AR aggregateRoot);
//
// <AR extends AggregateRoot, ID extends GenericId> AR load(ID id, Class<AR> aggregateType);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventBus.java
// public interface DomainEventBus {
//
// void publish(List<DomainEvent> events);
//
// void republish(List<DomainEvent> events);
//
// <T extends DomainEventListener> T register(T listener);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
| import se.citerus.cqrs.bookstore.GenericId;
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.domain.Repository;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventBus;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import java.util.List;
import static java.lang.String.format; | package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class DefaultRepository implements Repository {
private final DomainEventBus domainEventBus;
private final DomainEventStore domainEventStore;
public DefaultRepository(DomainEventBus domainEventBus, DomainEventStore domainEventStore) {
this.domainEventBus = domainEventBus;
this.domainEventStore = domainEventStore;
}
@Override
public <AR extends AggregateRoot> void save(AR aggregateRoot) {
if (aggregateRoot.hasUncommittedEvents()) { | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public class GenericId {
//
// public final String id;
//
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
//
// public GenericId(String id) {
// this.id = id;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return id;
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/Repository.java
// public interface Repository {
//
// <AR extends AggregateRoot> void save(AR aggregateRoot);
//
// <AR extends AggregateRoot, ID extends GenericId> AR load(ID id, Class<AR> aggregateType);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventBus.java
// public interface DomainEventBus {
//
// void publish(List<DomainEvent> events);
//
// void republish(List<DomainEvent> events);
//
// <T extends DomainEventListener> T register(T listener);
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
// Path: order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/DefaultRepository.java
import se.citerus.cqrs.bookstore.GenericId;
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.domain.Repository;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventBus;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import java.util.List;
import static java.lang.String.format;
package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class DefaultRepository implements Repository {
private final DomainEventBus domainEventBus;
private final DomainEventStore domainEventStore;
public DefaultRepository(DomainEventBus domainEventBus, DomainEventStore domainEventStore) {
this.domainEventBus = domainEventBus;
this.domainEventStore = domainEventStore;
}
@Override
public <AR extends AggregateRoot> void save(AR aggregateRoot) {
if (aggregateRoot.hasUncommittedEvents()) { | List<DomainEvent> newEvents = aggregateRoot.getUncommittedEvents(); |
citerus/bookstore-cqrs-example | product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/application/ProductCatalogApplication.java | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/infrastructure/InMemoryProductRepository.java
// public class InMemoryProductRepository implements ProductRepository {
//
// private Map<String, Product> products = new HashMap<>();
//
// private static final Comparator<Product> PRODUCT_COMPARATOR = new Comparator<Product>() {
// @Override
// public int compare(Product o1, Product o2) {
// return o1.book.title.compareTo(o2.book.title);
// }
// };
//
// @Override
// public List<Product> getProducts() {
// List<Product> values = new ArrayList<>(products.values());
// Collections.sort(values, PRODUCT_COMPARATOR);
// return values;
// }
//
// @Override
// public Product getProduct(String productId) {
// return products.get(productId);
// }
//
// @Override
// public void save(Product product) {
// this.products.put(product.productId, product);
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResource.java
// @Path("products")
// @Produces(APPLICATION_JSON)
// @Consumes(APPLICATION_JSON)
// public class ProductResource {
//
// private final Logger logger = LoggerFactory.getLogger(getClass());
// private ProductRepository productRepository;
//
// public ProductResource(ProductRepository productRepository) {
// this.productRepository = productRepository;
// }
//
// @GET
// @Path("{productId}")
// public ProductDto getProduct(@PathParam("productId") String productId) {
// Product product = productRepository.getProduct(productId);
// if (product == null) {
// throw new IllegalArgumentException("No such product: " + productId);
// }
// logger.info("Returning product with id [{}]", product.productId);
// return ProductDtoFactory.fromProduct(product);
// }
//
// @POST
// public void createProduct(@Valid ProductDto request) {
// BookDto bookDto = request.book;
// Book book = new Book(request.book.bookId, bookDto.isbn, bookDto.title, bookDto.description);
// Product product = new Product(request.productId, book, request.price, request.publisherContractId);
// logger.info("Saving product with id [{}]", request.productId);
// productRepository.save(product);
// }
//
// @GET
// public Collection<ProductDto> getProducts() {
// Collection<ProductDto> products = new ArrayList<>();
// for (Product product : productRepository.getProducts()) {
// products.add(ProductDtoFactory.fromProduct(product));
// }
// logger.info("Returning [{}] products", products.size());
// return products;
// }
//
// }
| import com.fasterxml.jackson.databind.ObjectMapper;
import io.dropwizard.Application;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import org.eclipse.jetty.servlets.CrossOriginFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.productcatalog.infrastructure.InMemoryProductRepository;
import se.citerus.cqrs.bookstore.productcatalog.resource.ProductResource;
import javax.servlet.DispatcherType;
import javax.servlet.FilterRegistration;
import java.util.EnumSet;
import static com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT;
import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS; | package se.citerus.cqrs.bookstore.productcatalog.application;
public class ProductCatalogApplication extends Application<ProductCatalogConfig> {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void initialize(Bootstrap<ProductCatalogConfig> bootstrap) {
}
@Override
public void run(ProductCatalogConfig configuration, Environment environment) {
ObjectMapper objectMapper = environment.getObjectMapper();
objectMapper.enable(INDENT_OUTPUT);
objectMapper.enable(WRITE_DATES_AS_TIMESTAMPS);
| // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/infrastructure/InMemoryProductRepository.java
// public class InMemoryProductRepository implements ProductRepository {
//
// private Map<String, Product> products = new HashMap<>();
//
// private static final Comparator<Product> PRODUCT_COMPARATOR = new Comparator<Product>() {
// @Override
// public int compare(Product o1, Product o2) {
// return o1.book.title.compareTo(o2.book.title);
// }
// };
//
// @Override
// public List<Product> getProducts() {
// List<Product> values = new ArrayList<>(products.values());
// Collections.sort(values, PRODUCT_COMPARATOR);
// return values;
// }
//
// @Override
// public Product getProduct(String productId) {
// return products.get(productId);
// }
//
// @Override
// public void save(Product product) {
// this.products.put(product.productId, product);
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResource.java
// @Path("products")
// @Produces(APPLICATION_JSON)
// @Consumes(APPLICATION_JSON)
// public class ProductResource {
//
// private final Logger logger = LoggerFactory.getLogger(getClass());
// private ProductRepository productRepository;
//
// public ProductResource(ProductRepository productRepository) {
// this.productRepository = productRepository;
// }
//
// @GET
// @Path("{productId}")
// public ProductDto getProduct(@PathParam("productId") String productId) {
// Product product = productRepository.getProduct(productId);
// if (product == null) {
// throw new IllegalArgumentException("No such product: " + productId);
// }
// logger.info("Returning product with id [{}]", product.productId);
// return ProductDtoFactory.fromProduct(product);
// }
//
// @POST
// public void createProduct(@Valid ProductDto request) {
// BookDto bookDto = request.book;
// Book book = new Book(request.book.bookId, bookDto.isbn, bookDto.title, bookDto.description);
// Product product = new Product(request.productId, book, request.price, request.publisherContractId);
// logger.info("Saving product with id [{}]", request.productId);
// productRepository.save(product);
// }
//
// @GET
// public Collection<ProductDto> getProducts() {
// Collection<ProductDto> products = new ArrayList<>();
// for (Product product : productRepository.getProducts()) {
// products.add(ProductDtoFactory.fromProduct(product));
// }
// logger.info("Returning [{}] products", products.size());
// return products;
// }
//
// }
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/application/ProductCatalogApplication.java
import com.fasterxml.jackson.databind.ObjectMapper;
import io.dropwizard.Application;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import org.eclipse.jetty.servlets.CrossOriginFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.productcatalog.infrastructure.InMemoryProductRepository;
import se.citerus.cqrs.bookstore.productcatalog.resource.ProductResource;
import javax.servlet.DispatcherType;
import javax.servlet.FilterRegistration;
import java.util.EnumSet;
import static com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT;
import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS;
package se.citerus.cqrs.bookstore.productcatalog.application;
public class ProductCatalogApplication extends Application<ProductCatalogConfig> {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void initialize(Bootstrap<ProductCatalogConfig> bootstrap) {
}
@Override
public void run(ProductCatalogConfig configuration, Environment environment) {
ObjectMapper objectMapper = environment.getObjectMapper();
objectMapper.enable(INDENT_OUTPUT);
objectMapper.enable(WRITE_DATES_AS_TIMESTAMPS);
| environment.jersey().register(new ProductResource(new InMemoryProductRepository())); |
citerus/bookstore-cqrs-example | product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/application/ProductCatalogApplication.java | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/infrastructure/InMemoryProductRepository.java
// public class InMemoryProductRepository implements ProductRepository {
//
// private Map<String, Product> products = new HashMap<>();
//
// private static final Comparator<Product> PRODUCT_COMPARATOR = new Comparator<Product>() {
// @Override
// public int compare(Product o1, Product o2) {
// return o1.book.title.compareTo(o2.book.title);
// }
// };
//
// @Override
// public List<Product> getProducts() {
// List<Product> values = new ArrayList<>(products.values());
// Collections.sort(values, PRODUCT_COMPARATOR);
// return values;
// }
//
// @Override
// public Product getProduct(String productId) {
// return products.get(productId);
// }
//
// @Override
// public void save(Product product) {
// this.products.put(product.productId, product);
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResource.java
// @Path("products")
// @Produces(APPLICATION_JSON)
// @Consumes(APPLICATION_JSON)
// public class ProductResource {
//
// private final Logger logger = LoggerFactory.getLogger(getClass());
// private ProductRepository productRepository;
//
// public ProductResource(ProductRepository productRepository) {
// this.productRepository = productRepository;
// }
//
// @GET
// @Path("{productId}")
// public ProductDto getProduct(@PathParam("productId") String productId) {
// Product product = productRepository.getProduct(productId);
// if (product == null) {
// throw new IllegalArgumentException("No such product: " + productId);
// }
// logger.info("Returning product with id [{}]", product.productId);
// return ProductDtoFactory.fromProduct(product);
// }
//
// @POST
// public void createProduct(@Valid ProductDto request) {
// BookDto bookDto = request.book;
// Book book = new Book(request.book.bookId, bookDto.isbn, bookDto.title, bookDto.description);
// Product product = new Product(request.productId, book, request.price, request.publisherContractId);
// logger.info("Saving product with id [{}]", request.productId);
// productRepository.save(product);
// }
//
// @GET
// public Collection<ProductDto> getProducts() {
// Collection<ProductDto> products = new ArrayList<>();
// for (Product product : productRepository.getProducts()) {
// products.add(ProductDtoFactory.fromProduct(product));
// }
// logger.info("Returning [{}] products", products.size());
// return products;
// }
//
// }
| import com.fasterxml.jackson.databind.ObjectMapper;
import io.dropwizard.Application;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import org.eclipse.jetty.servlets.CrossOriginFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.productcatalog.infrastructure.InMemoryProductRepository;
import se.citerus.cqrs.bookstore.productcatalog.resource.ProductResource;
import javax.servlet.DispatcherType;
import javax.servlet.FilterRegistration;
import java.util.EnumSet;
import static com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT;
import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS; | package se.citerus.cqrs.bookstore.productcatalog.application;
public class ProductCatalogApplication extends Application<ProductCatalogConfig> {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void initialize(Bootstrap<ProductCatalogConfig> bootstrap) {
}
@Override
public void run(ProductCatalogConfig configuration, Environment environment) {
ObjectMapper objectMapper = environment.getObjectMapper();
objectMapper.enable(INDENT_OUTPUT);
objectMapper.enable(WRITE_DATES_AS_TIMESTAMPS);
| // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/infrastructure/InMemoryProductRepository.java
// public class InMemoryProductRepository implements ProductRepository {
//
// private Map<String, Product> products = new HashMap<>();
//
// private static final Comparator<Product> PRODUCT_COMPARATOR = new Comparator<Product>() {
// @Override
// public int compare(Product o1, Product o2) {
// return o1.book.title.compareTo(o2.book.title);
// }
// };
//
// @Override
// public List<Product> getProducts() {
// List<Product> values = new ArrayList<>(products.values());
// Collections.sort(values, PRODUCT_COMPARATOR);
// return values;
// }
//
// @Override
// public Product getProduct(String productId) {
// return products.get(productId);
// }
//
// @Override
// public void save(Product product) {
// this.products.put(product.productId, product);
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResource.java
// @Path("products")
// @Produces(APPLICATION_JSON)
// @Consumes(APPLICATION_JSON)
// public class ProductResource {
//
// private final Logger logger = LoggerFactory.getLogger(getClass());
// private ProductRepository productRepository;
//
// public ProductResource(ProductRepository productRepository) {
// this.productRepository = productRepository;
// }
//
// @GET
// @Path("{productId}")
// public ProductDto getProduct(@PathParam("productId") String productId) {
// Product product = productRepository.getProduct(productId);
// if (product == null) {
// throw new IllegalArgumentException("No such product: " + productId);
// }
// logger.info("Returning product with id [{}]", product.productId);
// return ProductDtoFactory.fromProduct(product);
// }
//
// @POST
// public void createProduct(@Valid ProductDto request) {
// BookDto bookDto = request.book;
// Book book = new Book(request.book.bookId, bookDto.isbn, bookDto.title, bookDto.description);
// Product product = new Product(request.productId, book, request.price, request.publisherContractId);
// logger.info("Saving product with id [{}]", request.productId);
// productRepository.save(product);
// }
//
// @GET
// public Collection<ProductDto> getProducts() {
// Collection<ProductDto> products = new ArrayList<>();
// for (Product product : productRepository.getProducts()) {
// products.add(ProductDtoFactory.fromProduct(product));
// }
// logger.info("Returning [{}] products", products.size());
// return products;
// }
//
// }
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/application/ProductCatalogApplication.java
import com.fasterxml.jackson.databind.ObjectMapper;
import io.dropwizard.Application;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import org.eclipse.jetty.servlets.CrossOriginFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.productcatalog.infrastructure.InMemoryProductRepository;
import se.citerus.cqrs.bookstore.productcatalog.resource.ProductResource;
import javax.servlet.DispatcherType;
import javax.servlet.FilterRegistration;
import java.util.EnumSet;
import static com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT;
import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS;
package se.citerus.cqrs.bookstore.productcatalog.application;
public class ProductCatalogApplication extends Application<ProductCatalogConfig> {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void initialize(Bootstrap<ProductCatalogConfig> bootstrap) {
}
@Override
public void run(ProductCatalogConfig configuration, Environment environment) {
ObjectMapper objectMapper = environment.getObjectMapper();
objectMapper.enable(INDENT_OUTPUT);
objectMapper.enable(WRITE_DATES_AS_TIMESTAMPS);
| environment.jersey().register(new ProductResource(new InMemoryProductRepository())); |
citerus/bookstore-cqrs-example | product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResource.java | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/BookDto.java
// public class BookDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String bookId;
//
// @NotEmpty
// public String isbn;
//
// @NotEmpty
// public String title;
//
// @NotNull
// public String description;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.productcatalog.api.BookDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.validation.Valid;
import javax.ws.rs.*;
import java.util.ArrayList;
import java.util.Collection;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.productcatalog.resource;
@Path("products")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class ProductResource {
private final Logger logger = LoggerFactory.getLogger(getClass()); | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/BookDto.java
// public class BookDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String bookId;
//
// @NotEmpty
// public String isbn;
//
// @NotEmpty
// public String title;
//
// @NotNull
// public String description;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResource.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.productcatalog.api.BookDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.validation.Valid;
import javax.ws.rs.*;
import java.util.ArrayList;
import java.util.Collection;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.productcatalog.resource;
@Path("products")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class ProductResource {
private final Logger logger = LoggerFactory.getLogger(getClass()); | private ProductRepository productRepository; |
citerus/bookstore-cqrs-example | product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResource.java | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/BookDto.java
// public class BookDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String bookId;
//
// @NotEmpty
// public String isbn;
//
// @NotEmpty
// public String title;
//
// @NotNull
// public String description;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.productcatalog.api.BookDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.validation.Valid;
import javax.ws.rs.*;
import java.util.ArrayList;
import java.util.Collection;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.productcatalog.resource;
@Path("products")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class ProductResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private ProductRepository productRepository;
public ProductResource(ProductRepository productRepository) {
this.productRepository = productRepository;
}
@GET
@Path("{productId}") | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/BookDto.java
// public class BookDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String bookId;
//
// @NotEmpty
// public String isbn;
//
// @NotEmpty
// public String title;
//
// @NotNull
// public String description;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResource.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.productcatalog.api.BookDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.validation.Valid;
import javax.ws.rs.*;
import java.util.ArrayList;
import java.util.Collection;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.productcatalog.resource;
@Path("products")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class ProductResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private ProductRepository productRepository;
public ProductResource(ProductRepository productRepository) {
this.productRepository = productRepository;
}
@GET
@Path("{productId}") | public ProductDto getProduct(@PathParam("productId") String productId) { |
citerus/bookstore-cqrs-example | product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResource.java | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/BookDto.java
// public class BookDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String bookId;
//
// @NotEmpty
// public String isbn;
//
// @NotEmpty
// public String title;
//
// @NotNull
// public String description;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.productcatalog.api.BookDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.validation.Valid;
import javax.ws.rs.*;
import java.util.ArrayList;
import java.util.Collection;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.productcatalog.resource;
@Path("products")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class ProductResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private ProductRepository productRepository;
public ProductResource(ProductRepository productRepository) {
this.productRepository = productRepository;
}
@GET
@Path("{productId}")
public ProductDto getProduct(@PathParam("productId") String productId) { | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/BookDto.java
// public class BookDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String bookId;
//
// @NotEmpty
// public String isbn;
//
// @NotEmpty
// public String title;
//
// @NotNull
// public String description;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResource.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.productcatalog.api.BookDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.validation.Valid;
import javax.ws.rs.*;
import java.util.ArrayList;
import java.util.Collection;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.productcatalog.resource;
@Path("products")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class ProductResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private ProductRepository productRepository;
public ProductResource(ProductRepository productRepository) {
this.productRepository = productRepository;
}
@GET
@Path("{productId}")
public ProductDto getProduct(@PathParam("productId") String productId) { | Product product = productRepository.getProduct(productId); |
citerus/bookstore-cqrs-example | product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResource.java | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/BookDto.java
// public class BookDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String bookId;
//
// @NotEmpty
// public String isbn;
//
// @NotEmpty
// public String title;
//
// @NotNull
// public String description;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.productcatalog.api.BookDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.validation.Valid;
import javax.ws.rs.*;
import java.util.ArrayList;
import java.util.Collection;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.productcatalog.resource;
@Path("products")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class ProductResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private ProductRepository productRepository;
public ProductResource(ProductRepository productRepository) {
this.productRepository = productRepository;
}
@GET
@Path("{productId}")
public ProductDto getProduct(@PathParam("productId") String productId) {
Product product = productRepository.getProduct(productId);
if (product == null) {
throw new IllegalArgumentException("No such product: " + productId);
}
logger.info("Returning product with id [{}]", product.productId); | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/BookDto.java
// public class BookDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String bookId;
//
// @NotEmpty
// public String isbn;
//
// @NotEmpty
// public String title;
//
// @NotNull
// public String description;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResource.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.productcatalog.api.BookDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.validation.Valid;
import javax.ws.rs.*;
import java.util.ArrayList;
import java.util.Collection;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.productcatalog.resource;
@Path("products")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class ProductResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private ProductRepository productRepository;
public ProductResource(ProductRepository productRepository) {
this.productRepository = productRepository;
}
@GET
@Path("{productId}")
public ProductDto getProduct(@PathParam("productId") String productId) {
Product product = productRepository.getProduct(productId);
if (product == null) {
throw new IllegalArgumentException("No such product: " + productId);
}
logger.info("Returning product with id [{}]", product.productId); | return ProductDtoFactory.fromProduct(product); |
citerus/bookstore-cqrs-example | product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResource.java | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/BookDto.java
// public class BookDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String bookId;
//
// @NotEmpty
// public String isbn;
//
// @NotEmpty
// public String title;
//
// @NotNull
// public String description;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.productcatalog.api.BookDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.validation.Valid;
import javax.ws.rs.*;
import java.util.ArrayList;
import java.util.Collection;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.productcatalog.resource;
@Path("products")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class ProductResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private ProductRepository productRepository;
public ProductResource(ProductRepository productRepository) {
this.productRepository = productRepository;
}
@GET
@Path("{productId}")
public ProductDto getProduct(@PathParam("productId") String productId) {
Product product = productRepository.getProduct(productId);
if (product == null) {
throw new IllegalArgumentException("No such product: " + productId);
}
logger.info("Returning product with id [{}]", product.productId);
return ProductDtoFactory.fromProduct(product);
}
@POST
public void createProduct(@Valid ProductDto request) { | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/BookDto.java
// public class BookDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String bookId;
//
// @NotEmpty
// public String isbn;
//
// @NotEmpty
// public String title;
//
// @NotNull
// public String description;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResource.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.productcatalog.api.BookDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.validation.Valid;
import javax.ws.rs.*;
import java.util.ArrayList;
import java.util.Collection;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.productcatalog.resource;
@Path("products")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class ProductResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private ProductRepository productRepository;
public ProductResource(ProductRepository productRepository) {
this.productRepository = productRepository;
}
@GET
@Path("{productId}")
public ProductDto getProduct(@PathParam("productId") String productId) {
Product product = productRepository.getProduct(productId);
if (product == null) {
throw new IllegalArgumentException("No such product: " + productId);
}
logger.info("Returning product with id [{}]", product.productId);
return ProductDtoFactory.fromProduct(product);
}
@POST
public void createProduct(@Valid ProductDto request) { | BookDto bookDto = request.book; |
citerus/bookstore-cqrs-example | product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResource.java | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/BookDto.java
// public class BookDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String bookId;
//
// @NotEmpty
// public String isbn;
//
// @NotEmpty
// public String title;
//
// @NotNull
// public String description;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.productcatalog.api.BookDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.validation.Valid;
import javax.ws.rs.*;
import java.util.ArrayList;
import java.util.Collection;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | package se.citerus.cqrs.bookstore.productcatalog.resource;
@Path("products")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class ProductResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private ProductRepository productRepository;
public ProductResource(ProductRepository productRepository) {
this.productRepository = productRepository;
}
@GET
@Path("{productId}")
public ProductDto getProduct(@PathParam("productId") String productId) {
Product product = productRepository.getProduct(productId);
if (product == null) {
throw new IllegalArgumentException("No such product: " + productId);
}
logger.info("Returning product with id [{}]", product.productId);
return ProductDtoFactory.fromProduct(product);
}
@POST
public void createProduct(@Valid ProductDto request) {
BookDto bookDto = request.book; | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/BookDto.java
// public class BookDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String bookId;
//
// @NotEmpty
// public String isbn;
//
// @NotEmpty
// public String title;
//
// @NotNull
// public String description;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResource.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.productcatalog.api.BookDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.validation.Valid;
import javax.ws.rs.*;
import java.util.ArrayList;
import java.util.Collection;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
package se.citerus.cqrs.bookstore.productcatalog.resource;
@Path("products")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public class ProductResource {
private final Logger logger = LoggerFactory.getLogger(getClass());
private ProductRepository productRepository;
public ProductResource(ProductRepository productRepository) {
this.productRepository = productRepository;
}
@GET
@Path("{productId}")
public ProductDto getProduct(@PathParam("productId") String productId) {
Product product = productRepository.getProduct(productId);
if (product == null) {
throw new IllegalArgumentException("No such product: " + productId);
}
logger.info("Returning product with id [{}]", product.productId);
return ProductDtoFactory.fromProduct(product);
}
@POST
public void createProduct(@Valid ProductDto request) {
BookDto bookDto = request.book; | Book book = new Book(request.book.bookId, bookDto.isbn, bookDto.title, bookDto.description); |
citerus/bookstore-cqrs-example | product-catalog-context/src/test/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResourceTest.java | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
| import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.ws.rs.core.GenericType;
import java.util.Collection;
import java.util.UUID;
import static java.util.Arrays.asList;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*; | package se.citerus.cqrs.bookstore.productcatalog.resource;
public class ProductResourceTest {
private static final String PRODUCT_RESOURCE = "/products"; | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
// Path: product-catalog-context/src/test/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResourceTest.java
import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.ws.rs.core.GenericType;
import java.util.Collection;
import java.util.UUID;
import static java.util.Arrays.asList;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
package se.citerus.cqrs.bookstore.productcatalog.resource;
public class ProductResourceTest {
private static final String PRODUCT_RESOURCE = "/products"; | private static final GenericType<Collection<ProductDto>> PRODUCTS_COLLECTION_TYPE = |
citerus/bookstore-cqrs-example | product-catalog-context/src/test/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResourceTest.java | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
| import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.ws.rs.core.GenericType;
import java.util.Collection;
import java.util.UUID;
import static java.util.Arrays.asList;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*; | package se.citerus.cqrs.bookstore.productcatalog.resource;
public class ProductResourceTest {
private static final String PRODUCT_RESOURCE = "/products";
private static final GenericType<Collection<ProductDto>> PRODUCTS_COLLECTION_TYPE =
new GenericType<Collection<ProductDto>>() {
};
| // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
// Path: product-catalog-context/src/test/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResourceTest.java
import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.ws.rs.core.GenericType;
import java.util.Collection;
import java.util.UUID;
import static java.util.Arrays.asList;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
package se.citerus.cqrs.bookstore.productcatalog.resource;
public class ProductResourceTest {
private static final String PRODUCT_RESOURCE = "/products";
private static final GenericType<Collection<ProductDto>> PRODUCTS_COLLECTION_TYPE =
new GenericType<Collection<ProductDto>>() {
};
| private static ProductRepository productRepository = mock(ProductRepository.class); |
citerus/bookstore-cqrs-example | product-catalog-context/src/test/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResourceTest.java | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
| import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.ws.rs.core.GenericType;
import java.util.Collection;
import java.util.UUID;
import static java.util.Arrays.asList;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*; | package se.citerus.cqrs.bookstore.productcatalog.resource;
public class ProductResourceTest {
private static final String PRODUCT_RESOURCE = "/products";
private static final GenericType<Collection<ProductDto>> PRODUCTS_COLLECTION_TYPE =
new GenericType<Collection<ProductDto>>() {
};
private static ProductRepository productRepository = mock(ProductRepository.class);
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new ProductResource(productRepository))
.build();
@After
public void tearDown() throws Exception {
reset(productRepository);
}
@Test
public void getProductsRequest() { | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
// Path: product-catalog-context/src/test/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResourceTest.java
import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.ws.rs.core.GenericType;
import java.util.Collection;
import java.util.UUID;
import static java.util.Arrays.asList;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
package se.citerus.cqrs.bookstore.productcatalog.resource;
public class ProductResourceTest {
private static final String PRODUCT_RESOURCE = "/products";
private static final GenericType<Collection<ProductDto>> PRODUCTS_COLLECTION_TYPE =
new GenericType<Collection<ProductDto>>() {
};
private static ProductRepository productRepository = mock(ProductRepository.class);
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new ProductResource(productRepository))
.build();
@After
public void tearDown() throws Exception {
reset(productRepository);
}
@Test
public void getProductsRequest() { | Book book = new Book(UUID.randomUUID().toString(), "1234567890", "Book Title", ""); |
citerus/bookstore-cqrs-example | product-catalog-context/src/test/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResourceTest.java | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
| import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.ws.rs.core.GenericType;
import java.util.Collection;
import java.util.UUID;
import static java.util.Arrays.asList;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*; | package se.citerus.cqrs.bookstore.productcatalog.resource;
public class ProductResourceTest {
private static final String PRODUCT_RESOURCE = "/products";
private static final GenericType<Collection<ProductDto>> PRODUCTS_COLLECTION_TYPE =
new GenericType<Collection<ProductDto>>() {
};
private static ProductRepository productRepository = mock(ProductRepository.class);
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new ProductResource(productRepository))
.build();
@After
public void tearDown() throws Exception {
reset(productRepository);
}
@Test
public void getProductsRequest() {
Book book = new Book(UUID.randomUUID().toString(), "1234567890", "Book Title", ""); | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
// Path: product-catalog-context/src/test/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResourceTest.java
import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.ws.rs.core.GenericType;
import java.util.Collection;
import java.util.UUID;
import static java.util.Arrays.asList;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
package se.citerus.cqrs.bookstore.productcatalog.resource;
public class ProductResourceTest {
private static final String PRODUCT_RESOURCE = "/products";
private static final GenericType<Collection<ProductDto>> PRODUCTS_COLLECTION_TYPE =
new GenericType<Collection<ProductDto>>() {
};
private static ProductRepository productRepository = mock(ProductRepository.class);
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new ProductResource(productRepository))
.build();
@After
public void tearDown() throws Exception {
reset(productRepository);
}
@Test
public void getProductsRequest() {
Book book = new Book(UUID.randomUUID().toString(), "1234567890", "Book Title", ""); | Product product = new Product(UUID.randomUUID().toString(), book, 1000L, null); |
citerus/bookstore-cqrs-example | product-catalog-context/src/test/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResourceTest.java | // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
| import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.ws.rs.core.GenericType;
import java.util.Collection;
import java.util.UUID;
import static java.util.Arrays.asList;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*; | package se.citerus.cqrs.bookstore.productcatalog.resource;
public class ProductResourceTest {
private static final String PRODUCT_RESOURCE = "/products";
private static final GenericType<Collection<ProductDto>> PRODUCTS_COLLECTION_TYPE =
new GenericType<Collection<ProductDto>>() {
};
private static ProductRepository productRepository = mock(ProductRepository.class);
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new ProductResource(productRepository))
.build();
@After
public void tearDown() throws Exception {
reset(productRepository);
}
@Test
public void getProductsRequest() {
Book book = new Book(UUID.randomUUID().toString(), "1234567890", "Book Title", "");
Product product = new Product(UUID.randomUUID().toString(), book, 1000L, null);
when(productRepository.getProducts()).thenReturn(asList(product));
Collection<ProductDto> products = resources.client()
.target(PRODUCT_RESOURCE)
.request(APPLICATION_JSON_TYPE)
.get(PRODUCTS_COLLECTION_TYPE);
| // Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDto.java
// public class ProductDto extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @Valid
// public BookDto book;
//
// @Min(0)
// public long price;
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String publisherContractId;
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
// public class ProductDtoFactory {
//
// public static ProductDto fromProduct(Product product) {
// return toProduct(product, toBook(product.book));
// }
//
// private static ProductDto toProduct(Product product, BookDto bookDto) {
// ProductDto productDto = new ProductDto();
// productDto.productId = product.productId;
// productDto.price = product.price;
// productDto.publisherContractId = product.publisherContractId;
// productDto.book = bookDto;
// return productDto;
// }
//
// private static BookDto toBook(Book book) {
// BookDto bookDto = new BookDto();
// bookDto.bookId = book.bookId;
// bookDto.isbn = book.isbn;
// bookDto.title = book.title;
// bookDto.description = book.description;
// return bookDto;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
//
// public final String bookId;
// public final String isbn;
// public final String title;
// public final String description;
//
// public Book(String bookId, String isbn, String title, String description) {
// this.bookId = bookId;
// this.isbn = isbn;
// this.title = title;
// this.description = description;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
//
// public final String productId;
// public final Book book;
// public final long price;
// public final String publisherContractId;
//
// public Product(String productId, Book book, long price, String publisherContractId) {
// this.productId = productId;
// this.book = book;
// this.price = price;
// this.publisherContractId = publisherContractId;
// }
//
// }
//
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/ProductRepository.java
// public interface ProductRepository {
//
// Collection<Product> getProducts();
//
// Product getProduct(String productId);
//
// void save(Product product);
//
// }
// Path: product-catalog-context/src/test/java/se/citerus/cqrs/bookstore/productcatalog/resource/ProductResourceTest.java
import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDto;
import se.citerus.cqrs.bookstore.productcatalog.api.ProductDtoFactory;
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
import se.citerus.cqrs.bookstore.productcatalog.domain.ProductRepository;
import javax.ws.rs.core.GenericType;
import java.util.Collection;
import java.util.UUID;
import static java.util.Arrays.asList;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
package se.citerus.cqrs.bookstore.productcatalog.resource;
public class ProductResourceTest {
private static final String PRODUCT_RESOURCE = "/products";
private static final GenericType<Collection<ProductDto>> PRODUCTS_COLLECTION_TYPE =
new GenericType<Collection<ProductDto>>() {
};
private static ProductRepository productRepository = mock(ProductRepository.class);
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new ProductResource(productRepository))
.build();
@After
public void tearDown() throws Exception {
reset(productRepository);
}
@Test
public void getProductsRequest() {
Book book = new Book(UUID.randomUUID().toString(), "1234567890", "Book Title", "");
Product product = new Product(UUID.randomUUID().toString(), book, 1000L, null);
when(productRepository.getProducts()).thenReturn(asList(product));
Collection<ProductDto> products = resources.client()
.target(PRODUCT_RESOURCE)
.request(APPLICATION_JSON_TYPE)
.get(PRODUCTS_COLLECTION_TYPE);
| assertThat(products, hasItem(ProductDtoFactory.fromProduct(product))); |
citerus/bookstore-cqrs-example | shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/application/ShoppingApplication.java | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/domain/CartRepository.java
// public interface CartRepository {
//
// void save(Cart cart);
//
// Cart get(String cartId);
//
// Cart find(String cartId);
//
// void delete(String cartId);
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/resource/CartResource.java
// @Path("carts")
// @Produces(APPLICATION_JSON)
// @Consumes(APPLICATION_JSON)
// public class CartResource {
//
// private final Logger logger = LoggerFactory.getLogger(getClass());
// private final ProductCatalogClient productCatalogClient;
// private final CartRepository cartRepository;
//
// public CartResource(ProductCatalogClient productCatalogClient, CartRepository cartRepository) {
// this.productCatalogClient = productCatalogClient;
// this.cartRepository = cartRepository;
// }
//
// @POST
// public void initCart(@Valid CreateCartRequest cart) {
// cartRepository.save(new Cart(cart.cartId));
// }
//
// @POST
// @Path("{cartId}/items")
// public CartDto addItem(@PathParam("cartId") String cartId, AddItemRequest addItemRequest) {
// Cart cart = cartRepository.get(cartId);
// logger.debug("Got addItem request " + addItemRequest);
// ProductDto product = productCatalogClient.getProduct(addItemRequest.productId);
// assertProductExists(addItemRequest.productId, product);
// Item item = new Item(new ProductId(addItemRequest.productId), product.book.title, product.price);
// logger.info("Adding item to cart: " + item);
// cart.add(item);
// return CartDtoFactory.fromCart(cart);
// }
//
// @GET
// @Path("{cartId}")
// public Response getCart(@PathParam("cartId") String cartId) {
// Cart cart = cartRepository.find(cartId);
// if (cart == null) {
// return status(NOT_FOUND).entity(format("Cart with id '%s' does not exist", cartId)).build();
// } else {
// logger.info("Returning cart with [{}] lines", cart.getLineCount());
// return Response.ok().entity(CartDtoFactory.fromCart(cart)).build();
// }
// }
//
// @DELETE
// @Path("{cartId}")
// public void deleteCart(@PathParam("cartId") String cartId) {
// cartRepository.delete(cartId);
// logger.info("Shopping cart for session [{}] cleared", cartId);
// }
//
// private void assertProductExists(String productId, ProductDto product) {
// if (product == null) {
// throw new WebApplicationException(status(BAD_REQUEST)
// .entity("Product with id '" + productId + "' could not be found").build());
// }
// }
//
// }
| import io.dropwizard.Application;
import io.dropwizard.assets.AssetsBundle;
import io.dropwizard.client.JerseyClientBuilder;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.domain.CartRepository;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import se.citerus.cqrs.bookstore.shopping.resource.CartResource;
import javax.ws.rs.client.Client; | package se.citerus.cqrs.bookstore.shopping.application;
public class ShoppingApplication extends Application<ShoppingConfiguration> {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void initialize(Bootstrap<ShoppingConfiguration> bootstrap) {
bootstrap.addBundle(new AssetsBundle("/assets/", "/", "index.html"));
}
@Override
public void run(ShoppingConfiguration configuration, Environment environment) throws Exception { | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/domain/CartRepository.java
// public interface CartRepository {
//
// void save(Cart cart);
//
// Cart get(String cartId);
//
// Cart find(String cartId);
//
// void delete(String cartId);
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/resource/CartResource.java
// @Path("carts")
// @Produces(APPLICATION_JSON)
// @Consumes(APPLICATION_JSON)
// public class CartResource {
//
// private final Logger logger = LoggerFactory.getLogger(getClass());
// private final ProductCatalogClient productCatalogClient;
// private final CartRepository cartRepository;
//
// public CartResource(ProductCatalogClient productCatalogClient, CartRepository cartRepository) {
// this.productCatalogClient = productCatalogClient;
// this.cartRepository = cartRepository;
// }
//
// @POST
// public void initCart(@Valid CreateCartRequest cart) {
// cartRepository.save(new Cart(cart.cartId));
// }
//
// @POST
// @Path("{cartId}/items")
// public CartDto addItem(@PathParam("cartId") String cartId, AddItemRequest addItemRequest) {
// Cart cart = cartRepository.get(cartId);
// logger.debug("Got addItem request " + addItemRequest);
// ProductDto product = productCatalogClient.getProduct(addItemRequest.productId);
// assertProductExists(addItemRequest.productId, product);
// Item item = new Item(new ProductId(addItemRequest.productId), product.book.title, product.price);
// logger.info("Adding item to cart: " + item);
// cart.add(item);
// return CartDtoFactory.fromCart(cart);
// }
//
// @GET
// @Path("{cartId}")
// public Response getCart(@PathParam("cartId") String cartId) {
// Cart cart = cartRepository.find(cartId);
// if (cart == null) {
// return status(NOT_FOUND).entity(format("Cart with id '%s' does not exist", cartId)).build();
// } else {
// logger.info("Returning cart with [{}] lines", cart.getLineCount());
// return Response.ok().entity(CartDtoFactory.fromCart(cart)).build();
// }
// }
//
// @DELETE
// @Path("{cartId}")
// public void deleteCart(@PathParam("cartId") String cartId) {
// cartRepository.delete(cartId);
// logger.info("Shopping cart for session [{}] cleared", cartId);
// }
//
// private void assertProductExists(String productId, ProductDto product) {
// if (product == null) {
// throw new WebApplicationException(status(BAD_REQUEST)
// .entity("Product with id '" + productId + "' could not be found").build());
// }
// }
//
// }
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/application/ShoppingApplication.java
import io.dropwizard.Application;
import io.dropwizard.assets.AssetsBundle;
import io.dropwizard.client.JerseyClientBuilder;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.domain.CartRepository;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import se.citerus.cqrs.bookstore.shopping.resource.CartResource;
import javax.ws.rs.client.Client;
package se.citerus.cqrs.bookstore.shopping.application;
public class ShoppingApplication extends Application<ShoppingConfiguration> {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void initialize(Bootstrap<ShoppingConfiguration> bootstrap) {
bootstrap.addBundle(new AssetsBundle("/assets/", "/", "index.html"));
}
@Override
public void run(ShoppingConfiguration configuration, Environment environment) throws Exception { | CartRepository cartRepository = new InMemoryCartRepository(); |
citerus/bookstore-cqrs-example | shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/application/ShoppingApplication.java | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/domain/CartRepository.java
// public interface CartRepository {
//
// void save(Cart cart);
//
// Cart get(String cartId);
//
// Cart find(String cartId);
//
// void delete(String cartId);
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/resource/CartResource.java
// @Path("carts")
// @Produces(APPLICATION_JSON)
// @Consumes(APPLICATION_JSON)
// public class CartResource {
//
// private final Logger logger = LoggerFactory.getLogger(getClass());
// private final ProductCatalogClient productCatalogClient;
// private final CartRepository cartRepository;
//
// public CartResource(ProductCatalogClient productCatalogClient, CartRepository cartRepository) {
// this.productCatalogClient = productCatalogClient;
// this.cartRepository = cartRepository;
// }
//
// @POST
// public void initCart(@Valid CreateCartRequest cart) {
// cartRepository.save(new Cart(cart.cartId));
// }
//
// @POST
// @Path("{cartId}/items")
// public CartDto addItem(@PathParam("cartId") String cartId, AddItemRequest addItemRequest) {
// Cart cart = cartRepository.get(cartId);
// logger.debug("Got addItem request " + addItemRequest);
// ProductDto product = productCatalogClient.getProduct(addItemRequest.productId);
// assertProductExists(addItemRequest.productId, product);
// Item item = new Item(new ProductId(addItemRequest.productId), product.book.title, product.price);
// logger.info("Adding item to cart: " + item);
// cart.add(item);
// return CartDtoFactory.fromCart(cart);
// }
//
// @GET
// @Path("{cartId}")
// public Response getCart(@PathParam("cartId") String cartId) {
// Cart cart = cartRepository.find(cartId);
// if (cart == null) {
// return status(NOT_FOUND).entity(format("Cart with id '%s' does not exist", cartId)).build();
// } else {
// logger.info("Returning cart with [{}] lines", cart.getLineCount());
// return Response.ok().entity(CartDtoFactory.fromCart(cart)).build();
// }
// }
//
// @DELETE
// @Path("{cartId}")
// public void deleteCart(@PathParam("cartId") String cartId) {
// cartRepository.delete(cartId);
// logger.info("Shopping cart for session [{}] cleared", cartId);
// }
//
// private void assertProductExists(String productId, ProductDto product) {
// if (product == null) {
// throw new WebApplicationException(status(BAD_REQUEST)
// .entity("Product with id '" + productId + "' could not be found").build());
// }
// }
//
// }
| import io.dropwizard.Application;
import io.dropwizard.assets.AssetsBundle;
import io.dropwizard.client.JerseyClientBuilder;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.domain.CartRepository;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import se.citerus.cqrs.bookstore.shopping.resource.CartResource;
import javax.ws.rs.client.Client; | package se.citerus.cqrs.bookstore.shopping.application;
public class ShoppingApplication extends Application<ShoppingConfiguration> {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void initialize(Bootstrap<ShoppingConfiguration> bootstrap) {
bootstrap.addBundle(new AssetsBundle("/assets/", "/", "index.html"));
}
@Override
public void run(ShoppingConfiguration configuration, Environment environment) throws Exception { | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/domain/CartRepository.java
// public interface CartRepository {
//
// void save(Cart cart);
//
// Cart get(String cartId);
//
// Cart find(String cartId);
//
// void delete(String cartId);
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/resource/CartResource.java
// @Path("carts")
// @Produces(APPLICATION_JSON)
// @Consumes(APPLICATION_JSON)
// public class CartResource {
//
// private final Logger logger = LoggerFactory.getLogger(getClass());
// private final ProductCatalogClient productCatalogClient;
// private final CartRepository cartRepository;
//
// public CartResource(ProductCatalogClient productCatalogClient, CartRepository cartRepository) {
// this.productCatalogClient = productCatalogClient;
// this.cartRepository = cartRepository;
// }
//
// @POST
// public void initCart(@Valid CreateCartRequest cart) {
// cartRepository.save(new Cart(cart.cartId));
// }
//
// @POST
// @Path("{cartId}/items")
// public CartDto addItem(@PathParam("cartId") String cartId, AddItemRequest addItemRequest) {
// Cart cart = cartRepository.get(cartId);
// logger.debug("Got addItem request " + addItemRequest);
// ProductDto product = productCatalogClient.getProduct(addItemRequest.productId);
// assertProductExists(addItemRequest.productId, product);
// Item item = new Item(new ProductId(addItemRequest.productId), product.book.title, product.price);
// logger.info("Adding item to cart: " + item);
// cart.add(item);
// return CartDtoFactory.fromCart(cart);
// }
//
// @GET
// @Path("{cartId}")
// public Response getCart(@PathParam("cartId") String cartId) {
// Cart cart = cartRepository.find(cartId);
// if (cart == null) {
// return status(NOT_FOUND).entity(format("Cart with id '%s' does not exist", cartId)).build();
// } else {
// logger.info("Returning cart with [{}] lines", cart.getLineCount());
// return Response.ok().entity(CartDtoFactory.fromCart(cart)).build();
// }
// }
//
// @DELETE
// @Path("{cartId}")
// public void deleteCart(@PathParam("cartId") String cartId) {
// cartRepository.delete(cartId);
// logger.info("Shopping cart for session [{}] cleared", cartId);
// }
//
// private void assertProductExists(String productId, ProductDto product) {
// if (product == null) {
// throw new WebApplicationException(status(BAD_REQUEST)
// .entity("Product with id '" + productId + "' could not be found").build());
// }
// }
//
// }
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/application/ShoppingApplication.java
import io.dropwizard.Application;
import io.dropwizard.assets.AssetsBundle;
import io.dropwizard.client.JerseyClientBuilder;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.domain.CartRepository;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import se.citerus.cqrs.bookstore.shopping.resource.CartResource;
import javax.ws.rs.client.Client;
package se.citerus.cqrs.bookstore.shopping.application;
public class ShoppingApplication extends Application<ShoppingConfiguration> {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void initialize(Bootstrap<ShoppingConfiguration> bootstrap) {
bootstrap.addBundle(new AssetsBundle("/assets/", "/", "index.html"));
}
@Override
public void run(ShoppingConfiguration configuration, Environment environment) throws Exception { | CartRepository cartRepository = new InMemoryCartRepository(); |
citerus/bookstore-cqrs-example | shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/application/ShoppingApplication.java | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/domain/CartRepository.java
// public interface CartRepository {
//
// void save(Cart cart);
//
// Cart get(String cartId);
//
// Cart find(String cartId);
//
// void delete(String cartId);
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/resource/CartResource.java
// @Path("carts")
// @Produces(APPLICATION_JSON)
// @Consumes(APPLICATION_JSON)
// public class CartResource {
//
// private final Logger logger = LoggerFactory.getLogger(getClass());
// private final ProductCatalogClient productCatalogClient;
// private final CartRepository cartRepository;
//
// public CartResource(ProductCatalogClient productCatalogClient, CartRepository cartRepository) {
// this.productCatalogClient = productCatalogClient;
// this.cartRepository = cartRepository;
// }
//
// @POST
// public void initCart(@Valid CreateCartRequest cart) {
// cartRepository.save(new Cart(cart.cartId));
// }
//
// @POST
// @Path("{cartId}/items")
// public CartDto addItem(@PathParam("cartId") String cartId, AddItemRequest addItemRequest) {
// Cart cart = cartRepository.get(cartId);
// logger.debug("Got addItem request " + addItemRequest);
// ProductDto product = productCatalogClient.getProduct(addItemRequest.productId);
// assertProductExists(addItemRequest.productId, product);
// Item item = new Item(new ProductId(addItemRequest.productId), product.book.title, product.price);
// logger.info("Adding item to cart: " + item);
// cart.add(item);
// return CartDtoFactory.fromCart(cart);
// }
//
// @GET
// @Path("{cartId}")
// public Response getCart(@PathParam("cartId") String cartId) {
// Cart cart = cartRepository.find(cartId);
// if (cart == null) {
// return status(NOT_FOUND).entity(format("Cart with id '%s' does not exist", cartId)).build();
// } else {
// logger.info("Returning cart with [{}] lines", cart.getLineCount());
// return Response.ok().entity(CartDtoFactory.fromCart(cart)).build();
// }
// }
//
// @DELETE
// @Path("{cartId}")
// public void deleteCart(@PathParam("cartId") String cartId) {
// cartRepository.delete(cartId);
// logger.info("Shopping cart for session [{}] cleared", cartId);
// }
//
// private void assertProductExists(String productId, ProductDto product) {
// if (product == null) {
// throw new WebApplicationException(status(BAD_REQUEST)
// .entity("Product with id '" + productId + "' could not be found").build());
// }
// }
//
// }
| import io.dropwizard.Application;
import io.dropwizard.assets.AssetsBundle;
import io.dropwizard.client.JerseyClientBuilder;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.domain.CartRepository;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import se.citerus.cqrs.bookstore.shopping.resource.CartResource;
import javax.ws.rs.client.Client; | package se.citerus.cqrs.bookstore.shopping.application;
public class ShoppingApplication extends Application<ShoppingConfiguration> {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void initialize(Bootstrap<ShoppingConfiguration> bootstrap) {
bootstrap.addBundle(new AssetsBundle("/assets/", "/", "index.html"));
}
@Override
public void run(ShoppingConfiguration configuration, Environment environment) throws Exception {
CartRepository cartRepository = new InMemoryCartRepository();
final Client client = new JerseyClientBuilder(environment).using(configuration.httpClient).build(getName()); | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/domain/CartRepository.java
// public interface CartRepository {
//
// void save(Cart cart);
//
// Cart get(String cartId);
//
// Cart find(String cartId);
//
// void delete(String cartId);
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/resource/CartResource.java
// @Path("carts")
// @Produces(APPLICATION_JSON)
// @Consumes(APPLICATION_JSON)
// public class CartResource {
//
// private final Logger logger = LoggerFactory.getLogger(getClass());
// private final ProductCatalogClient productCatalogClient;
// private final CartRepository cartRepository;
//
// public CartResource(ProductCatalogClient productCatalogClient, CartRepository cartRepository) {
// this.productCatalogClient = productCatalogClient;
// this.cartRepository = cartRepository;
// }
//
// @POST
// public void initCart(@Valid CreateCartRequest cart) {
// cartRepository.save(new Cart(cart.cartId));
// }
//
// @POST
// @Path("{cartId}/items")
// public CartDto addItem(@PathParam("cartId") String cartId, AddItemRequest addItemRequest) {
// Cart cart = cartRepository.get(cartId);
// logger.debug("Got addItem request " + addItemRequest);
// ProductDto product = productCatalogClient.getProduct(addItemRequest.productId);
// assertProductExists(addItemRequest.productId, product);
// Item item = new Item(new ProductId(addItemRequest.productId), product.book.title, product.price);
// logger.info("Adding item to cart: " + item);
// cart.add(item);
// return CartDtoFactory.fromCart(cart);
// }
//
// @GET
// @Path("{cartId}")
// public Response getCart(@PathParam("cartId") String cartId) {
// Cart cart = cartRepository.find(cartId);
// if (cart == null) {
// return status(NOT_FOUND).entity(format("Cart with id '%s' does not exist", cartId)).build();
// } else {
// logger.info("Returning cart with [{}] lines", cart.getLineCount());
// return Response.ok().entity(CartDtoFactory.fromCart(cart)).build();
// }
// }
//
// @DELETE
// @Path("{cartId}")
// public void deleteCart(@PathParam("cartId") String cartId) {
// cartRepository.delete(cartId);
// logger.info("Shopping cart for session [{}] cleared", cartId);
// }
//
// private void assertProductExists(String productId, ProductDto product) {
// if (product == null) {
// throw new WebApplicationException(status(BAD_REQUEST)
// .entity("Product with id '" + productId + "' could not be found").build());
// }
// }
//
// }
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/application/ShoppingApplication.java
import io.dropwizard.Application;
import io.dropwizard.assets.AssetsBundle;
import io.dropwizard.client.JerseyClientBuilder;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.domain.CartRepository;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import se.citerus.cqrs.bookstore.shopping.resource.CartResource;
import javax.ws.rs.client.Client;
package se.citerus.cqrs.bookstore.shopping.application;
public class ShoppingApplication extends Application<ShoppingConfiguration> {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void initialize(Bootstrap<ShoppingConfiguration> bootstrap) {
bootstrap.addBundle(new AssetsBundle("/assets/", "/", "index.html"));
}
@Override
public void run(ShoppingConfiguration configuration, Environment environment) throws Exception {
CartRepository cartRepository = new InMemoryCartRepository();
final Client client = new JerseyClientBuilder(environment).using(configuration.httpClient).build(getName()); | ProductCatalogClient productCatalogClient = ProductCatalogClient.create(client, |
citerus/bookstore-cqrs-example | shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/application/ShoppingApplication.java | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/domain/CartRepository.java
// public interface CartRepository {
//
// void save(Cart cart);
//
// Cart get(String cartId);
//
// Cart find(String cartId);
//
// void delete(String cartId);
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/resource/CartResource.java
// @Path("carts")
// @Produces(APPLICATION_JSON)
// @Consumes(APPLICATION_JSON)
// public class CartResource {
//
// private final Logger logger = LoggerFactory.getLogger(getClass());
// private final ProductCatalogClient productCatalogClient;
// private final CartRepository cartRepository;
//
// public CartResource(ProductCatalogClient productCatalogClient, CartRepository cartRepository) {
// this.productCatalogClient = productCatalogClient;
// this.cartRepository = cartRepository;
// }
//
// @POST
// public void initCart(@Valid CreateCartRequest cart) {
// cartRepository.save(new Cart(cart.cartId));
// }
//
// @POST
// @Path("{cartId}/items")
// public CartDto addItem(@PathParam("cartId") String cartId, AddItemRequest addItemRequest) {
// Cart cart = cartRepository.get(cartId);
// logger.debug("Got addItem request " + addItemRequest);
// ProductDto product = productCatalogClient.getProduct(addItemRequest.productId);
// assertProductExists(addItemRequest.productId, product);
// Item item = new Item(new ProductId(addItemRequest.productId), product.book.title, product.price);
// logger.info("Adding item to cart: " + item);
// cart.add(item);
// return CartDtoFactory.fromCart(cart);
// }
//
// @GET
// @Path("{cartId}")
// public Response getCart(@PathParam("cartId") String cartId) {
// Cart cart = cartRepository.find(cartId);
// if (cart == null) {
// return status(NOT_FOUND).entity(format("Cart with id '%s' does not exist", cartId)).build();
// } else {
// logger.info("Returning cart with [{}] lines", cart.getLineCount());
// return Response.ok().entity(CartDtoFactory.fromCart(cart)).build();
// }
// }
//
// @DELETE
// @Path("{cartId}")
// public void deleteCart(@PathParam("cartId") String cartId) {
// cartRepository.delete(cartId);
// logger.info("Shopping cart for session [{}] cleared", cartId);
// }
//
// private void assertProductExists(String productId, ProductDto product) {
// if (product == null) {
// throw new WebApplicationException(status(BAD_REQUEST)
// .entity("Product with id '" + productId + "' could not be found").build());
// }
// }
//
// }
| import io.dropwizard.Application;
import io.dropwizard.assets.AssetsBundle;
import io.dropwizard.client.JerseyClientBuilder;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.domain.CartRepository;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import se.citerus.cqrs.bookstore.shopping.resource.CartResource;
import javax.ws.rs.client.Client; | package se.citerus.cqrs.bookstore.shopping.application;
public class ShoppingApplication extends Application<ShoppingConfiguration> {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void initialize(Bootstrap<ShoppingConfiguration> bootstrap) {
bootstrap.addBundle(new AssetsBundle("/assets/", "/", "index.html"));
}
@Override
public void run(ShoppingConfiguration configuration, Environment environment) throws Exception {
CartRepository cartRepository = new InMemoryCartRepository();
final Client client = new JerseyClientBuilder(environment).using(configuration.httpClient).build(getName());
ProductCatalogClient productCatalogClient = ProductCatalogClient.create(client,
configuration.productCatalogServiceUrl); | // Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/client/productcatalog/ProductCatalogClient.java
// public class ProductCatalogClient {
//
// private final Client client;
// private final String serviceUrl;
//
// private ProductCatalogClient(Client client, String serviceUrl) {
// this.client = client;
// this.serviceUrl = serviceUrl;
// }
//
// public static ProductCatalogClient create(Client client, String serviceUrl) {
// return new ProductCatalogClient(client, serviceUrl);
// }
//
// public ProductDto getProduct(String productId) {
// return client.target(serviceUrl + productId).request().get(ProductDto.class);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/domain/CartRepository.java
// public interface CartRepository {
//
// void save(Cart cart);
//
// Cart get(String cartId);
//
// Cart find(String cartId);
//
// void delete(String cartId);
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/infrastructure/InMemoryCartRepository.java
// public class InMemoryCartRepository implements CartRepository {
//
// private ConcurrentHashMap<String, Cart> sessions = new ConcurrentHashMap<>();
//
// public void save(Cart cart) {
// if (sessions.putIfAbsent(cart.cartId, cart) != null) {
// throw new IllegalArgumentException(format("Shopping cart with id '%s' already exists", cart.cartId));
// }
// }
//
// public Cart get(String cartId) {
// Cart cart = sessions.get(cartId);
// checkArgument(cart != null, "No shopping cart with id '%s' exists", cartId);
// return cart;
// }
//
// public Cart find(String cartId) {
// return sessions.get(cartId);
// }
//
// public void delete(String cartId) {
// sessions.remove(cartId);
// }
//
// }
//
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/resource/CartResource.java
// @Path("carts")
// @Produces(APPLICATION_JSON)
// @Consumes(APPLICATION_JSON)
// public class CartResource {
//
// private final Logger logger = LoggerFactory.getLogger(getClass());
// private final ProductCatalogClient productCatalogClient;
// private final CartRepository cartRepository;
//
// public CartResource(ProductCatalogClient productCatalogClient, CartRepository cartRepository) {
// this.productCatalogClient = productCatalogClient;
// this.cartRepository = cartRepository;
// }
//
// @POST
// public void initCart(@Valid CreateCartRequest cart) {
// cartRepository.save(new Cart(cart.cartId));
// }
//
// @POST
// @Path("{cartId}/items")
// public CartDto addItem(@PathParam("cartId") String cartId, AddItemRequest addItemRequest) {
// Cart cart = cartRepository.get(cartId);
// logger.debug("Got addItem request " + addItemRequest);
// ProductDto product = productCatalogClient.getProduct(addItemRequest.productId);
// assertProductExists(addItemRequest.productId, product);
// Item item = new Item(new ProductId(addItemRequest.productId), product.book.title, product.price);
// logger.info("Adding item to cart: " + item);
// cart.add(item);
// return CartDtoFactory.fromCart(cart);
// }
//
// @GET
// @Path("{cartId}")
// public Response getCart(@PathParam("cartId") String cartId) {
// Cart cart = cartRepository.find(cartId);
// if (cart == null) {
// return status(NOT_FOUND).entity(format("Cart with id '%s' does not exist", cartId)).build();
// } else {
// logger.info("Returning cart with [{}] lines", cart.getLineCount());
// return Response.ok().entity(CartDtoFactory.fromCart(cart)).build();
// }
// }
//
// @DELETE
// @Path("{cartId}")
// public void deleteCart(@PathParam("cartId") String cartId) {
// cartRepository.delete(cartId);
// logger.info("Shopping cart for session [{}] cleared", cartId);
// }
//
// private void assertProductExists(String productId, ProductDto product) {
// if (product == null) {
// throw new WebApplicationException(status(BAD_REQUEST)
// .entity("Product with id '" + productId + "' could not be found").build());
// }
// }
//
// }
// Path: shopping-context/src/main/java/se/citerus/cqrs/bookstore/shopping/application/ShoppingApplication.java
import io.dropwizard.Application;
import io.dropwizard.assets.AssetsBundle;
import io.dropwizard.client.JerseyClientBuilder;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.cqrs.bookstore.shopping.client.productcatalog.ProductCatalogClient;
import se.citerus.cqrs.bookstore.shopping.domain.CartRepository;
import se.citerus.cqrs.bookstore.shopping.infrastructure.InMemoryCartRepository;
import se.citerus.cqrs.bookstore.shopping.resource.CartResource;
import javax.ws.rs.client.Client;
package se.citerus.cqrs.bookstore.shopping.application;
public class ShoppingApplication extends Application<ShoppingConfiguration> {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void initialize(Bootstrap<ShoppingConfiguration> bootstrap) {
bootstrap.addBundle(new AssetsBundle("/assets/", "/", "index.html"));
}
@Override
public void run(ShoppingConfiguration configuration, Environment environment) throws Exception {
CartRepository cartRepository = new InMemoryCartRepository();
final Client client = new JerseyClientBuilder(environment).using(configuration.httpClient).build(getName());
ProductCatalogClient productCatalogClient = ProductCatalogClient.create(client,
configuration.productCatalogServiceUrl); | environment.jersey().register(new CartResource(productCatalogClient, cartRepository)); |
citerus/bookstore-cqrs-example | order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/RegisterPurchaseCommand.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/Command.java
// public abstract class Command {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
| import se.citerus.cqrs.bookstore.command.Command;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import static com.google.common.base.Preconditions.checkArgument; | package se.citerus.cqrs.bookstore.ordercontext.publishercontract.command;
public class RegisterPurchaseCommand extends Command {
public final PublisherContractId publisherContractId; | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/Command.java
// public abstract class Command {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/PublisherContractId.java
// public class PublisherContractId extends GenericId {
//
// public PublisherContractId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static PublisherContractId randomId() {
// return new PublisherContractId(UUID.randomUUID().toString());
// }
//
// }
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/publishercontract/command/RegisterPurchaseCommand.java
import se.citerus.cqrs.bookstore.command.Command;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.publishercontract.PublisherContractId;
import static com.google.common.base.Preconditions.checkArgument;
package se.citerus.cqrs.bookstore.ordercontext.publishercontract.command;
public class RegisterPurchaseCommand extends Command {
public final PublisherContractId publisherContractId; | public final ProductId productId; |
citerus/bookstore-cqrs-example | order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/RegisterPublisherContractRequest.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/TransportObject.java
// public abstract class TransportObject {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
| import org.hibernate.validator.constraints.NotEmpty;
import se.citerus.cqrs.bookstore.TransportObject;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import static se.citerus.cqrs.bookstore.GenericId.ID_PATTERN; | package se.citerus.cqrs.bookstore.ordercontext.api;
public class RegisterPublisherContractRequest extends TransportObject {
@NotEmpty | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/TransportObject.java
// public abstract class TransportObject {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
// Path: order-context-parent/publisher-contract-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/RegisterPublisherContractRequest.java
import org.hibernate.validator.constraints.NotEmpty;
import se.citerus.cqrs.bookstore.TransportObject;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import static se.citerus.cqrs.bookstore.GenericId.ID_PATTERN;
package se.citerus.cqrs.bookstore.ordercontext.api;
public class RegisterPublisherContractRequest extends TransportObject {
@NotEmpty | @Pattern(regexp = ID_PATTERN) |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java | // Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/CustomerInformation.java
// public class CustomerInformation extends ValueObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(String customerName, String email, String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderLine.java
// public class OrderLine extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(ProductId productId, String title, int quantity, long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
| import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.OrderLine;
import java.util.ArrayList;
import java.util.List; | package se.citerus.cqrs.bookstore.ordercontext.order.command;
public class CommandFactory {
public PlaceOrderCommand toCommand(PlaceOrderRequest request) { | // Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/CustomerInformation.java
// public class CustomerInformation extends ValueObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(String customerName, String email, String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderLine.java
// public class OrderLine extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(ProductId productId, String title, int quantity, long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java
import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.OrderLine;
import java.util.ArrayList;
import java.util.List;
package se.citerus.cqrs.bookstore.ordercontext.order.command;
public class CommandFactory {
public PlaceOrderCommand toCommand(PlaceOrderRequest request) { | List<OrderLine> itemsToOrder = getOrderLines(request.cart); |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java | // Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/CustomerInformation.java
// public class CustomerInformation extends ValueObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(String customerName, String email, String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderLine.java
// public class OrderLine extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(ProductId productId, String title, int quantity, long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
| import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.OrderLine;
import java.util.ArrayList;
import java.util.List; | package se.citerus.cqrs.bookstore.ordercontext.order.command;
public class CommandFactory {
public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
List<OrderLine> itemsToOrder = getOrderLines(request.cart); | // Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/CustomerInformation.java
// public class CustomerInformation extends ValueObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(String customerName, String email, String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderLine.java
// public class OrderLine extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(ProductId productId, String title, int quantity, long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java
import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.OrderLine;
import java.util.ArrayList;
import java.util.List;
package se.citerus.cqrs.bookstore.ordercontext.order.command;
public class CommandFactory {
public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
List<OrderLine> itemsToOrder = getOrderLines(request.cart); | CustomerInformation customerInformation = getCustomerInformation(request); |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java | // Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/CustomerInformation.java
// public class CustomerInformation extends ValueObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(String customerName, String email, String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderLine.java
// public class OrderLine extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(ProductId productId, String title, int quantity, long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
| import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.OrderLine;
import java.util.ArrayList;
import java.util.List; | package se.citerus.cqrs.bookstore.ordercontext.order.command;
public class CommandFactory {
public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
List<OrderLine> itemsToOrder = getOrderLines(request.cart);
CustomerInformation customerInformation = getCustomerInformation(request);
long totalPrice = request.cart.totalPrice; | // Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/CustomerInformation.java
// public class CustomerInformation extends ValueObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(String customerName, String email, String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderLine.java
// public class OrderLine extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(ProductId productId, String title, int quantity, long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java
import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.OrderLine;
import java.util.ArrayList;
import java.util.List;
package se.citerus.cqrs.bookstore.ordercontext.order.command;
public class CommandFactory {
public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
List<OrderLine> itemsToOrder = getOrderLines(request.cart);
CustomerInformation customerInformation = getCustomerInformation(request);
long totalPrice = request.cart.totalPrice; | return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice); |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java | // Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/CustomerInformation.java
// public class CustomerInformation extends ValueObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(String customerName, String email, String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderLine.java
// public class OrderLine extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(ProductId productId, String title, int quantity, long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
| import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.OrderLine;
import java.util.ArrayList;
import java.util.List; | package se.citerus.cqrs.bookstore.ordercontext.order.command;
public class CommandFactory {
public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
List<OrderLine> itemsToOrder = getOrderLines(request.cart);
CustomerInformation customerInformation = getCustomerInformation(request);
long totalPrice = request.cart.totalPrice;
return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice);
}
| // Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/CustomerInformation.java
// public class CustomerInformation extends ValueObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(String customerName, String email, String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderLine.java
// public class OrderLine extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(ProductId productId, String title, int quantity, long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java
import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.OrderLine;
import java.util.ArrayList;
import java.util.List;
package se.citerus.cqrs.bookstore.ordercontext.order.command;
public class CommandFactory {
public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
List<OrderLine> itemsToOrder = getOrderLines(request.cart);
CustomerInformation customerInformation = getCustomerInformation(request);
long totalPrice = request.cart.totalPrice;
return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice);
}
| public ActivateOrderCommand toCommand(ActivateOrderRequest request) { |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java | // Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/CustomerInformation.java
// public class CustomerInformation extends ValueObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(String customerName, String email, String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderLine.java
// public class OrderLine extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(ProductId productId, String title, int quantity, long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
| import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.OrderLine;
import java.util.ArrayList;
import java.util.List; | package se.citerus.cqrs.bookstore.ordercontext.order.command;
public class CommandFactory {
public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
List<OrderLine> itemsToOrder = getOrderLines(request.cart);
CustomerInformation customerInformation = getCustomerInformation(request);
long totalPrice = request.cart.totalPrice;
return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice);
}
public ActivateOrderCommand toCommand(ActivateOrderRequest request) {
return new ActivateOrderCommand(new OrderId(request.orderId));
}
| // Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/CustomerInformation.java
// public class CustomerInformation extends ValueObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(String customerName, String email, String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderLine.java
// public class OrderLine extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(ProductId productId, String title, int quantity, long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java
import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.OrderLine;
import java.util.ArrayList;
import java.util.List;
package se.citerus.cqrs.bookstore.ordercontext.order.command;
public class CommandFactory {
public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
List<OrderLine> itemsToOrder = getOrderLines(request.cart);
CustomerInformation customerInformation = getCustomerInformation(request);
long totalPrice = request.cart.totalPrice;
return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice);
}
public ActivateOrderCommand toCommand(ActivateOrderRequest request) {
return new ActivateOrderCommand(new OrderId(request.orderId));
}
| private List<OrderLine> getOrderLines(CartDto cart) { |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java | // Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/CustomerInformation.java
// public class CustomerInformation extends ValueObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(String customerName, String email, String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderLine.java
// public class OrderLine extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(ProductId productId, String title, int quantity, long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
| import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.OrderLine;
import java.util.ArrayList;
import java.util.List; | package se.citerus.cqrs.bookstore.ordercontext.order.command;
public class CommandFactory {
public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
List<OrderLine> itemsToOrder = getOrderLines(request.cart);
CustomerInformation customerInformation = getCustomerInformation(request);
long totalPrice = request.cart.totalPrice;
return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice);
}
public ActivateOrderCommand toCommand(ActivateOrderRequest request) {
return new ActivateOrderCommand(new OrderId(request.orderId));
}
private List<OrderLine> getOrderLines(CartDto cart) {
List<OrderLine> itemsToOrder = new ArrayList<>(); | // Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/CustomerInformation.java
// public class CustomerInformation extends ValueObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(String customerName, String email, String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderLine.java
// public class OrderLine extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(ProductId productId, String title, int quantity, long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java
import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.OrderLine;
import java.util.ArrayList;
import java.util.List;
package se.citerus.cqrs.bookstore.ordercontext.order.command;
public class CommandFactory {
public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
List<OrderLine> itemsToOrder = getOrderLines(request.cart);
CustomerInformation customerInformation = getCustomerInformation(request);
long totalPrice = request.cart.totalPrice;
return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice);
}
public ActivateOrderCommand toCommand(ActivateOrderRequest request) {
return new ActivateOrderCommand(new OrderId(request.orderId));
}
private List<OrderLine> getOrderLines(CartDto cart) {
List<OrderLine> itemsToOrder = new ArrayList<>(); | for (LineItemDto lineItem : cart.lineItems) { |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java | // Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/CustomerInformation.java
// public class CustomerInformation extends ValueObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(String customerName, String email, String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderLine.java
// public class OrderLine extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(ProductId productId, String title, int quantity, long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
| import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.OrderLine;
import java.util.ArrayList;
import java.util.List; | package se.citerus.cqrs.bookstore.ordercontext.order.command;
public class CommandFactory {
public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
List<OrderLine> itemsToOrder = getOrderLines(request.cart);
CustomerInformation customerInformation = getCustomerInformation(request);
long totalPrice = request.cart.totalPrice;
return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice);
}
public ActivateOrderCommand toCommand(ActivateOrderRequest request) {
return new ActivateOrderCommand(new OrderId(request.orderId));
}
private List<OrderLine> getOrderLines(CartDto cart) {
List<OrderLine> itemsToOrder = new ArrayList<>();
for (LineItemDto lineItem : cart.lineItems) { | // Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
// public class ActivateOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/CartDto.java
// public class CartDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String cartId;
//
// @Min(1)
// public long totalPrice;
//
// @Min(1)
// public int totalQuantity;
//
// @NotNull
// @NotEmpty
// public List<LineItemDto> lineItems;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
// public class LineItemDto {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String productId;
//
// @NotNull
// public String title;
//
// @Min(1)
// public long price;
//
// @Min(1)
// public int quantity;
//
// @Min(1)
// public long totalPrice;
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/PlaceOrderRequest.java
// public class PlaceOrderRequest extends TransportObject {
//
// @NotEmpty
// @Pattern(regexp = ID_PATTERN)
// public String orderId;
//
// @NotNull
// public String customerName;
//
// @NotNull
// public String customerEmail;
//
// @NotNull
// public String customerAddress;
//
// @NotNull
// public CartDto cart;
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
//
// public OrderId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static OrderId randomId() {
// return new OrderId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
//
// public ProductId(@JsonProperty("id") String id) {
// super(id);
// }
//
// public static ProductId randomId() {
// return new ProductId(UUID.randomUUID().toString());
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/CustomerInformation.java
// public class CustomerInformation extends ValueObject {
//
// public final String customerName;
// public final String email;
// public final String address;
//
// public CustomerInformation(String customerName, String email, String address) {
// this.customerName = customerName;
// this.email = email;
// this.address = address;
// }
//
// }
//
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderLine.java
// public class OrderLine extends ValueObject {
//
// public final ProductId productId;
// public final String title;
// public final int quantity;
// public final long unitPrice;
//
// public OrderLine(ProductId productId, String title, int quantity, long unitPrice) {
// this.productId = productId;
// this.title = title;
// this.quantity = quantity;
// this.unitPrice = unitPrice;
// }
//
// }
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/command/CommandFactory.java
import se.citerus.cqrs.bookstore.ordercontext.api.ActivateOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.api.CartDto;
import se.citerus.cqrs.bookstore.ordercontext.api.LineItemDto;
import se.citerus.cqrs.bookstore.ordercontext.api.PlaceOrderRequest;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.CustomerInformation;
import se.citerus.cqrs.bookstore.ordercontext.order.domain.OrderLine;
import java.util.ArrayList;
import java.util.List;
package se.citerus.cqrs.bookstore.ordercontext.order.command;
public class CommandFactory {
public PlaceOrderCommand toCommand(PlaceOrderRequest request) {
List<OrderLine> itemsToOrder = getOrderLines(request.cart);
CustomerInformation customerInformation = getCustomerInformation(request);
long totalPrice = request.cart.totalPrice;
return new PlaceOrderCommand(new OrderId(request.orderId), customerInformation, itemsToOrder, totalPrice);
}
public ActivateOrderCommand toCommand(ActivateOrderRequest request) {
return new ActivateOrderCommand(new OrderId(request.orderId));
}
private List<OrderLine> getOrderLines(CartDto cart) {
List<OrderLine> itemsToOrder = new ArrayList<>();
for (LineItemDto lineItem : cart.lineItems) { | ProductId productId = new ProductId(lineItem.productId); |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/TransportObject.java
// public abstract class TransportObject {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
| import org.hibernate.validator.constraints.NotEmpty;
import se.citerus.cqrs.bookstore.TransportObject;
import javax.validation.constraints.Pattern;
import static se.citerus.cqrs.bookstore.GenericId.ID_PATTERN; | package se.citerus.cqrs.bookstore.ordercontext.api;
public class ActivateOrderRequest extends TransportObject {
@NotEmpty | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/TransportObject.java
// public abstract class TransportObject {
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/ActivateOrderRequest.java
import org.hibernate.validator.constraints.NotEmpty;
import se.citerus.cqrs.bookstore.TransportObject;
import javax.validation.constraints.Pattern;
import static se.citerus.cqrs.bookstore.GenericId.ID_PATTERN;
package se.citerus.cqrs.bookstore.ordercontext.api;
public class ActivateOrderRequest extends TransportObject {
@NotEmpty | @Pattern(regexp = ID_PATTERN) |
citerus/bookstore-cqrs-example | order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/InMemoryDomainEventStore.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public class GenericId {
//
// public final String id;
//
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
//
// public GenericId(String id) {
// this.id = id;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return id;
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
| import com.google.common.collect.Lists;
import se.citerus.cqrs.bookstore.GenericId;
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List; | package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class InMemoryDomainEventStore implements DomainEventStore {
private final List<DomainEvent> events = new ArrayList<>();
@Override | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public class GenericId {
//
// public final String id;
//
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
//
// public GenericId(String id) {
// this.id = id;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return id;
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
// Path: order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/InMemoryDomainEventStore.java
import com.google.common.collect.Lists;
import se.citerus.cqrs.bookstore.GenericId;
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class InMemoryDomainEventStore implements DomainEventStore {
private final List<DomainEvent> events = new ArrayList<>();
@Override | public synchronized List<DomainEvent> loadEvents(GenericId id) { |
citerus/bookstore-cqrs-example | order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/InMemoryDomainEventStore.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public class GenericId {
//
// public final String id;
//
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
//
// public GenericId(String id) {
// this.id = id;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return id;
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
| import com.google.common.collect.Lists;
import se.citerus.cqrs.bookstore.GenericId;
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List; | package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class InMemoryDomainEventStore implements DomainEventStore {
private final List<DomainEvent> events = new ArrayList<>();
@Override
public synchronized List<DomainEvent> loadEvents(GenericId id) {
List<DomainEvent> loadedEvents = new ArrayList<>();
for (DomainEvent event : events) {
if (event.aggregateId.equals(id)) {
loadedEvents.add(event);
}
}
if (loadedEvents.isEmpty()) throw new IllegalArgumentException("Aggregate does not exist: " + id);
else return loadedEvents;
}
@Override | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public class GenericId {
//
// public final String id;
//
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
//
// public GenericId(String id) {
// this.id = id;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return id;
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
// Path: order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/InMemoryDomainEventStore.java
import com.google.common.collect.Lists;
import se.citerus.cqrs.bookstore.GenericId;
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class InMemoryDomainEventStore implements DomainEventStore {
private final List<DomainEvent> events = new ArrayList<>();
@Override
public synchronized List<DomainEvent> loadEvents(GenericId id) {
List<DomainEvent> loadedEvents = new ArrayList<>();
for (DomainEvent event : events) {
if (event.aggregateId.equals(id)) {
loadedEvents.add(event);
}
}
if (loadedEvents.isEmpty()) throw new IllegalArgumentException("Aggregate does not exist: " + id);
else return loadedEvents;
}
@Override | public synchronized void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events) { |
citerus/bookstore-cqrs-example | order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
| import org.hibernate.validator.constraints.NotEmpty;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import static se.citerus.cqrs.bookstore.GenericId.ID_PATTERN; | package se.citerus.cqrs.bookstore.ordercontext.api;
public class LineItemDto {
@NotEmpty | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
// Path: order-context-parent/order-command/src/main/java/se/citerus/cqrs/bookstore/ordercontext/api/LineItemDto.java
import org.hibernate.validator.constraints.NotEmpty;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import static se.citerus.cqrs.bookstore.GenericId.ID_PATTERN;
package se.citerus.cqrs.bookstore.ordercontext.api;
public class LineItemDto {
@NotEmpty | @Pattern(regexp = ID_PATTERN) |
citerus/bookstore-cqrs-example | order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/SimpleFileBasedEventStore.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public class GenericId {
//
// public final String id;
//
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
//
// public GenericId(String id) {
// this.id = id;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return id;
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
| import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.io.Files;
import se.citerus.cqrs.bookstore.GenericId;
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import static com.google.common.base.Charsets.UTF_8; | package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class SimpleFileBasedEventStore implements DomainEventStore {
private static final String DEFAULT_FILE_NAME = "events.txt";
private final File eventStoreFile;
private final ObjectMapper objectMapper = new ObjectMapper();
public SimpleFileBasedEventStore() throws IOException {
this(DEFAULT_FILE_NAME);
}
public SimpleFileBasedEventStore(String eventStoreFile) throws IOException {
objectMapper.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.NON_FINAL, "type");
this.eventStoreFile = init(eventStoreFile);
}
@Override | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public class GenericId {
//
// public final String id;
//
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
//
// public GenericId(String id) {
// this.id = id;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return id;
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
// Path: order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/SimpleFileBasedEventStore.java
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.io.Files;
import se.citerus.cqrs.bookstore.GenericId;
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import static com.google.common.base.Charsets.UTF_8;
package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class SimpleFileBasedEventStore implements DomainEventStore {
private static final String DEFAULT_FILE_NAME = "events.txt";
private final File eventStoreFile;
private final ObjectMapper objectMapper = new ObjectMapper();
public SimpleFileBasedEventStore() throws IOException {
this(DEFAULT_FILE_NAME);
}
public SimpleFileBasedEventStore(String eventStoreFile) throws IOException {
objectMapper.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.NON_FINAL, "type");
this.eventStoreFile = init(eventStoreFile);
}
@Override | public synchronized List<DomainEvent> loadEvents(final GenericId id) { |
citerus/bookstore-cqrs-example | order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/SimpleFileBasedEventStore.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public class GenericId {
//
// public final String id;
//
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
//
// public GenericId(String id) {
// this.id = id;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return id;
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
| import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.io.Files;
import se.citerus.cqrs.bookstore.GenericId;
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import static com.google.common.base.Charsets.UTF_8; | package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class SimpleFileBasedEventStore implements DomainEventStore {
private static final String DEFAULT_FILE_NAME = "events.txt";
private final File eventStoreFile;
private final ObjectMapper objectMapper = new ObjectMapper();
public SimpleFileBasedEventStore() throws IOException {
this(DEFAULT_FILE_NAME);
}
public SimpleFileBasedEventStore(String eventStoreFile) throws IOException {
objectMapper.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.NON_FINAL, "type");
this.eventStoreFile = init(eventStoreFile);
}
@Override | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public class GenericId {
//
// public final String id;
//
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
//
// public GenericId(String id) {
// this.id = id;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return id;
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
// Path: order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/SimpleFileBasedEventStore.java
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.io.Files;
import se.citerus.cqrs.bookstore.GenericId;
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import static com.google.common.base.Charsets.UTF_8;
package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class SimpleFileBasedEventStore implements DomainEventStore {
private static final String DEFAULT_FILE_NAME = "events.txt";
private final File eventStoreFile;
private final ObjectMapper objectMapper = new ObjectMapper();
public SimpleFileBasedEventStore() throws IOException {
this(DEFAULT_FILE_NAME);
}
public SimpleFileBasedEventStore(String eventStoreFile) throws IOException {
objectMapper.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.NON_FINAL, "type");
this.eventStoreFile = init(eventStoreFile);
}
@Override | public synchronized List<DomainEvent> loadEvents(final GenericId id) { |
citerus/bookstore-cqrs-example | order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/SimpleFileBasedEventStore.java | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public class GenericId {
//
// public final String id;
//
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
//
// public GenericId(String id) {
// this.id = id;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return id;
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
| import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.io.Files;
import se.citerus.cqrs.bookstore.GenericId;
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import static com.google.common.base.Charsets.UTF_8; | package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class SimpleFileBasedEventStore implements DomainEventStore {
private static final String DEFAULT_FILE_NAME = "events.txt";
private final File eventStoreFile;
private final ObjectMapper objectMapper = new ObjectMapper();
public SimpleFileBasedEventStore() throws IOException {
this(DEFAULT_FILE_NAME);
}
public SimpleFileBasedEventStore(String eventStoreFile) throws IOException {
objectMapper.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.NON_FINAL, "type");
this.eventStoreFile = init(eventStoreFile);
}
@Override
public synchronized List<DomainEvent> loadEvents(final GenericId id) {
List<DomainEvent> events = new ArrayList<>();
for (DomainEvent event : getAllEvents()) {
if (event.aggregateId.equals(id)) {
events.add(event);
}
}
return events;
}
@Override | // Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/GenericId.java
// public class GenericId {
//
// public final String id;
//
// public static final String ID_PATTERN =
// "^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$";
//
// public GenericId(String id) {
// this.id = id;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return id;
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/domain/AggregateRoot.java
// public class AggregateRoot<T extends GenericId> {
//
// private final List<DomainEvent> uncommittedEvents = new ArrayList<>();
//
// private T id;
// private int version = 0;
// private long timestamp = 0;
//
// public List<DomainEvent> getUncommittedEvents() {
// return uncommittedEvents;
// }
//
// public void loadFromHistory(List<DomainEvent> history) {
// for (DomainEvent event : history) {
// applyChange(event, false);
// }
// }
//
// protected int nextVersion() {
// return version + 1;
// }
//
// protected long now() {
// return System.currentTimeMillis();
// }
//
// public T id() {
// return id;
// }
//
// public int version() {
// return version;
// }
//
// public long timestamp() {
// return timestamp;
// }
//
// protected void applyChange(DomainEvent event) {
// applyChange(event, true);
// }
//
// private void applyChange(DomainEvent event, boolean isNew) {
// updateMetadata(event);
// invokeHandlerMethod(event);
// if (isNew) uncommittedEvents.add(event);
// }
//
// private void updateMetadata(DomainEvent event) {
// this.id = (T) event.aggregateId;
// this.version = event.version;
// this.timestamp = event.timestamp;
// }
//
// private void invokeHandlerMethod(DomainEvent event) {
// Method handlerMethod = getHandlerMethod(event);
// if (handlerMethod != null) {
// handlerMethod.setAccessible(true);
// try {
// handlerMethod.invoke(this, event);
// } catch (Exception e) {
// throw new RuntimeException("Unable to call event handler method for " + event.getClass().getName(), e);
// }
// }
// }
//
// private Method getHandlerMethod(DomainEvent event) {
// try {
// return getClass().getDeclaredMethod("handleEvent", event.getClass());
// } catch (NoSuchMethodException e) {
// return null;
// }
// }
//
// public boolean hasUncommittedEvents() {
// return !uncommittedEvents.isEmpty();
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
//
// public final T aggregateId;
// public final int version;
// public final long timestamp;
//
// protected DomainEvent(T aggregateId, int version, long timestamp) {
// this.aggregateId = aggregateId;
// this.version = version;
// this.timestamp = timestamp;
// }
//
// @Override
// public boolean equals(Object o) {
// return EqualsBuilder.reflectionEquals(this, o);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
// }
//
// }
//
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEventStore.java
// public interface DomainEventStore {
//
// List<DomainEvent> loadEvents(GenericId id);
//
// void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events);
//
// List<DomainEvent> getAllEvents();
//
// }
// Path: order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/SimpleFileBasedEventStore.java
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.io.Files;
import se.citerus.cqrs.bookstore.GenericId;
import se.citerus.cqrs.bookstore.domain.AggregateRoot;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.event.DomainEventStore;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import static com.google.common.base.Charsets.UTF_8;
package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;
public class SimpleFileBasedEventStore implements DomainEventStore {
private static final String DEFAULT_FILE_NAME = "events.txt";
private final File eventStoreFile;
private final ObjectMapper objectMapper = new ObjectMapper();
public SimpleFileBasedEventStore() throws IOException {
this(DEFAULT_FILE_NAME);
}
public SimpleFileBasedEventStore(String eventStoreFile) throws IOException {
objectMapper.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.NON_FINAL, "type");
this.eventStoreFile = init(eventStoreFile);
}
@Override
public synchronized List<DomainEvent> loadEvents(final GenericId id) {
List<DomainEvent> events = new ArrayList<>();
for (DomainEvent event : getAllEvents()) {
if (event.aggregateId.equals(id)) {
events.add(event);
}
}
return events;
}
@Override | public synchronized void save(GenericId id, Class<? extends AggregateRoot> type, List<DomainEvent> events) { |
wada811/AndroidLibrary-wada811 | AndroidLibrary@wada811Demos/src/at/wada811/android/library/demos/MainActivity.java | // Path: AndroidLibrary@wada811Demos/src/at/wada811/android/library/demos/ActivityListFragment.java
// public static interface ExpandableListListener {
//
// /**
// * Callback method to be invoked when a group in this expandable list has
// * been clicked.
// *
// * @param parent The ExpandableListConnector where the click happened
// * @param v The view within the expandable list/ListView that was clicked
// * @param groupPosition The group position that was clicked
// * @param id The row id of the group that was clicked
// * @return True if the click was handled
// */
// public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id);
//
// /**
// * Callback method to be invoked when a group in this expandable list has
// * been collapsed.
// *
// * @param groupPosition The group position that was collapsed
// */
// public void onGroupCollapse(int groupPosition);
//
// /**
// * Callback method to be invoked when a group in this expandable list has
// * been expanded.
// *
// * @param groupPosition The group position that was expanded
// */
// public void onGroupExpand(int groupPosition);
//
// /**
// * Callback method to be invoked when a child in this expandable list has
// * been clicked.
// *
// * @param parent The ExpandableListView where the click happened
// * @param v The view within the expandable list/ListView that was clicked
// * @param groupPosition The group position that contains the child that
// * was clicked
// * @param childPosition The child position within the group
// * @param id The row id of the child that was clicked
// * @return True if the click was handled
// */
// public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id);
// }
//
// Path: AndroidLibrary@wada811Demos/src/at/wada811/android/library/demos/ActivityListFragment.java
// public static interface ExpandableListListenerProvider {
// public ExpandableListListener getExpandableListListener();
// }
| import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.View;
import android.widget.ExpandableListView;
import at.wada811.android.library.demos.ActivityListFragment.ExpandableListListener;
import at.wada811.android.library.demos.ActivityListFragment.ExpandableListListenerProvider;
import at.wada811.android.library.demos.broadcastreceiver.DateTimeChangeReceiver;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.TreeSet; | Collections.sort(activityInfos, new Comparator<ActivityInfo>(){
@Override
public int compare(ActivityInfo lhs, ActivityInfo rhs){
return lhs.name.compareTo(rhs.name);
}
});
// packages の生成
TreeSet<String> packages = new TreeSet<String>();
// activities の生成
HashMap<String, ArrayList<ActivityInfo>> activities = new HashMap<String, ArrayList<ActivityInfo>>();
for(ActivityInfo activityInfo : activityInfos){
String[] splitsPackageName = activityInfo.name.split("\\.");
String packageName = splitsPackageName[splitsPackageName.length - 2];
packages.add(packageName);
ArrayList<ActivityInfo> activityList = activities.get(packageName);
if(activityList == null){
activityList = new ArrayList<ActivityInfo>();
}
activityList.add(activityInfo);
activities.put(packageName, activityList);
}
mActivityListAdapter = new ActivityListAdapter(this, new ArrayList<String>(packages), activities);
// ListFragmentを初期化
FragmentManager fragmentManager = getSupportFragmentManager();
ActivityListFragment activityListFragment = ActivityListFragment.newInstance("Activity Not Found!");
fragmentManager.beginTransaction().replace(R.id.fragment, activityListFragment).commit();
activityListFragment.setListAdapter(mActivityListAdapter);
}
@Override | // Path: AndroidLibrary@wada811Demos/src/at/wada811/android/library/demos/ActivityListFragment.java
// public static interface ExpandableListListener {
//
// /**
// * Callback method to be invoked when a group in this expandable list has
// * been clicked.
// *
// * @param parent The ExpandableListConnector where the click happened
// * @param v The view within the expandable list/ListView that was clicked
// * @param groupPosition The group position that was clicked
// * @param id The row id of the group that was clicked
// * @return True if the click was handled
// */
// public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id);
//
// /**
// * Callback method to be invoked when a group in this expandable list has
// * been collapsed.
// *
// * @param groupPosition The group position that was collapsed
// */
// public void onGroupCollapse(int groupPosition);
//
// /**
// * Callback method to be invoked when a group in this expandable list has
// * been expanded.
// *
// * @param groupPosition The group position that was expanded
// */
// public void onGroupExpand(int groupPosition);
//
// /**
// * Callback method to be invoked when a child in this expandable list has
// * been clicked.
// *
// * @param parent The ExpandableListView where the click happened
// * @param v The view within the expandable list/ListView that was clicked
// * @param groupPosition The group position that contains the child that
// * was clicked
// * @param childPosition The child position within the group
// * @param id The row id of the child that was clicked
// * @return True if the click was handled
// */
// public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id);
// }
//
// Path: AndroidLibrary@wada811Demos/src/at/wada811/android/library/demos/ActivityListFragment.java
// public static interface ExpandableListListenerProvider {
// public ExpandableListListener getExpandableListListener();
// }
// Path: AndroidLibrary@wada811Demos/src/at/wada811/android/library/demos/MainActivity.java
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.View;
import android.widget.ExpandableListView;
import at.wada811.android.library.demos.ActivityListFragment.ExpandableListListener;
import at.wada811.android.library.demos.ActivityListFragment.ExpandableListListenerProvider;
import at.wada811.android.library.demos.broadcastreceiver.DateTimeChangeReceiver;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.TreeSet;
Collections.sort(activityInfos, new Comparator<ActivityInfo>(){
@Override
public int compare(ActivityInfo lhs, ActivityInfo rhs){
return lhs.name.compareTo(rhs.name);
}
});
// packages の生成
TreeSet<String> packages = new TreeSet<String>();
// activities の生成
HashMap<String, ArrayList<ActivityInfo>> activities = new HashMap<String, ArrayList<ActivityInfo>>();
for(ActivityInfo activityInfo : activityInfos){
String[] splitsPackageName = activityInfo.name.split("\\.");
String packageName = splitsPackageName[splitsPackageName.length - 2];
packages.add(packageName);
ArrayList<ActivityInfo> activityList = activities.get(packageName);
if(activityList == null){
activityList = new ArrayList<ActivityInfo>();
}
activityList.add(activityInfo);
activities.put(packageName, activityList);
}
mActivityListAdapter = new ActivityListAdapter(this, new ArrayList<String>(packages), activities);
// ListFragmentを初期化
FragmentManager fragmentManager = getSupportFragmentManager();
ActivityListFragment activityListFragment = ActivityListFragment.newInstance("Activity Not Found!");
fragmentManager.beginTransaction().replace(R.id.fragment, activityListFragment).commit();
activityListFragment.setListAdapter(mActivityListAdapter);
}
@Override | public ExpandableListListener getExpandableListListener(){ |
bpatters/schemagen-graphql | src/test/java/com/bretpatterson/schemagen/graphql/relay/model/impl/Game.java | // Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/model/IGame.java
// public interface IGame {
//
// Long getId();
//
// IGame setId(Long id);
//
// String getName();
//
// IGame setName(String name);
//
// List<IUser> getUsers();
//
// IGame setUsers(List<IUser> users);
// }
//
// Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/model/IUser.java
// public interface IUser {
//
// Long getId();
//
// IUser setId(Long id);
//
// String getName();
//
// IUser setName(String name);
//
// String getEmail();
//
// IUser setEmail(String email);
// }
| import com.bretpatterson.schemagen.graphql.relay.model.IGame;
import com.bretpatterson.schemagen.graphql.relay.model.IUser;
import com.google.common.collect.Lists;
import java.util.List; | package com.bretpatterson.schemagen.graphql.relay.model.impl;
/**
* Created by bpatterson on 1/27/16.
*/
public class Game implements IGame {
private Long id;
private String name; | // Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/model/IGame.java
// public interface IGame {
//
// Long getId();
//
// IGame setId(Long id);
//
// String getName();
//
// IGame setName(String name);
//
// List<IUser> getUsers();
//
// IGame setUsers(List<IUser> users);
// }
//
// Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/model/IUser.java
// public interface IUser {
//
// Long getId();
//
// IUser setId(Long id);
//
// String getName();
//
// IUser setName(String name);
//
// String getEmail();
//
// IUser setEmail(String email);
// }
// Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/model/impl/Game.java
import com.bretpatterson.schemagen.graphql.relay.model.IGame;
import com.bretpatterson.schemagen.graphql.relay.model.IUser;
import com.google.common.collect.Lists;
import java.util.List;
package com.bretpatterson.schemagen.graphql.relay.model.impl;
/**
* Created by bpatterson on 1/27/16.
*/
public class Game implements IGame {
private Long id;
private String name; | private List<IUser> users; |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/impl/SimpleTypeNamingStrategy.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/ITypeNamingStrategy.java
// public interface ITypeNamingStrategy {
//
// /**
// * Get the GraphQL type name for the specified type
// * @param graphQLObjectMapper
// * @param type
// * @return
// */
// String getTypeName(IGraphQLObjectMapper graphQLObjectMapper, Type type);
//
// /**
// * String to append to GraphQL InputType's
// * @return
// */
// String getInputTypePostfix();
//
// /**
// * Delimiter used for separating sections of a type name
// * @return
// */
// String getDelimiter();
// }
| import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.ITypeNamingStrategy;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLName;
import com.google.common.base.Preconditions;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type; | package com.bretpatterson.schemagen.graphql.impl;
/**
* Type naming strategy that uses the simple class name as the GraphQL type.
*/
public class SimpleTypeNamingStrategy implements ITypeNamingStrategy {
private final String delimiter;
private final String inputTypePostfix;
public SimpleTypeNamingStrategy(String delimiter, String inputTypePostfix) {
Preconditions.checkNotNull(delimiter, "Delimiter cannot be null.");
Preconditions.checkNotNull(inputTypePostfix, "InputType Postfix cannot be null.");
this.delimiter = delimiter;
this.inputTypePostfix = inputTypePostfix;
}
public SimpleTypeNamingStrategy() {
this("_", "Input");
}
@Override | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/ITypeNamingStrategy.java
// public interface ITypeNamingStrategy {
//
// /**
// * Get the GraphQL type name for the specified type
// * @param graphQLObjectMapper
// * @param type
// * @return
// */
// String getTypeName(IGraphQLObjectMapper graphQLObjectMapper, Type type);
//
// /**
// * String to append to GraphQL InputType's
// * @return
// */
// String getInputTypePostfix();
//
// /**
// * Delimiter used for separating sections of a type name
// * @return
// */
// String getDelimiter();
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/impl/SimpleTypeNamingStrategy.java
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.ITypeNamingStrategy;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLName;
import com.google.common.base.Preconditions;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
package com.bretpatterson.schemagen.graphql.impl;
/**
* Type naming strategy that uses the simple class name as the GraphQL type.
*/
public class SimpleTypeNamingStrategy implements ITypeNamingStrategy {
private final String delimiter;
private final String inputTypePostfix;
public SimpleTypeNamingStrategy(String delimiter, String inputTypePostfix) {
Preconditions.checkNotNull(delimiter, "Delimiter cannot be null.");
Preconditions.checkNotNull(inputTypePostfix, "InputType Postfix cannot be null.");
this.delimiter = delimiter;
this.inputTypePostfix = inputTypePostfix;
}
public SimpleTypeNamingStrategy() {
this("_", "Input");
}
@Override | public String getTypeName(IGraphQLObjectMapper graphQLObjectMapper, Type type) { |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/typemappers/java/util/CollectionMapper.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
| import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLList;
import graphql.schema.GraphQLOutputType;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Collection; | package com.bretpatterson.schemagen.graphql.typemappers.java.util;
/**
* Default interface mapper for all Collections. Converts all collections
* into a GraphQLList type containing the type of object the collection contains.
*/
@GraphQLTypeMapper(type = Collection.class)
public class CollectionMapper implements IGraphQLTypeMapper {
@Override | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/typemappers/java/util/CollectionMapper.java
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLList;
import graphql.schema.GraphQLOutputType;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Collection;
package com.bretpatterson.schemagen.graphql.typemappers.java.util;
/**
* Default interface mapper for all Collections. Converts all collections
* into a GraphQLList type containing the type of object the collection contains.
*/
@GraphQLTypeMapper(type = Collection.class)
public class CollectionMapper implements IGraphQLTypeMapper {
@Override | public boolean handlesType(IGraphQLObjectMapper graphQLObjectMapper, Type type) { |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/typemappers/java/math/BigIntegerMapper.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
| import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.Scalars;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLOutputType;
import java.lang.reflect.Type;
import java.math.BigInteger; | package com.bretpatterson.schemagen.graphql.typemappers.java.math;
/**
* DefaultType Mapper to convert a BigInteger to a GraphQLLong data type.
*/
@GraphQLTypeMapper(type= BigInteger.class)
public class BigIntegerMapper implements IGraphQLTypeMapper{
@Override | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/typemappers/java/math/BigIntegerMapper.java
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.Scalars;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLOutputType;
import java.lang.reflect.Type;
import java.math.BigInteger;
package com.bretpatterson.schemagen.graphql.typemappers.java.math;
/**
* DefaultType Mapper to convert a BigInteger to a GraphQLLong data type.
*/
@GraphQLTypeMapper(type= BigInteger.class)
public class BigIntegerMapper implements IGraphQLTypeMapper{
@Override | public boolean handlesType(IGraphQLObjectMapper graphQLObjectMapper, Type type) { |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/annotations/GraphQLParam.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/utils/AnnotationUtils.java
// public class AnnotationUtils {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(AnnotationUtils.class);
// public static final String DEFAULT_NULL = "\n\t\t\n\t\t\n\uE000\uE001\uE002\n\t\t\t\t\n";
// private static ClassLoader classLoader;
// private static ClassPath classPath;
//
// public final static class DEFAULT_NULL_CLASS extends DefaultMethodDataFetcher {}
// static {
// try {
// // Change classloader to work with spring boot executable jars
// // http://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html#executable-jar-system-classloader
// classLoader = Thread.currentThread().getContextClassLoader();
// classPath = ClassPath.from(classLoader);
// } catch (IOException ex) {
// Throwables.propagate(ex);
// }
// }
// @SuppressWarnings("unchecked")
// public static <T> T findAnnotation(Annotation[] annotations, Class<T> type) {
// for (Annotation annotation : annotations) {
// if (annotation.annotationType() == type) {
// return (T) annotation;
// }
// }
// return null;
// }
//
// public static <T extends Annotation> Map<Class<?>, T> getClassesWithAnnotation(Class<T> annotation, String packageName) {
// ImmutableMap.Builder<Class<?>, T> results = ImmutableMap.builder();
// try {
// ImmutableSet<ClassPath.ClassInfo> classes = classPath.getTopLevelClassesRecursive(packageName);
// for (ClassPath.ClassInfo info : classes) {
// try {
// Class<?> type = info.load();
// T classAnnotation = type.getAnnotation(annotation);
// if (classAnnotation != null) {
// LOGGER.info("Found {} with annotation {}.", type.getCanonicalName(), annotation.getClass());
// results.put(type, classAnnotation);
// }
// } catch (NoClassDefFoundError ex) {
// LOGGER.warn("Failed to load {}. This is probably because of an unsatisfied runtime dependency.", ex);
// }
// }
// } catch (Exception ex) {
// Throwables.propagate(ex);
// }
//
// return results.build();
// }
//
// public static <T extends Annotation> List<Method> getMethodsWithAnnotation(Class<?> targetClass, Class<T> annotationClass) {
// ImmutableList.Builder<Method> methods = ImmutableList.builder();
//
// for (Method method : targetClass.getDeclaredMethods()) {
// T annotation = method.getAnnotation(annotationClass);
// if (annotation != null) {
// methods.add(method);
// }
// }
//
// return methods.build();
// }
//
// public static <T extends Annotation> List<Field> getFieldsWithAnnotation(Class<?> targetClass, Class<T> annotationClass) {
// ImmutableList.Builder<Field> fields = ImmutableList.builder();
//
// for (Field field : targetClass.getDeclaredFields()) {
// T annotation = field.getAnnotation(annotationClass);
// if (annotation != null) {
// fields.add(field);
// }
// }
//
// return fields.build();
// }
//
// public static boolean isNullValue(String value) {
// return DEFAULT_NULL.equals(value);
// }
//
// public static boolean isNullValue(Class<?> value) {
// return DEFAULT_NULL_CLASS.class.equals(value);
// }
// }
| import com.bretpatterson.schemagen.graphql.utils.AnnotationUtils;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.bretpatterson.schemagen.graphql.annotations;
/**
* Created by bpatterson on 1/18/16.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER})
public @interface GraphQLParam {
/**
* The Query/Mutation parameter name
* @return
*/
String name();
/**
* The Default value for this property. Defaults to null.
* @return
*/ | // Path: src/main/java/com/bretpatterson/schemagen/graphql/utils/AnnotationUtils.java
// public class AnnotationUtils {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(AnnotationUtils.class);
// public static final String DEFAULT_NULL = "\n\t\t\n\t\t\n\uE000\uE001\uE002\n\t\t\t\t\n";
// private static ClassLoader classLoader;
// private static ClassPath classPath;
//
// public final static class DEFAULT_NULL_CLASS extends DefaultMethodDataFetcher {}
// static {
// try {
// // Change classloader to work with spring boot executable jars
// // http://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html#executable-jar-system-classloader
// classLoader = Thread.currentThread().getContextClassLoader();
// classPath = ClassPath.from(classLoader);
// } catch (IOException ex) {
// Throwables.propagate(ex);
// }
// }
// @SuppressWarnings("unchecked")
// public static <T> T findAnnotation(Annotation[] annotations, Class<T> type) {
// for (Annotation annotation : annotations) {
// if (annotation.annotationType() == type) {
// return (T) annotation;
// }
// }
// return null;
// }
//
// public static <T extends Annotation> Map<Class<?>, T> getClassesWithAnnotation(Class<T> annotation, String packageName) {
// ImmutableMap.Builder<Class<?>, T> results = ImmutableMap.builder();
// try {
// ImmutableSet<ClassPath.ClassInfo> classes = classPath.getTopLevelClassesRecursive(packageName);
// for (ClassPath.ClassInfo info : classes) {
// try {
// Class<?> type = info.load();
// T classAnnotation = type.getAnnotation(annotation);
// if (classAnnotation != null) {
// LOGGER.info("Found {} with annotation {}.", type.getCanonicalName(), annotation.getClass());
// results.put(type, classAnnotation);
// }
// } catch (NoClassDefFoundError ex) {
// LOGGER.warn("Failed to load {}. This is probably because of an unsatisfied runtime dependency.", ex);
// }
// }
// } catch (Exception ex) {
// Throwables.propagate(ex);
// }
//
// return results.build();
// }
//
// public static <T extends Annotation> List<Method> getMethodsWithAnnotation(Class<?> targetClass, Class<T> annotationClass) {
// ImmutableList.Builder<Method> methods = ImmutableList.builder();
//
// for (Method method : targetClass.getDeclaredMethods()) {
// T annotation = method.getAnnotation(annotationClass);
// if (annotation != null) {
// methods.add(method);
// }
// }
//
// return methods.build();
// }
//
// public static <T extends Annotation> List<Field> getFieldsWithAnnotation(Class<?> targetClass, Class<T> annotationClass) {
// ImmutableList.Builder<Field> fields = ImmutableList.builder();
//
// for (Field field : targetClass.getDeclaredFields()) {
// T annotation = field.getAnnotation(annotationClass);
// if (annotation != null) {
// fields.add(field);
// }
// }
//
// return fields.build();
// }
//
// public static boolean isNullValue(String value) {
// return DEFAULT_NULL.equals(value);
// }
//
// public static boolean isNullValue(Class<?> value) {
// return DEFAULT_NULL_CLASS.class.equals(value);
// }
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/annotations/GraphQLParam.java
import com.bretpatterson.schemagen.graphql.utils.AnnotationUtils;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.bretpatterson.schemagen.graphql.annotations;
/**
* Created by bpatterson on 1/18/16.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER})
public @interface GraphQLParam {
/**
* The Query/Mutation parameter name
* @return
*/
String name();
/**
* The Default value for this property. Defaults to null.
* @return
*/ | String defaultValue() default AnnotationUtils.DEFAULT_NULL; |
bpatters/schemagen-graphql | schemagen-graphql-spring/src/main/java/com/bretpatterson/schemagen/graphql/GraphQLSpringSchemaBuilder.java | // Path: schemagen-graphql-spring/src/main/java/com/bretpatterson/schemagen/graphql/datafetchers/spring/SpringDataFetcherFactory.java
// public class SpringDataFetcherFactory extends DefaultDataFetcherFactory {
//
// ApplicationContext context;
// SpringBeanELResolver springBeanELResolver;
//
// public SpringDataFetcherFactory(ApplicationContext context) {
// this.context = context;
// }
//
// @Override
// public DataFetcher newFieldDataFetcher(final IGraphQLObjectMapper graphQLObjectMapper, final Optional<Object> targetObject, final Field field, final String fieldName, Class<? extends DataFetcher> dataFetcher) {
//
// SpringDataFetcher dataFetcherObject = null;
// try {
// GraphQLSpringELDataFetcher springDataFetcher = field.getAnnotation(GraphQLSpringELDataFetcher.class);
// if (springDataFetcher != null) {
// dataFetcherObject = springDataFetcher.dataFetcher().newInstance();
// dataFetcherObject.setFieldName(field.getName());
// dataFetcherObject.setTypeFactory(graphQLObjectMapper.getTypeFactory());
// dataFetcherObject.setTargetObject(null);
// dataFetcherObject.setMethod(null);
// dataFetcherObject.setExpression(springDataFetcher.value());
// dataFetcherObject.setApplicationContext(context);
// return dataFetcherObject;
// }
// } catch (Exception ex) {
// throw Throwables.propagate(ex);
// }
//
// return super.newFieldDataFetcher(graphQLObjectMapper, targetObject, field, fieldName, dataFetcher);
// }
//
// @Override
// public DataFetcher newMethodDataFetcher(final IGraphQLObjectMapper graphQLObjectMapper,
// final Optional<Object> targetObject,
// final Method method,
// final String fieldName,
// final Class<? extends DataFetcher> dataFetcher) {
// checkNotNull(method);
// SpringDataFetcher dataFetcherObject = null;
// try {
// GraphQLSpringELDataFetcher springDataFetcher = method.getAnnotation(GraphQLSpringELDataFetcher.class);
// if (springDataFetcher != null) {
// dataFetcherObject = springDataFetcher.dataFetcher().newInstance();
// dataFetcherObject.setFieldName(fieldName);
// dataFetcherObject.setTypeFactory(graphQLObjectMapper.getTypeFactory());
// dataFetcherObject.setTargetObject(targetObject);
// dataFetcherObject.setMethod(method);
// dataFetcherObject.setExpression(springDataFetcher.value());
// dataFetcherObject.setApplicationContext(context);
// return dataFetcherObject;
// }
// } catch (Exception ex) {
// throw Throwables.propagate(ex);
// }
// return super.newMethodDataFetcher(graphQLObjectMapper, targetObject, method, fieldName, dataFetcher);
// }
//
// }
| import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.datafetchers.spring.SpringDataFetcherFactory;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import com.google.common.collect.ImmutableList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.util.ClassUtils;
import java.util.List; | package com.bretpatterson.schemagen.graphql;
public class GraphQLSpringSchemaBuilder extends GraphQLSchemaBuilder {
private static final Logger LOGGER = LoggerFactory.getLogger(GraphQLSpringSchemaBuilder.class);
private final ApplicationContext applicationContext;
public GraphQLSpringSchemaBuilder(ApplicationContext applicationContext) {
super();
this.applicationContext = applicationContext; | // Path: schemagen-graphql-spring/src/main/java/com/bretpatterson/schemagen/graphql/datafetchers/spring/SpringDataFetcherFactory.java
// public class SpringDataFetcherFactory extends DefaultDataFetcherFactory {
//
// ApplicationContext context;
// SpringBeanELResolver springBeanELResolver;
//
// public SpringDataFetcherFactory(ApplicationContext context) {
// this.context = context;
// }
//
// @Override
// public DataFetcher newFieldDataFetcher(final IGraphQLObjectMapper graphQLObjectMapper, final Optional<Object> targetObject, final Field field, final String fieldName, Class<? extends DataFetcher> dataFetcher) {
//
// SpringDataFetcher dataFetcherObject = null;
// try {
// GraphQLSpringELDataFetcher springDataFetcher = field.getAnnotation(GraphQLSpringELDataFetcher.class);
// if (springDataFetcher != null) {
// dataFetcherObject = springDataFetcher.dataFetcher().newInstance();
// dataFetcherObject.setFieldName(field.getName());
// dataFetcherObject.setTypeFactory(graphQLObjectMapper.getTypeFactory());
// dataFetcherObject.setTargetObject(null);
// dataFetcherObject.setMethod(null);
// dataFetcherObject.setExpression(springDataFetcher.value());
// dataFetcherObject.setApplicationContext(context);
// return dataFetcherObject;
// }
// } catch (Exception ex) {
// throw Throwables.propagate(ex);
// }
//
// return super.newFieldDataFetcher(graphQLObjectMapper, targetObject, field, fieldName, dataFetcher);
// }
//
// @Override
// public DataFetcher newMethodDataFetcher(final IGraphQLObjectMapper graphQLObjectMapper,
// final Optional<Object> targetObject,
// final Method method,
// final String fieldName,
// final Class<? extends DataFetcher> dataFetcher) {
// checkNotNull(method);
// SpringDataFetcher dataFetcherObject = null;
// try {
// GraphQLSpringELDataFetcher springDataFetcher = method.getAnnotation(GraphQLSpringELDataFetcher.class);
// if (springDataFetcher != null) {
// dataFetcherObject = springDataFetcher.dataFetcher().newInstance();
// dataFetcherObject.setFieldName(fieldName);
// dataFetcherObject.setTypeFactory(graphQLObjectMapper.getTypeFactory());
// dataFetcherObject.setTargetObject(targetObject);
// dataFetcherObject.setMethod(method);
// dataFetcherObject.setExpression(springDataFetcher.value());
// dataFetcherObject.setApplicationContext(context);
// return dataFetcherObject;
// }
// } catch (Exception ex) {
// throw Throwables.propagate(ex);
// }
// return super.newMethodDataFetcher(graphQLObjectMapper, targetObject, method, fieldName, dataFetcher);
// }
//
// }
// Path: schemagen-graphql-spring/src/main/java/com/bretpatterson/schemagen/graphql/GraphQLSpringSchemaBuilder.java
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.datafetchers.spring.SpringDataFetcherFactory;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import com.google.common.collect.ImmutableList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.util.ClassUtils;
import java.util.List;
package com.bretpatterson.schemagen.graphql;
public class GraphQLSpringSchemaBuilder extends GraphQLSchemaBuilder {
private static final Logger LOGGER = LoggerFactory.getLogger(GraphQLSpringSchemaBuilder.class);
private final ApplicationContext applicationContext;
public GraphQLSpringSchemaBuilder(ApplicationContext applicationContext) {
super();
this.applicationContext = applicationContext; | this.registerDataFetcherFactory(new SpringDataFetcherFactory(applicationContext)); |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/typemappers/java/util/MapMapper.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
| import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.exceptions.NotMappableException;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLInputObjectField;
import graphql.schema.GraphQLInputObjectType;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLList;
import graphql.schema.GraphQLObjectType;
import graphql.schema.GraphQLOutputType;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Map; | package com.bretpatterson.schemagen.graphql.typemappers.java.util;
/**
* GraphQL doesn't support generic maps fully. However this implementation attempts to support them as best it can. It currently supports
* {@code Map<Enum, Object> } since the set of keys is well defined. In this case it maps this datatype to an Object of Enum {@literal -->} GraphQLType
* where the keys of Enum are fields and values are the field values.
*/
@GraphQLTypeMapper(type = Map.class)
public class MapMapper implements IGraphQLTypeMapper {
public static final String KEY_NAME = "key";
public static final String VALUE_NAME = "value";
@Override | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/typemappers/java/util/MapMapper.java
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.exceptions.NotMappableException;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLInputObjectField;
import graphql.schema.GraphQLInputObjectType;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLList;
import graphql.schema.GraphQLObjectType;
import graphql.schema.GraphQLOutputType;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Map;
package com.bretpatterson.schemagen.graphql.typemappers.java.util;
/**
* GraphQL doesn't support generic maps fully. However this implementation attempts to support them as best it can. It currently supports
* {@code Map<Enum, Object> } since the set of keys is well defined. In this case it maps this datatype to an Object of Enum {@literal -->} GraphQLType
* where the keys of Enum are fields and values are the field values.
*/
@GraphQLTypeMapper(type = Map.class)
public class MapMapper implements IGraphQLTypeMapper {
public static final String KEY_NAME = "key";
public static final String VALUE_NAME = "value";
@Override | public boolean handlesType(IGraphQLObjectMapper graphQLObjectMapper, Type type) { |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/typemappers/java/util/TimeZoneMapper.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
| import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.Scalars;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLOutputType;
import java.lang.reflect.Type;
import java.util.TimeZone; | package com.bretpatterson.schemagen.graphql.typemappers.java.util;
/**
* Maps a TimeZone object into a GraphQLString
*/
@GraphQLTypeMapper(type=TimeZone.class)
public class TimeZoneMapper implements IGraphQLTypeMapper {
@Override | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/typemappers/java/util/TimeZoneMapper.java
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.Scalars;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLOutputType;
import java.lang.reflect.Type;
import java.util.TimeZone;
package com.bretpatterson.schemagen.graphql.typemappers.java.util;
/**
* Maps a TimeZone object into a GraphQLString
*/
@GraphQLTypeMapper(type=TimeZone.class)
public class TimeZoneMapper implements IGraphQLTypeMapper {
@Override | public boolean handlesType(IGraphQLObjectMapper graphQLObjectMapper, Type type) { |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/impl/FullTypeNamingStrategy.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
| import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import java.lang.reflect.Type; | package com.bretpatterson.schemagen.graphql.impl;
/**
* Generates type names using the full package name with . replaced with _
*/
public class FullTypeNamingStrategy extends SimpleTypeNamingStrategy {
@Override | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/impl/FullTypeNamingStrategy.java
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import java.lang.reflect.Type;
package com.bretpatterson.schemagen.graphql.impl;
/**
* Generates type names using the full package name with . replaced with _
*/
public class FullTypeNamingStrategy extends SimpleTypeNamingStrategy {
@Override | public String getTypeName(IGraphQLObjectMapper graphQLObjectMapper, Type type) { |
bpatters/schemagen-graphql | schemagen-graphql-spring/src/main/java/com/bretpatterson/schemagen/graphql/datafetchers/spring/SpringDataFetcherFactory.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/impl/DefaultDataFetcherFactory.java
// public class DefaultDataFetcherFactory implements IDataFetcherFactory {
//
// @Override
// public DataFetcher newFieldDataFetcher(final IGraphQLObjectMapper objectMapper, final Optional<Object> targetObject, final Field field, String fieldName, Class<? extends DataFetcher> dataFetcher) {
// if (dataFetcher != null) {
// try {
// return dataFetcher.newInstance();
// } catch (IllegalAccessException | InstantiationException ex) {
// throw Throwables.propagate(ex);
// }
// } else {
// return new PropertyDataFetcher(fieldName);
// }
// }
//
// @Override
// public DataFetcher newMethodDataFetcher(final IGraphQLObjectMapper graphQLObjectMapper,
// final Optional<Object> targetObject,
// final Method method,
// final String fieldName,
// final Class<? extends DataFetcher> dataFetcher) {
// DataFetcher dataFetcherObject;
// try {
// dataFetcherObject = dataFetcher.newInstance();
// if (!IMethodDataFetcher.class.isAssignableFrom(dataFetcher)) {
// throw new InvalidParameterException("This Data Fetcher Factory only supports IMethodDataFetchers");
// }
// IMethodDataFetcher methodDataFetcher = (IMethodDataFetcher) dataFetcherObject;
// methodDataFetcher.setFieldName(fieldName);
// methodDataFetcher.setTypeFactory(graphQLObjectMapper.getTypeFactory());
// if (targetObject.isPresent()) {
// methodDataFetcher.setTargetObject(targetObject.get());
// }
// methodDataFetcher.setMethod(method);
// } catch (Exception ex) {
// throw Throwables.propagate(ex);
// }
// return dataFetcherObject;
// }
// }
| import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLSpringELDataFetcher;
import com.bretpatterson.schemagen.graphql.impl.DefaultDataFetcherFactory;
import com.google.common.base.Optional;
import com.google.common.base.Throwables;
import graphql.schema.DataFetcher;
import org.springframework.beans.factory.access.el.SpringBeanELResolver;
import org.springframework.context.ApplicationContext;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import static com.google.common.base.Preconditions.checkNotNull; | package com.bretpatterson.schemagen.graphql.datafetchers.spring;
/**
* Supports methods/fields annotated with the @GraphQLSpringDataFetcher annotation. This allows you to execute Spring EL expressions as part
* of your datafetching environment.
*/
public class SpringDataFetcherFactory extends DefaultDataFetcherFactory {
ApplicationContext context;
SpringBeanELResolver springBeanELResolver;
public SpringDataFetcherFactory(ApplicationContext context) {
this.context = context;
}
@Override | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/impl/DefaultDataFetcherFactory.java
// public class DefaultDataFetcherFactory implements IDataFetcherFactory {
//
// @Override
// public DataFetcher newFieldDataFetcher(final IGraphQLObjectMapper objectMapper, final Optional<Object> targetObject, final Field field, String fieldName, Class<? extends DataFetcher> dataFetcher) {
// if (dataFetcher != null) {
// try {
// return dataFetcher.newInstance();
// } catch (IllegalAccessException | InstantiationException ex) {
// throw Throwables.propagate(ex);
// }
// } else {
// return new PropertyDataFetcher(fieldName);
// }
// }
//
// @Override
// public DataFetcher newMethodDataFetcher(final IGraphQLObjectMapper graphQLObjectMapper,
// final Optional<Object> targetObject,
// final Method method,
// final String fieldName,
// final Class<? extends DataFetcher> dataFetcher) {
// DataFetcher dataFetcherObject;
// try {
// dataFetcherObject = dataFetcher.newInstance();
// if (!IMethodDataFetcher.class.isAssignableFrom(dataFetcher)) {
// throw new InvalidParameterException("This Data Fetcher Factory only supports IMethodDataFetchers");
// }
// IMethodDataFetcher methodDataFetcher = (IMethodDataFetcher) dataFetcherObject;
// methodDataFetcher.setFieldName(fieldName);
// methodDataFetcher.setTypeFactory(graphQLObjectMapper.getTypeFactory());
// if (targetObject.isPresent()) {
// methodDataFetcher.setTargetObject(targetObject.get());
// }
// methodDataFetcher.setMethod(method);
// } catch (Exception ex) {
// throw Throwables.propagate(ex);
// }
// return dataFetcherObject;
// }
// }
// Path: schemagen-graphql-spring/src/main/java/com/bretpatterson/schemagen/graphql/datafetchers/spring/SpringDataFetcherFactory.java
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLSpringELDataFetcher;
import com.bretpatterson.schemagen.graphql.impl.DefaultDataFetcherFactory;
import com.google.common.base.Optional;
import com.google.common.base.Throwables;
import graphql.schema.DataFetcher;
import org.springframework.beans.factory.access.el.SpringBeanELResolver;
import org.springframework.context.ApplicationContext;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import static com.google.common.base.Preconditions.checkNotNull;
package com.bretpatterson.schemagen.graphql.datafetchers.spring;
/**
* Supports methods/fields annotated with the @GraphQLSpringDataFetcher annotation. This allows you to execute Spring EL expressions as part
* of your datafetching environment.
*/
public class SpringDataFetcherFactory extends DefaultDataFetcherFactory {
ApplicationContext context;
SpringBeanELResolver springBeanELResolver;
public SpringDataFetcherFactory(ApplicationContext context) {
this.context = context;
}
@Override | public DataFetcher newFieldDataFetcher(final IGraphQLObjectMapper graphQLObjectMapper, final Optional<Object> targetObject, final Field field, final String fieldName, Class<? extends DataFetcher> dataFetcher) { |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/typemappers/java/math/BigDecimalMapper.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
| import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.Scalars;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLOutputType;
import java.lang.reflect.Type;
import java.math.BigDecimal; | package com.bretpatterson.schemagen.graphql.typemappers.java.math;
/**
* Type Mapper that converts a BigDecimal.class type to a GraphQLFloat data type
*/
@GraphQLTypeMapper(type= BigDecimal.class)
public class BigDecimalMapper implements IGraphQLTypeMapper{
@Override | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/typemappers/java/math/BigDecimalMapper.java
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.Scalars;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLOutputType;
import java.lang.reflect.Type;
import java.math.BigDecimal;
package com.bretpatterson.schemagen.graphql.typemappers.java.math;
/**
* Type Mapper that converts a BigDecimal.class type to a GraphQLFloat data type
*/
@GraphQLTypeMapper(type= BigDecimal.class)
public class BigDecimalMapper implements IGraphQLTypeMapper{
@Override | public boolean handlesType(IGraphQLObjectMapper graphQLObjectMapper, Type type) { |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/utils/AnnotationUtils.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/datafetchers/DefaultMethodDataFetcher.java
// public class DefaultMethodDataFetcher implements IMethodDataFetcher {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(DefaultMethodDataFetcher.class);
// protected ITypeFactory typeFactory;
//
// protected Method method;
// protected String fieldName;
// protected Optional<Object> targetObject = Optional.absent();
// protected LinkedHashMap<String, Type> argumentTypeMap = new LinkedHashMap<>();
// protected Map<String, Object> parameterDefaultValue = Maps.newHashMap();
//
// @Override
// public void setTargetObject(Object targetObject) {
// this.targetObject = Optional.fromNullable(targetObject);
// }
//
// @Override
// public void addParam(String name, Type type, Optional<Object> defaultValue) {
// argumentTypeMap.put(name, type);
// if (defaultValue.isPresent()) {
// parameterDefaultValue.put(name, defaultValue.get());
// }
// }
//
// Object getDefaultValue(DataFetchingEnvironment environment, String name, Type argumentType) {
// if (parameterDefaultValue.containsKey(name)) {
// return typeFactory.convertToType(argumentTypeMap.get(name), parameterDefaultValue.get(name));
// } else {
// return null;
// }
// }
//
// Object convertToType(Type argumentType, Object value) {
// if (value == null)
// return value;
//
// return typeFactory.convertToType(argumentType, value);
// }
//
// Object getParamValue(DataFetchingEnvironment environment, String argumentName, Type argumentType) {
// Object value = environment.getArgument(argumentName);
// if (value == null) {
// value = getDefaultValue(environment, argumentName, argumentType);
// }
// return convertToType(argumentType, value);
// }
//
// @Override
// public Object get(DataFetchingEnvironment environment) {
//
// for (Field field : environment.getFields()) {
// if (field.getName().equals(fieldName)) {
// Object[] arguments = new Object[argumentTypeMap.size()];
// int index = 0;
// for (String argumentName : argumentTypeMap.keySet()) {
// arguments[index] = getParamValue(environment, argumentName, argumentTypeMap.get(argumentName));
// index++;
// }
// return invokeMethod(environment, method, targetObject.isPresent() ? targetObject.get() : environment.getSource(), arguments);
// }
// }
// return null;
//
// }
//
// @Override
// public Object invokeMethod(DataFetchingEnvironment environment, Method method, Object target, Object[] arguments) {
// try {
// return method.invoke(target, (Object[]) arguments);
// } catch (Exception ex) {
// LOGGER.error("Unexpected exception.", ex);
// throw Throwables.propagate(ex);
// }
// }
//
// @Override
// public void setFieldName(String fieldName) {
// this.fieldName = fieldName;
// }
//
// @Override
// public void setMethod(Method method) {
// this.method = method;
// }
//
// @Override
// public void setTypeFactory(ITypeFactory typeFactory) {
// this.typeFactory = typeFactory;
// }
// }
| import com.bretpatterson.schemagen.graphql.datafetchers.DefaultMethodDataFetcher;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.ClassPath;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map; | package com.bretpatterson.schemagen.graphql.utils;
/**
* Common Annotation related utility methods.
*/
public class AnnotationUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(AnnotationUtils.class);
public static final String DEFAULT_NULL = "\n\t\t\n\t\t\n\uE000\uE001\uE002\n\t\t\t\t\n";
private static ClassLoader classLoader;
private static ClassPath classPath;
| // Path: src/main/java/com/bretpatterson/schemagen/graphql/datafetchers/DefaultMethodDataFetcher.java
// public class DefaultMethodDataFetcher implements IMethodDataFetcher {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(DefaultMethodDataFetcher.class);
// protected ITypeFactory typeFactory;
//
// protected Method method;
// protected String fieldName;
// protected Optional<Object> targetObject = Optional.absent();
// protected LinkedHashMap<String, Type> argumentTypeMap = new LinkedHashMap<>();
// protected Map<String, Object> parameterDefaultValue = Maps.newHashMap();
//
// @Override
// public void setTargetObject(Object targetObject) {
// this.targetObject = Optional.fromNullable(targetObject);
// }
//
// @Override
// public void addParam(String name, Type type, Optional<Object> defaultValue) {
// argumentTypeMap.put(name, type);
// if (defaultValue.isPresent()) {
// parameterDefaultValue.put(name, defaultValue.get());
// }
// }
//
// Object getDefaultValue(DataFetchingEnvironment environment, String name, Type argumentType) {
// if (parameterDefaultValue.containsKey(name)) {
// return typeFactory.convertToType(argumentTypeMap.get(name), parameterDefaultValue.get(name));
// } else {
// return null;
// }
// }
//
// Object convertToType(Type argumentType, Object value) {
// if (value == null)
// return value;
//
// return typeFactory.convertToType(argumentType, value);
// }
//
// Object getParamValue(DataFetchingEnvironment environment, String argumentName, Type argumentType) {
// Object value = environment.getArgument(argumentName);
// if (value == null) {
// value = getDefaultValue(environment, argumentName, argumentType);
// }
// return convertToType(argumentType, value);
// }
//
// @Override
// public Object get(DataFetchingEnvironment environment) {
//
// for (Field field : environment.getFields()) {
// if (field.getName().equals(fieldName)) {
// Object[] arguments = new Object[argumentTypeMap.size()];
// int index = 0;
// for (String argumentName : argumentTypeMap.keySet()) {
// arguments[index] = getParamValue(environment, argumentName, argumentTypeMap.get(argumentName));
// index++;
// }
// return invokeMethod(environment, method, targetObject.isPresent() ? targetObject.get() : environment.getSource(), arguments);
// }
// }
// return null;
//
// }
//
// @Override
// public Object invokeMethod(DataFetchingEnvironment environment, Method method, Object target, Object[] arguments) {
// try {
// return method.invoke(target, (Object[]) arguments);
// } catch (Exception ex) {
// LOGGER.error("Unexpected exception.", ex);
// throw Throwables.propagate(ex);
// }
// }
//
// @Override
// public void setFieldName(String fieldName) {
// this.fieldName = fieldName;
// }
//
// @Override
// public void setMethod(Method method) {
// this.method = method;
// }
//
// @Override
// public void setTypeFactory(ITypeFactory typeFactory) {
// this.typeFactory = typeFactory;
// }
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/utils/AnnotationUtils.java
import com.bretpatterson.schemagen.graphql.datafetchers.DefaultMethodDataFetcher;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.ClassPath;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
package com.bretpatterson.schemagen.graphql.utils;
/**
* Common Annotation related utility methods.
*/
public class AnnotationUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(AnnotationUtils.class);
public static final String DEFAULT_NULL = "\n\t\t\n\t\t\n\uE000\uE001\uE002\n\t\t\t\t\n";
private static ClassLoader classLoader;
private static ClassPath classPath;
| public final static class DEFAULT_NULL_CLASS extends DefaultMethodDataFetcher {} |
bpatters/schemagen-graphql | schemagen-graphql-joda/src/main/java/com/bretpatterson/schemagen/graphql/typemappers/org/joda/time/DateTimeMapper.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
| import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.Scalars;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLOutputType;
import org.joda.time.DateTime;
import java.lang.reflect.Type; | package com.bretpatterson.schemagen.graphql.typemappers.org.joda.time;
/**
* Created by bpatterson on 1/19/16.
*/
@GraphQLTypeMapper(type=DateTime.class)
public class DateTimeMapper implements IGraphQLTypeMapper {
@Override | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
// Path: schemagen-graphql-joda/src/main/java/com/bretpatterson/schemagen/graphql/typemappers/org/joda/time/DateTimeMapper.java
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.Scalars;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLOutputType;
import org.joda.time.DateTime;
import java.lang.reflect.Type;
package com.bretpatterson.schemagen.graphql.typemappers.org.joda.time;
/**
* Created by bpatterson on 1/19/16.
*/
@GraphQLTypeMapper(type=DateTime.class)
public class DateTimeMapper implements IGraphQLTypeMapper {
@Override | public boolean handlesType(IGraphQLObjectMapper graphQLObjectMapper, Type type) { |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/annotations/GraphQLController.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IMutationFactory.java
// public interface IMutationFactory {
//
// List<GraphQLFieldDefinition> newMethodMutationsForObject(IGraphQLObjectMapper graphQLObjectMapper, Object sourceObject);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/IQueryFactory.java
// public interface IQueryFactory {
//
// List<GraphQLFieldDefinition> newMethodQueriesForObject(IGraphQLObjectMapper graphQLObjectMapper, Object sourceObject);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/utils/AnnotationUtils.java
// public class AnnotationUtils {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(AnnotationUtils.class);
// public static final String DEFAULT_NULL = "\n\t\t\n\t\t\n\uE000\uE001\uE002\n\t\t\t\t\n";
// private static ClassLoader classLoader;
// private static ClassPath classPath;
//
// public final static class DEFAULT_NULL_CLASS extends DefaultMethodDataFetcher {}
// static {
// try {
// // Change classloader to work with spring boot executable jars
// // http://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html#executable-jar-system-classloader
// classLoader = Thread.currentThread().getContextClassLoader();
// classPath = ClassPath.from(classLoader);
// } catch (IOException ex) {
// Throwables.propagate(ex);
// }
// }
// @SuppressWarnings("unchecked")
// public static <T> T findAnnotation(Annotation[] annotations, Class<T> type) {
// for (Annotation annotation : annotations) {
// if (annotation.annotationType() == type) {
// return (T) annotation;
// }
// }
// return null;
// }
//
// public static <T extends Annotation> Map<Class<?>, T> getClassesWithAnnotation(Class<T> annotation, String packageName) {
// ImmutableMap.Builder<Class<?>, T> results = ImmutableMap.builder();
// try {
// ImmutableSet<ClassPath.ClassInfo> classes = classPath.getTopLevelClassesRecursive(packageName);
// for (ClassPath.ClassInfo info : classes) {
// try {
// Class<?> type = info.load();
// T classAnnotation = type.getAnnotation(annotation);
// if (classAnnotation != null) {
// LOGGER.info("Found {} with annotation {}.", type.getCanonicalName(), annotation.getClass());
// results.put(type, classAnnotation);
// }
// } catch (NoClassDefFoundError ex) {
// LOGGER.warn("Failed to load {}. This is probably because of an unsatisfied runtime dependency.", ex);
// }
// }
// } catch (Exception ex) {
// Throwables.propagate(ex);
// }
//
// return results.build();
// }
//
// public static <T extends Annotation> List<Method> getMethodsWithAnnotation(Class<?> targetClass, Class<T> annotationClass) {
// ImmutableList.Builder<Method> methods = ImmutableList.builder();
//
// for (Method method : targetClass.getDeclaredMethods()) {
// T annotation = method.getAnnotation(annotationClass);
// if (annotation != null) {
// methods.add(method);
// }
// }
//
// return methods.build();
// }
//
// public static <T extends Annotation> List<Field> getFieldsWithAnnotation(Class<?> targetClass, Class<T> annotationClass) {
// ImmutableList.Builder<Field> fields = ImmutableList.builder();
//
// for (Field field : targetClass.getDeclaredFields()) {
// T annotation = field.getAnnotation(annotationClass);
// if (annotation != null) {
// fields.add(field);
// }
// }
//
// return fields.build();
// }
//
// public static boolean isNullValue(String value) {
// return DEFAULT_NULL.equals(value);
// }
//
// public static boolean isNullValue(Class<?> value) {
// return DEFAULT_NULL_CLASS.class.equals(value);
// }
// }
| import com.bretpatterson.schemagen.graphql.IMutationFactory;
import com.bretpatterson.schemagen.graphql.IQueryFactory;
import com.bretpatterson.schemagen.graphql.impl.DefaultQueryAndMutationFactory;
import com.bretpatterson.schemagen.graphql.utils.AnnotationUtils;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.bretpatterson.schemagen.graphql.annotations;
/**
* Classes annotated with this method are scanned for methods defined as queryable.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface GraphQLController {
/**
* When using relay this must be set, otherwise it's an optional object name to wrapper
* this controllers top level queries within.
* @return
*/ | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IMutationFactory.java
// public interface IMutationFactory {
//
// List<GraphQLFieldDefinition> newMethodMutationsForObject(IGraphQLObjectMapper graphQLObjectMapper, Object sourceObject);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/IQueryFactory.java
// public interface IQueryFactory {
//
// List<GraphQLFieldDefinition> newMethodQueriesForObject(IGraphQLObjectMapper graphQLObjectMapper, Object sourceObject);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/utils/AnnotationUtils.java
// public class AnnotationUtils {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(AnnotationUtils.class);
// public static final String DEFAULT_NULL = "\n\t\t\n\t\t\n\uE000\uE001\uE002\n\t\t\t\t\n";
// private static ClassLoader classLoader;
// private static ClassPath classPath;
//
// public final static class DEFAULT_NULL_CLASS extends DefaultMethodDataFetcher {}
// static {
// try {
// // Change classloader to work with spring boot executable jars
// // http://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html#executable-jar-system-classloader
// classLoader = Thread.currentThread().getContextClassLoader();
// classPath = ClassPath.from(classLoader);
// } catch (IOException ex) {
// Throwables.propagate(ex);
// }
// }
// @SuppressWarnings("unchecked")
// public static <T> T findAnnotation(Annotation[] annotations, Class<T> type) {
// for (Annotation annotation : annotations) {
// if (annotation.annotationType() == type) {
// return (T) annotation;
// }
// }
// return null;
// }
//
// public static <T extends Annotation> Map<Class<?>, T> getClassesWithAnnotation(Class<T> annotation, String packageName) {
// ImmutableMap.Builder<Class<?>, T> results = ImmutableMap.builder();
// try {
// ImmutableSet<ClassPath.ClassInfo> classes = classPath.getTopLevelClassesRecursive(packageName);
// for (ClassPath.ClassInfo info : classes) {
// try {
// Class<?> type = info.load();
// T classAnnotation = type.getAnnotation(annotation);
// if (classAnnotation != null) {
// LOGGER.info("Found {} with annotation {}.", type.getCanonicalName(), annotation.getClass());
// results.put(type, classAnnotation);
// }
// } catch (NoClassDefFoundError ex) {
// LOGGER.warn("Failed to load {}. This is probably because of an unsatisfied runtime dependency.", ex);
// }
// }
// } catch (Exception ex) {
// Throwables.propagate(ex);
// }
//
// return results.build();
// }
//
// public static <T extends Annotation> List<Method> getMethodsWithAnnotation(Class<?> targetClass, Class<T> annotationClass) {
// ImmutableList.Builder<Method> methods = ImmutableList.builder();
//
// for (Method method : targetClass.getDeclaredMethods()) {
// T annotation = method.getAnnotation(annotationClass);
// if (annotation != null) {
// methods.add(method);
// }
// }
//
// return methods.build();
// }
//
// public static <T extends Annotation> List<Field> getFieldsWithAnnotation(Class<?> targetClass, Class<T> annotationClass) {
// ImmutableList.Builder<Field> fields = ImmutableList.builder();
//
// for (Field field : targetClass.getDeclaredFields()) {
// T annotation = field.getAnnotation(annotationClass);
// if (annotation != null) {
// fields.add(field);
// }
// }
//
// return fields.build();
// }
//
// public static boolean isNullValue(String value) {
// return DEFAULT_NULL.equals(value);
// }
//
// public static boolean isNullValue(Class<?> value) {
// return DEFAULT_NULL_CLASS.class.equals(value);
// }
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/annotations/GraphQLController.java
import com.bretpatterson.schemagen.graphql.IMutationFactory;
import com.bretpatterson.schemagen.graphql.IQueryFactory;
import com.bretpatterson.schemagen.graphql.impl.DefaultQueryAndMutationFactory;
import com.bretpatterson.schemagen.graphql.utils.AnnotationUtils;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.bretpatterson.schemagen.graphql.annotations;
/**
* Classes annotated with this method are scanned for methods defined as queryable.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface GraphQLController {
/**
* When using relay this must be set, otherwise it's an optional object name to wrapper
* this controllers top level queries within.
* @return
*/ | String rootQueriesObjectName() default AnnotationUtils.DEFAULT_NULL; |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/annotations/GraphQLController.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IMutationFactory.java
// public interface IMutationFactory {
//
// List<GraphQLFieldDefinition> newMethodMutationsForObject(IGraphQLObjectMapper graphQLObjectMapper, Object sourceObject);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/IQueryFactory.java
// public interface IQueryFactory {
//
// List<GraphQLFieldDefinition> newMethodQueriesForObject(IGraphQLObjectMapper graphQLObjectMapper, Object sourceObject);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/utils/AnnotationUtils.java
// public class AnnotationUtils {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(AnnotationUtils.class);
// public static final String DEFAULT_NULL = "\n\t\t\n\t\t\n\uE000\uE001\uE002\n\t\t\t\t\n";
// private static ClassLoader classLoader;
// private static ClassPath classPath;
//
// public final static class DEFAULT_NULL_CLASS extends DefaultMethodDataFetcher {}
// static {
// try {
// // Change classloader to work with spring boot executable jars
// // http://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html#executable-jar-system-classloader
// classLoader = Thread.currentThread().getContextClassLoader();
// classPath = ClassPath.from(classLoader);
// } catch (IOException ex) {
// Throwables.propagate(ex);
// }
// }
// @SuppressWarnings("unchecked")
// public static <T> T findAnnotation(Annotation[] annotations, Class<T> type) {
// for (Annotation annotation : annotations) {
// if (annotation.annotationType() == type) {
// return (T) annotation;
// }
// }
// return null;
// }
//
// public static <T extends Annotation> Map<Class<?>, T> getClassesWithAnnotation(Class<T> annotation, String packageName) {
// ImmutableMap.Builder<Class<?>, T> results = ImmutableMap.builder();
// try {
// ImmutableSet<ClassPath.ClassInfo> classes = classPath.getTopLevelClassesRecursive(packageName);
// for (ClassPath.ClassInfo info : classes) {
// try {
// Class<?> type = info.load();
// T classAnnotation = type.getAnnotation(annotation);
// if (classAnnotation != null) {
// LOGGER.info("Found {} with annotation {}.", type.getCanonicalName(), annotation.getClass());
// results.put(type, classAnnotation);
// }
// } catch (NoClassDefFoundError ex) {
// LOGGER.warn("Failed to load {}. This is probably because of an unsatisfied runtime dependency.", ex);
// }
// }
// } catch (Exception ex) {
// Throwables.propagate(ex);
// }
//
// return results.build();
// }
//
// public static <T extends Annotation> List<Method> getMethodsWithAnnotation(Class<?> targetClass, Class<T> annotationClass) {
// ImmutableList.Builder<Method> methods = ImmutableList.builder();
//
// for (Method method : targetClass.getDeclaredMethods()) {
// T annotation = method.getAnnotation(annotationClass);
// if (annotation != null) {
// methods.add(method);
// }
// }
//
// return methods.build();
// }
//
// public static <T extends Annotation> List<Field> getFieldsWithAnnotation(Class<?> targetClass, Class<T> annotationClass) {
// ImmutableList.Builder<Field> fields = ImmutableList.builder();
//
// for (Field field : targetClass.getDeclaredFields()) {
// T annotation = field.getAnnotation(annotationClass);
// if (annotation != null) {
// fields.add(field);
// }
// }
//
// return fields.build();
// }
//
// public static boolean isNullValue(String value) {
// return DEFAULT_NULL.equals(value);
// }
//
// public static boolean isNullValue(Class<?> value) {
// return DEFAULT_NULL_CLASS.class.equals(value);
// }
// }
| import com.bretpatterson.schemagen.graphql.IMutationFactory;
import com.bretpatterson.schemagen.graphql.IQueryFactory;
import com.bretpatterson.schemagen.graphql.impl.DefaultQueryAndMutationFactory;
import com.bretpatterson.schemagen.graphql.utils.AnnotationUtils;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.bretpatterson.schemagen.graphql.annotations;
/**
* Classes annotated with this method are scanned for methods defined as queryable.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface GraphQLController {
/**
* When using relay this must be set, otherwise it's an optional object name to wrapper
* this controllers top level queries within.
* @return
*/
String rootQueriesObjectName() default AnnotationUtils.DEFAULT_NULL;
/**
* When using relay this must be set, otherwise it's an optional object name to wrapper
* this controllers top level mutations within.
* @return
*/
String rootMutationsObjectName() default AnnotationUtils.DEFAULT_NULL;
/**
*
* This factory that will be used to generate queries for this object, if any.
* Default factory scans the object for {@link GraphQLQuery} annotated methods and turns
* the methods into queries.
* @return
*/ | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IMutationFactory.java
// public interface IMutationFactory {
//
// List<GraphQLFieldDefinition> newMethodMutationsForObject(IGraphQLObjectMapper graphQLObjectMapper, Object sourceObject);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/IQueryFactory.java
// public interface IQueryFactory {
//
// List<GraphQLFieldDefinition> newMethodQueriesForObject(IGraphQLObjectMapper graphQLObjectMapper, Object sourceObject);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/utils/AnnotationUtils.java
// public class AnnotationUtils {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(AnnotationUtils.class);
// public static final String DEFAULT_NULL = "\n\t\t\n\t\t\n\uE000\uE001\uE002\n\t\t\t\t\n";
// private static ClassLoader classLoader;
// private static ClassPath classPath;
//
// public final static class DEFAULT_NULL_CLASS extends DefaultMethodDataFetcher {}
// static {
// try {
// // Change classloader to work with spring boot executable jars
// // http://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html#executable-jar-system-classloader
// classLoader = Thread.currentThread().getContextClassLoader();
// classPath = ClassPath.from(classLoader);
// } catch (IOException ex) {
// Throwables.propagate(ex);
// }
// }
// @SuppressWarnings("unchecked")
// public static <T> T findAnnotation(Annotation[] annotations, Class<T> type) {
// for (Annotation annotation : annotations) {
// if (annotation.annotationType() == type) {
// return (T) annotation;
// }
// }
// return null;
// }
//
// public static <T extends Annotation> Map<Class<?>, T> getClassesWithAnnotation(Class<T> annotation, String packageName) {
// ImmutableMap.Builder<Class<?>, T> results = ImmutableMap.builder();
// try {
// ImmutableSet<ClassPath.ClassInfo> classes = classPath.getTopLevelClassesRecursive(packageName);
// for (ClassPath.ClassInfo info : classes) {
// try {
// Class<?> type = info.load();
// T classAnnotation = type.getAnnotation(annotation);
// if (classAnnotation != null) {
// LOGGER.info("Found {} with annotation {}.", type.getCanonicalName(), annotation.getClass());
// results.put(type, classAnnotation);
// }
// } catch (NoClassDefFoundError ex) {
// LOGGER.warn("Failed to load {}. This is probably because of an unsatisfied runtime dependency.", ex);
// }
// }
// } catch (Exception ex) {
// Throwables.propagate(ex);
// }
//
// return results.build();
// }
//
// public static <T extends Annotation> List<Method> getMethodsWithAnnotation(Class<?> targetClass, Class<T> annotationClass) {
// ImmutableList.Builder<Method> methods = ImmutableList.builder();
//
// for (Method method : targetClass.getDeclaredMethods()) {
// T annotation = method.getAnnotation(annotationClass);
// if (annotation != null) {
// methods.add(method);
// }
// }
//
// return methods.build();
// }
//
// public static <T extends Annotation> List<Field> getFieldsWithAnnotation(Class<?> targetClass, Class<T> annotationClass) {
// ImmutableList.Builder<Field> fields = ImmutableList.builder();
//
// for (Field field : targetClass.getDeclaredFields()) {
// T annotation = field.getAnnotation(annotationClass);
// if (annotation != null) {
// fields.add(field);
// }
// }
//
// return fields.build();
// }
//
// public static boolean isNullValue(String value) {
// return DEFAULT_NULL.equals(value);
// }
//
// public static boolean isNullValue(Class<?> value) {
// return DEFAULT_NULL_CLASS.class.equals(value);
// }
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/annotations/GraphQLController.java
import com.bretpatterson.schemagen.graphql.IMutationFactory;
import com.bretpatterson.schemagen.graphql.IQueryFactory;
import com.bretpatterson.schemagen.graphql.impl.DefaultQueryAndMutationFactory;
import com.bretpatterson.schemagen.graphql.utils.AnnotationUtils;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.bretpatterson.schemagen.graphql.annotations;
/**
* Classes annotated with this method are scanned for methods defined as queryable.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface GraphQLController {
/**
* When using relay this must be set, otherwise it's an optional object name to wrapper
* this controllers top level queries within.
* @return
*/
String rootQueriesObjectName() default AnnotationUtils.DEFAULT_NULL;
/**
* When using relay this must be set, otherwise it's an optional object name to wrapper
* this controllers top level mutations within.
* @return
*/
String rootMutationsObjectName() default AnnotationUtils.DEFAULT_NULL;
/**
*
* This factory that will be used to generate queries for this object, if any.
* Default factory scans the object for {@link GraphQLQuery} annotated methods and turns
* the methods into queries.
* @return
*/ | Class<? extends IQueryFactory> queryFactory() default DefaultQueryAndMutationFactory.class; |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/annotations/GraphQLController.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IMutationFactory.java
// public interface IMutationFactory {
//
// List<GraphQLFieldDefinition> newMethodMutationsForObject(IGraphQLObjectMapper graphQLObjectMapper, Object sourceObject);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/IQueryFactory.java
// public interface IQueryFactory {
//
// List<GraphQLFieldDefinition> newMethodQueriesForObject(IGraphQLObjectMapper graphQLObjectMapper, Object sourceObject);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/utils/AnnotationUtils.java
// public class AnnotationUtils {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(AnnotationUtils.class);
// public static final String DEFAULT_NULL = "\n\t\t\n\t\t\n\uE000\uE001\uE002\n\t\t\t\t\n";
// private static ClassLoader classLoader;
// private static ClassPath classPath;
//
// public final static class DEFAULT_NULL_CLASS extends DefaultMethodDataFetcher {}
// static {
// try {
// // Change classloader to work with spring boot executable jars
// // http://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html#executable-jar-system-classloader
// classLoader = Thread.currentThread().getContextClassLoader();
// classPath = ClassPath.from(classLoader);
// } catch (IOException ex) {
// Throwables.propagate(ex);
// }
// }
// @SuppressWarnings("unchecked")
// public static <T> T findAnnotation(Annotation[] annotations, Class<T> type) {
// for (Annotation annotation : annotations) {
// if (annotation.annotationType() == type) {
// return (T) annotation;
// }
// }
// return null;
// }
//
// public static <T extends Annotation> Map<Class<?>, T> getClassesWithAnnotation(Class<T> annotation, String packageName) {
// ImmutableMap.Builder<Class<?>, T> results = ImmutableMap.builder();
// try {
// ImmutableSet<ClassPath.ClassInfo> classes = classPath.getTopLevelClassesRecursive(packageName);
// for (ClassPath.ClassInfo info : classes) {
// try {
// Class<?> type = info.load();
// T classAnnotation = type.getAnnotation(annotation);
// if (classAnnotation != null) {
// LOGGER.info("Found {} with annotation {}.", type.getCanonicalName(), annotation.getClass());
// results.put(type, classAnnotation);
// }
// } catch (NoClassDefFoundError ex) {
// LOGGER.warn("Failed to load {}. This is probably because of an unsatisfied runtime dependency.", ex);
// }
// }
// } catch (Exception ex) {
// Throwables.propagate(ex);
// }
//
// return results.build();
// }
//
// public static <T extends Annotation> List<Method> getMethodsWithAnnotation(Class<?> targetClass, Class<T> annotationClass) {
// ImmutableList.Builder<Method> methods = ImmutableList.builder();
//
// for (Method method : targetClass.getDeclaredMethods()) {
// T annotation = method.getAnnotation(annotationClass);
// if (annotation != null) {
// methods.add(method);
// }
// }
//
// return methods.build();
// }
//
// public static <T extends Annotation> List<Field> getFieldsWithAnnotation(Class<?> targetClass, Class<T> annotationClass) {
// ImmutableList.Builder<Field> fields = ImmutableList.builder();
//
// for (Field field : targetClass.getDeclaredFields()) {
// T annotation = field.getAnnotation(annotationClass);
// if (annotation != null) {
// fields.add(field);
// }
// }
//
// return fields.build();
// }
//
// public static boolean isNullValue(String value) {
// return DEFAULT_NULL.equals(value);
// }
//
// public static boolean isNullValue(Class<?> value) {
// return DEFAULT_NULL_CLASS.class.equals(value);
// }
// }
| import com.bretpatterson.schemagen.graphql.IMutationFactory;
import com.bretpatterson.schemagen.graphql.IQueryFactory;
import com.bretpatterson.schemagen.graphql.impl.DefaultQueryAndMutationFactory;
import com.bretpatterson.schemagen.graphql.utils.AnnotationUtils;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.bretpatterson.schemagen.graphql.annotations;
/**
* Classes annotated with this method are scanned for methods defined as queryable.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface GraphQLController {
/**
* When using relay this must be set, otherwise it's an optional object name to wrapper
* this controllers top level queries within.
* @return
*/
String rootQueriesObjectName() default AnnotationUtils.DEFAULT_NULL;
/**
* When using relay this must be set, otherwise it's an optional object name to wrapper
* this controllers top level mutations within.
* @return
*/
String rootMutationsObjectName() default AnnotationUtils.DEFAULT_NULL;
/**
*
* This factory that will be used to generate queries for this object, if any.
* Default factory scans the object for {@link GraphQLQuery} annotated methods and turns
* the methods into queries.
* @return
*/
Class<? extends IQueryFactory> queryFactory() default DefaultQueryAndMutationFactory.class;
/**
* This factory that will be used to generate mutations for this object, if any.
* Default factory scans the object for {@link GraphQLMutation} annotated methods and turns
* the methods into mutations.
* @return
*/ | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IMutationFactory.java
// public interface IMutationFactory {
//
// List<GraphQLFieldDefinition> newMethodMutationsForObject(IGraphQLObjectMapper graphQLObjectMapper, Object sourceObject);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/IQueryFactory.java
// public interface IQueryFactory {
//
// List<GraphQLFieldDefinition> newMethodQueriesForObject(IGraphQLObjectMapper graphQLObjectMapper, Object sourceObject);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/utils/AnnotationUtils.java
// public class AnnotationUtils {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(AnnotationUtils.class);
// public static final String DEFAULT_NULL = "\n\t\t\n\t\t\n\uE000\uE001\uE002\n\t\t\t\t\n";
// private static ClassLoader classLoader;
// private static ClassPath classPath;
//
// public final static class DEFAULT_NULL_CLASS extends DefaultMethodDataFetcher {}
// static {
// try {
// // Change classloader to work with spring boot executable jars
// // http://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html#executable-jar-system-classloader
// classLoader = Thread.currentThread().getContextClassLoader();
// classPath = ClassPath.from(classLoader);
// } catch (IOException ex) {
// Throwables.propagate(ex);
// }
// }
// @SuppressWarnings("unchecked")
// public static <T> T findAnnotation(Annotation[] annotations, Class<T> type) {
// for (Annotation annotation : annotations) {
// if (annotation.annotationType() == type) {
// return (T) annotation;
// }
// }
// return null;
// }
//
// public static <T extends Annotation> Map<Class<?>, T> getClassesWithAnnotation(Class<T> annotation, String packageName) {
// ImmutableMap.Builder<Class<?>, T> results = ImmutableMap.builder();
// try {
// ImmutableSet<ClassPath.ClassInfo> classes = classPath.getTopLevelClassesRecursive(packageName);
// for (ClassPath.ClassInfo info : classes) {
// try {
// Class<?> type = info.load();
// T classAnnotation = type.getAnnotation(annotation);
// if (classAnnotation != null) {
// LOGGER.info("Found {} with annotation {}.", type.getCanonicalName(), annotation.getClass());
// results.put(type, classAnnotation);
// }
// } catch (NoClassDefFoundError ex) {
// LOGGER.warn("Failed to load {}. This is probably because of an unsatisfied runtime dependency.", ex);
// }
// }
// } catch (Exception ex) {
// Throwables.propagate(ex);
// }
//
// return results.build();
// }
//
// public static <T extends Annotation> List<Method> getMethodsWithAnnotation(Class<?> targetClass, Class<T> annotationClass) {
// ImmutableList.Builder<Method> methods = ImmutableList.builder();
//
// for (Method method : targetClass.getDeclaredMethods()) {
// T annotation = method.getAnnotation(annotationClass);
// if (annotation != null) {
// methods.add(method);
// }
// }
//
// return methods.build();
// }
//
// public static <T extends Annotation> List<Field> getFieldsWithAnnotation(Class<?> targetClass, Class<T> annotationClass) {
// ImmutableList.Builder<Field> fields = ImmutableList.builder();
//
// for (Field field : targetClass.getDeclaredFields()) {
// T annotation = field.getAnnotation(annotationClass);
// if (annotation != null) {
// fields.add(field);
// }
// }
//
// return fields.build();
// }
//
// public static boolean isNullValue(String value) {
// return DEFAULT_NULL.equals(value);
// }
//
// public static boolean isNullValue(Class<?> value) {
// return DEFAULT_NULL_CLASS.class.equals(value);
// }
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/annotations/GraphQLController.java
import com.bretpatterson.schemagen.graphql.IMutationFactory;
import com.bretpatterson.schemagen.graphql.IQueryFactory;
import com.bretpatterson.schemagen.graphql.impl.DefaultQueryAndMutationFactory;
import com.bretpatterson.schemagen.graphql.utils.AnnotationUtils;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.bretpatterson.schemagen.graphql.annotations;
/**
* Classes annotated with this method are scanned for methods defined as queryable.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface GraphQLController {
/**
* When using relay this must be set, otherwise it's an optional object name to wrapper
* this controllers top level queries within.
* @return
*/
String rootQueriesObjectName() default AnnotationUtils.DEFAULT_NULL;
/**
* When using relay this must be set, otherwise it's an optional object name to wrapper
* this controllers top level mutations within.
* @return
*/
String rootMutationsObjectName() default AnnotationUtils.DEFAULT_NULL;
/**
*
* This factory that will be used to generate queries for this object, if any.
* Default factory scans the object for {@link GraphQLQuery} annotated methods and turns
* the methods into queries.
* @return
*/
Class<? extends IQueryFactory> queryFactory() default DefaultQueryAndMutationFactory.class;
/**
* This factory that will be used to generate mutations for this object, if any.
* Default factory scans the object for {@link GraphQLMutation} annotated methods and turns
* the methods into mutations.
* @return
*/ | Class<? extends IMutationFactory> mutationFactory() default DefaultQueryAndMutationFactory.class; |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/typemappers/java/util/EnumSetMapper.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
| import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.schema.GraphQLEnumType;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLList;
import graphql.schema.GraphQLOutputType;
import java.lang.reflect.Type;
import java.util.EnumSet; | package com.bretpatterson.schemagen.graphql.typemappers.java.util;
/**
* Default interface type mapper that handles all types of EnumSet.
*/
@GraphQLTypeMapper(type = EnumSet.class)
public class EnumSetMapper implements IGraphQLTypeMapper {
@Override | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/typemappers/java/util/EnumSetMapper.java
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.schema.GraphQLEnumType;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLList;
import graphql.schema.GraphQLOutputType;
import java.lang.reflect.Type;
import java.util.EnumSet;
package com.bretpatterson.schemagen.graphql.typemappers.java.util;
/**
* Default interface type mapper that handles all types of EnumSet.
*/
@GraphQLTypeMapper(type = EnumSet.class)
public class EnumSetMapper implements IGraphQLTypeMapper {
@Override | public boolean handlesType(IGraphQLObjectMapper graphQLObjectMapper, Type type) { |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/impl/DefaultDataFetcherFactory.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/datafetchers/IMethodDataFetcher.java
// public interface IMethodDataFetcher extends IDataFetcher {
//
// /**
// * Called to let the data fetcher know about the Type factory registered for
// * converting GraphQL deserialized data types to your Application method specific data types.
// * {@link ITypeFactory}
// * @param typeFactory
// */
// void setTypeFactory(ITypeFactory typeFactory);
//
// /**
// * The field name that is used to invoke the query.{@link GraphQLQuery#name()}
// *
// * @param fieldName
// */
// void setFieldName(String fieldName);
//
// /**
// * A reference to the method we will be invoking for this data fetcher.
// * @param method
// */
// void setMethod(Method method);
//
// /**
// * The target object the method will be invoked upon.
// * @param targetObject
// */
// void setTargetObject(Object targetObject);
//
// /**
// * Invokes the method on the target object with the specified arguments
// * @param method the method to invoke
// * @param targetObject the target object
// * @param arguments the arguments to the method
// * @return return value
// */
// Object invokeMethod(DataFetchingEnvironment environment, Method method, Object targetObject, Object[] arguments);
// }
| import com.bretpatterson.schemagen.graphql.IDataFetcherFactory;
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.datafetchers.IMethodDataFetcher;
import com.google.common.base.Optional;
import com.google.common.base.Throwables;
import graphql.schema.DataFetcher;
import graphql.schema.PropertyDataFetcher;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.security.InvalidParameterException; | package com.bretpatterson.schemagen.graphql.impl;
/**
* The Default DataFetcher Factory. This only supports custom datafetchers of type IMethodDataFetcher
*/
public class DefaultDataFetcherFactory implements IDataFetcherFactory {
@Override | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/datafetchers/IMethodDataFetcher.java
// public interface IMethodDataFetcher extends IDataFetcher {
//
// /**
// * Called to let the data fetcher know about the Type factory registered for
// * converting GraphQL deserialized data types to your Application method specific data types.
// * {@link ITypeFactory}
// * @param typeFactory
// */
// void setTypeFactory(ITypeFactory typeFactory);
//
// /**
// * The field name that is used to invoke the query.{@link GraphQLQuery#name()}
// *
// * @param fieldName
// */
// void setFieldName(String fieldName);
//
// /**
// * A reference to the method we will be invoking for this data fetcher.
// * @param method
// */
// void setMethod(Method method);
//
// /**
// * The target object the method will be invoked upon.
// * @param targetObject
// */
// void setTargetObject(Object targetObject);
//
// /**
// * Invokes the method on the target object with the specified arguments
// * @param method the method to invoke
// * @param targetObject the target object
// * @param arguments the arguments to the method
// * @return return value
// */
// Object invokeMethod(DataFetchingEnvironment environment, Method method, Object targetObject, Object[] arguments);
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/impl/DefaultDataFetcherFactory.java
import com.bretpatterson.schemagen.graphql.IDataFetcherFactory;
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.datafetchers.IMethodDataFetcher;
import com.google.common.base.Optional;
import com.google.common.base.Throwables;
import graphql.schema.DataFetcher;
import graphql.schema.PropertyDataFetcher;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.security.InvalidParameterException;
package com.bretpatterson.schemagen.graphql.impl;
/**
* The Default DataFetcher Factory. This only supports custom datafetchers of type IMethodDataFetcher
*/
public class DefaultDataFetcherFactory implements IDataFetcherFactory {
@Override | public DataFetcher newFieldDataFetcher(final IGraphQLObjectMapper objectMapper, final Optional<Object> targetObject, final Field field, String fieldName, Class<? extends DataFetcher> dataFetcher) { |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/impl/DefaultDataFetcherFactory.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/datafetchers/IMethodDataFetcher.java
// public interface IMethodDataFetcher extends IDataFetcher {
//
// /**
// * Called to let the data fetcher know about the Type factory registered for
// * converting GraphQL deserialized data types to your Application method specific data types.
// * {@link ITypeFactory}
// * @param typeFactory
// */
// void setTypeFactory(ITypeFactory typeFactory);
//
// /**
// * The field name that is used to invoke the query.{@link GraphQLQuery#name()}
// *
// * @param fieldName
// */
// void setFieldName(String fieldName);
//
// /**
// * A reference to the method we will be invoking for this data fetcher.
// * @param method
// */
// void setMethod(Method method);
//
// /**
// * The target object the method will be invoked upon.
// * @param targetObject
// */
// void setTargetObject(Object targetObject);
//
// /**
// * Invokes the method on the target object with the specified arguments
// * @param method the method to invoke
// * @param targetObject the target object
// * @param arguments the arguments to the method
// * @return return value
// */
// Object invokeMethod(DataFetchingEnvironment environment, Method method, Object targetObject, Object[] arguments);
// }
| import com.bretpatterson.schemagen.graphql.IDataFetcherFactory;
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.datafetchers.IMethodDataFetcher;
import com.google.common.base.Optional;
import com.google.common.base.Throwables;
import graphql.schema.DataFetcher;
import graphql.schema.PropertyDataFetcher;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.security.InvalidParameterException; | package com.bretpatterson.schemagen.graphql.impl;
/**
* The Default DataFetcher Factory. This only supports custom datafetchers of type IMethodDataFetcher
*/
public class DefaultDataFetcherFactory implements IDataFetcherFactory {
@Override
public DataFetcher newFieldDataFetcher(final IGraphQLObjectMapper objectMapper, final Optional<Object> targetObject, final Field field, String fieldName, Class<? extends DataFetcher> dataFetcher) {
if (dataFetcher != null) {
try {
return dataFetcher.newInstance();
} catch (IllegalAccessException | InstantiationException ex) {
throw Throwables.propagate(ex);
}
} else {
return new PropertyDataFetcher(fieldName);
}
}
@Override
public DataFetcher newMethodDataFetcher(final IGraphQLObjectMapper graphQLObjectMapper,
final Optional<Object> targetObject,
final Method method,
final String fieldName,
final Class<? extends DataFetcher> dataFetcher) {
DataFetcher dataFetcherObject;
try {
dataFetcherObject = dataFetcher.newInstance(); | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/datafetchers/IMethodDataFetcher.java
// public interface IMethodDataFetcher extends IDataFetcher {
//
// /**
// * Called to let the data fetcher know about the Type factory registered for
// * converting GraphQL deserialized data types to your Application method specific data types.
// * {@link ITypeFactory}
// * @param typeFactory
// */
// void setTypeFactory(ITypeFactory typeFactory);
//
// /**
// * The field name that is used to invoke the query.{@link GraphQLQuery#name()}
// *
// * @param fieldName
// */
// void setFieldName(String fieldName);
//
// /**
// * A reference to the method we will be invoking for this data fetcher.
// * @param method
// */
// void setMethod(Method method);
//
// /**
// * The target object the method will be invoked upon.
// * @param targetObject
// */
// void setTargetObject(Object targetObject);
//
// /**
// * Invokes the method on the target object with the specified arguments
// * @param method the method to invoke
// * @param targetObject the target object
// * @param arguments the arguments to the method
// * @return return value
// */
// Object invokeMethod(DataFetchingEnvironment environment, Method method, Object targetObject, Object[] arguments);
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/impl/DefaultDataFetcherFactory.java
import com.bretpatterson.schemagen.graphql.IDataFetcherFactory;
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.datafetchers.IMethodDataFetcher;
import com.google.common.base.Optional;
import com.google.common.base.Throwables;
import graphql.schema.DataFetcher;
import graphql.schema.PropertyDataFetcher;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.security.InvalidParameterException;
package com.bretpatterson.schemagen.graphql.impl;
/**
* The Default DataFetcher Factory. This only supports custom datafetchers of type IMethodDataFetcher
*/
public class DefaultDataFetcherFactory implements IDataFetcherFactory {
@Override
public DataFetcher newFieldDataFetcher(final IGraphQLObjectMapper objectMapper, final Optional<Object> targetObject, final Field field, String fieldName, Class<? extends DataFetcher> dataFetcher) {
if (dataFetcher != null) {
try {
return dataFetcher.newInstance();
} catch (IllegalAccessException | InstantiationException ex) {
throw Throwables.propagate(ex);
}
} else {
return new PropertyDataFetcher(fieldName);
}
}
@Override
public DataFetcher newMethodDataFetcher(final IGraphQLObjectMapper graphQLObjectMapper,
final Optional<Object> targetObject,
final Method method,
final String fieldName,
final Class<? extends DataFetcher> dataFetcher) {
DataFetcher dataFetcherObject;
try {
dataFetcherObject = dataFetcher.newInstance(); | if (!IMethodDataFetcher.class.isAssignableFrom(dataFetcher)) { |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/annotations/GraphQLTypeMapper.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/utils/AnnotationUtils.java
// public class AnnotationUtils {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(AnnotationUtils.class);
// public static final String DEFAULT_NULL = "\n\t\t\n\t\t\n\uE000\uE001\uE002\n\t\t\t\t\n";
// private static ClassLoader classLoader;
// private static ClassPath classPath;
//
// public final static class DEFAULT_NULL_CLASS extends DefaultMethodDataFetcher {}
// static {
// try {
// // Change classloader to work with spring boot executable jars
// // http://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html#executable-jar-system-classloader
// classLoader = Thread.currentThread().getContextClassLoader();
// classPath = ClassPath.from(classLoader);
// } catch (IOException ex) {
// Throwables.propagate(ex);
// }
// }
// @SuppressWarnings("unchecked")
// public static <T> T findAnnotation(Annotation[] annotations, Class<T> type) {
// for (Annotation annotation : annotations) {
// if (annotation.annotationType() == type) {
// return (T) annotation;
// }
// }
// return null;
// }
//
// public static <T extends Annotation> Map<Class<?>, T> getClassesWithAnnotation(Class<T> annotation, String packageName) {
// ImmutableMap.Builder<Class<?>, T> results = ImmutableMap.builder();
// try {
// ImmutableSet<ClassPath.ClassInfo> classes = classPath.getTopLevelClassesRecursive(packageName);
// for (ClassPath.ClassInfo info : classes) {
// try {
// Class<?> type = info.load();
// T classAnnotation = type.getAnnotation(annotation);
// if (classAnnotation != null) {
// LOGGER.info("Found {} with annotation {}.", type.getCanonicalName(), annotation.getClass());
// results.put(type, classAnnotation);
// }
// } catch (NoClassDefFoundError ex) {
// LOGGER.warn("Failed to load {}. This is probably because of an unsatisfied runtime dependency.", ex);
// }
// }
// } catch (Exception ex) {
// Throwables.propagate(ex);
// }
//
// return results.build();
// }
//
// public static <T extends Annotation> List<Method> getMethodsWithAnnotation(Class<?> targetClass, Class<T> annotationClass) {
// ImmutableList.Builder<Method> methods = ImmutableList.builder();
//
// for (Method method : targetClass.getDeclaredMethods()) {
// T annotation = method.getAnnotation(annotationClass);
// if (annotation != null) {
// methods.add(method);
// }
// }
//
// return methods.build();
// }
//
// public static <T extends Annotation> List<Field> getFieldsWithAnnotation(Class<?> targetClass, Class<T> annotationClass) {
// ImmutableList.Builder<Field> fields = ImmutableList.builder();
//
// for (Field field : targetClass.getDeclaredFields()) {
// T annotation = field.getAnnotation(annotationClass);
// if (annotation != null) {
// fields.add(field);
// }
// }
//
// return fields.build();
// }
//
// public static boolean isNullValue(String value) {
// return DEFAULT_NULL.equals(value);
// }
//
// public static boolean isNullValue(Class<?> value) {
// return DEFAULT_NULL_CLASS.class.equals(value);
// }
// }
| import com.bretpatterson.schemagen.graphql.utils.AnnotationUtils;
import graphql.schema.DataFetcher;
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.bretpatterson.schemagen.graphql.annotations;
/**
* Annotation to use to configure a default type mapper for a type
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface GraphQLTypeMapper {
/**
* The Class this type mapper knows how to handle.
* @return
*/
Class<?> type();
/**
* Allows you to override the default datafetcher for this data type.
* @return
*/ | // Path: src/main/java/com/bretpatterson/schemagen/graphql/utils/AnnotationUtils.java
// public class AnnotationUtils {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(AnnotationUtils.class);
// public static final String DEFAULT_NULL = "\n\t\t\n\t\t\n\uE000\uE001\uE002\n\t\t\t\t\n";
// private static ClassLoader classLoader;
// private static ClassPath classPath;
//
// public final static class DEFAULT_NULL_CLASS extends DefaultMethodDataFetcher {}
// static {
// try {
// // Change classloader to work with spring boot executable jars
// // http://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html#executable-jar-system-classloader
// classLoader = Thread.currentThread().getContextClassLoader();
// classPath = ClassPath.from(classLoader);
// } catch (IOException ex) {
// Throwables.propagate(ex);
// }
// }
// @SuppressWarnings("unchecked")
// public static <T> T findAnnotation(Annotation[] annotations, Class<T> type) {
// for (Annotation annotation : annotations) {
// if (annotation.annotationType() == type) {
// return (T) annotation;
// }
// }
// return null;
// }
//
// public static <T extends Annotation> Map<Class<?>, T> getClassesWithAnnotation(Class<T> annotation, String packageName) {
// ImmutableMap.Builder<Class<?>, T> results = ImmutableMap.builder();
// try {
// ImmutableSet<ClassPath.ClassInfo> classes = classPath.getTopLevelClassesRecursive(packageName);
// for (ClassPath.ClassInfo info : classes) {
// try {
// Class<?> type = info.load();
// T classAnnotation = type.getAnnotation(annotation);
// if (classAnnotation != null) {
// LOGGER.info("Found {} with annotation {}.", type.getCanonicalName(), annotation.getClass());
// results.put(type, classAnnotation);
// }
// } catch (NoClassDefFoundError ex) {
// LOGGER.warn("Failed to load {}. This is probably because of an unsatisfied runtime dependency.", ex);
// }
// }
// } catch (Exception ex) {
// Throwables.propagate(ex);
// }
//
// return results.build();
// }
//
// public static <T extends Annotation> List<Method> getMethodsWithAnnotation(Class<?> targetClass, Class<T> annotationClass) {
// ImmutableList.Builder<Method> methods = ImmutableList.builder();
//
// for (Method method : targetClass.getDeclaredMethods()) {
// T annotation = method.getAnnotation(annotationClass);
// if (annotation != null) {
// methods.add(method);
// }
// }
//
// return methods.build();
// }
//
// public static <T extends Annotation> List<Field> getFieldsWithAnnotation(Class<?> targetClass, Class<T> annotationClass) {
// ImmutableList.Builder<Field> fields = ImmutableList.builder();
//
// for (Field field : targetClass.getDeclaredFields()) {
// T annotation = field.getAnnotation(annotationClass);
// if (annotation != null) {
// fields.add(field);
// }
// }
//
// return fields.build();
// }
//
// public static boolean isNullValue(String value) {
// return DEFAULT_NULL.equals(value);
// }
//
// public static boolean isNullValue(Class<?> value) {
// return DEFAULT_NULL_CLASS.class.equals(value);
// }
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/annotations/GraphQLTypeMapper.java
import com.bretpatterson.schemagen.graphql.utils.AnnotationUtils;
import graphql.schema.DataFetcher;
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.bretpatterson.schemagen.graphql.annotations;
/**
* Annotation to use to configure a default type mapper for a type
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface GraphQLTypeMapper {
/**
* The Class this type mapper knows how to handle.
* @return
*/
Class<?> type();
/**
* Allows you to override the default datafetcher for this data type.
* @return
*/ | Class<? extends DataFetcher> dataFetcher() default AnnotationUtils.DEFAULT_NULL_CLASS.class; |
bpatters/schemagen-graphql | src/test/java/com/bretpatterson/schemagen/graphql/impl/RelayTypeNamingStrategyTest.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/ITypeNamingStrategy.java
// public interface ITypeNamingStrategy {
//
// /**
// * Get the GraphQL type name for the specified type
// * @param graphQLObjectMapper
// * @param type
// * @return
// */
// String getTypeName(IGraphQLObjectMapper graphQLObjectMapper, Type type);
//
// /**
// * String to append to GraphQL InputType's
// * @return
// */
// String getInputTypePostfix();
//
// /**
// * Delimiter used for separating sections of a type name
// * @return
// */
// String getDelimiter();
// }
| import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.ITypeNamingStrategy;
import com.bretpatterson.schemagen.graphql.relay.RelayConnection;
import com.google.common.reflect.TypeToken;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock; | package com.bretpatterson.schemagen.graphql.impl;
/**
* Created by bpatterson on 2/10/16.
*/
public class RelayTypeNamingStrategyTest {
IGraphQLObjectMapper graphQLObjectMapper = mock(IGraphQLObjectMapper.class);
private class Connection<T> {
@SuppressWarnings("unused")
T field;
}
@SuppressWarnings({ "serial", "unchecked", "rawtypes" })
@Test
public void testRelayNamingTypes() { | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/ITypeNamingStrategy.java
// public interface ITypeNamingStrategy {
//
// /**
// * Get the GraphQL type name for the specified type
// * @param graphQLObjectMapper
// * @param type
// * @return
// */
// String getTypeName(IGraphQLObjectMapper graphQLObjectMapper, Type type);
//
// /**
// * String to append to GraphQL InputType's
// * @return
// */
// String getInputTypePostfix();
//
// /**
// * Delimiter used for separating sections of a type name
// * @return
// */
// String getDelimiter();
// }
// Path: src/test/java/com/bretpatterson/schemagen/graphql/impl/RelayTypeNamingStrategyTest.java
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.ITypeNamingStrategy;
import com.bretpatterson.schemagen.graphql.relay.RelayConnection;
import com.google.common.reflect.TypeToken;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
package com.bretpatterson.schemagen.graphql.impl;
/**
* Created by bpatterson on 2/10/16.
*/
public class RelayTypeNamingStrategyTest {
IGraphQLObjectMapper graphQLObjectMapper = mock(IGraphQLObjectMapper.class);
private class Connection<T> {
@SuppressWarnings("unused")
T field;
}
@SuppressWarnings({ "serial", "unchecked", "rawtypes" })
@Test
public void testRelayNamingTypes() { | ITypeNamingStrategy strategy = new RelayTypeNamingStrategy(); |
bpatters/schemagen-graphql | src/test/java/com/bretpatterson/schemagen/graphql/impl/SimpleTypeNamingStrategyTest.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/ITypeNamingStrategy.java
// public interface ITypeNamingStrategy {
//
// /**
// * Get the GraphQL type name for the specified type
// * @param graphQLObjectMapper
// * @param type
// * @return
// */
// String getTypeName(IGraphQLObjectMapper graphQLObjectMapper, Type type);
//
// /**
// * String to append to GraphQL InputType's
// * @return
// */
// String getInputTypePostfix();
//
// /**
// * Delimiter used for separating sections of a type name
// * @return
// */
// String getDelimiter();
// }
| import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.ITypeNamingStrategy;
import com.bretpatterson.schemagen.graphql.relay.RelayConnection;
import com.google.common.reflect.TypeToken;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock; | package com.bretpatterson.schemagen.graphql.impl;
/**
* Created by bpatterson on 2/10/16.
*/
public class SimpleTypeNamingStrategyTest {
IGraphQLObjectMapper graphQLObjectMapper = mock(IGraphQLObjectMapper.class);
private class Connection<T> {
@SuppressWarnings("unused")
T field;
}
@SuppressWarnings({ "unchecked", "serial", "rawtypes" })
@Test
public void TestSimpleType() { | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
//
// Path: src/main/java/com/bretpatterson/schemagen/graphql/ITypeNamingStrategy.java
// public interface ITypeNamingStrategy {
//
// /**
// * Get the GraphQL type name for the specified type
// * @param graphQLObjectMapper
// * @param type
// * @return
// */
// String getTypeName(IGraphQLObjectMapper graphQLObjectMapper, Type type);
//
// /**
// * String to append to GraphQL InputType's
// * @return
// */
// String getInputTypePostfix();
//
// /**
// * Delimiter used for separating sections of a type name
// * @return
// */
// String getDelimiter();
// }
// Path: src/test/java/com/bretpatterson/schemagen/graphql/impl/SimpleTypeNamingStrategyTest.java
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.ITypeNamingStrategy;
import com.bretpatterson.schemagen.graphql.relay.RelayConnection;
import com.google.common.reflect.TypeToken;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
package com.bretpatterson.schemagen.graphql.impl;
/**
* Created by bpatterson on 2/10/16.
*/
public class SimpleTypeNamingStrategyTest {
IGraphQLObjectMapper graphQLObjectMapper = mock(IGraphQLObjectMapper.class);
private class Connection<T> {
@SuppressWarnings("unused")
T field;
}
@SuppressWarnings({ "unchecked", "serial", "rawtypes" })
@Test
public void TestSimpleType() { | ITypeNamingStrategy strategy = new SimpleTypeNamingStrategy(); |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/typemappers/relay/ConnectionCursorMapper.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
| import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.relay.ConnectionCursor;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.Scalars;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLOutputType;
import java.lang.reflect.Type; | package com.bretpatterson.schemagen.graphql.typemappers.relay;
/**
* Specification Compliant ConnectionCursor mapper
*
* @see <a href="https://facebook.github.io/relay/graphql/connections.htm">Connection Specification</a>
*/
@GraphQLTypeMapper(type = ConnectionCursor.class)
public class ConnectionCursorMapper implements IGraphQLTypeMapper {
@Override | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/typemappers/relay/ConnectionCursorMapper.java
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.relay.ConnectionCursor;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.Scalars;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLOutputType;
import java.lang.reflect.Type;
package com.bretpatterson.schemagen.graphql.typemappers.relay;
/**
* Specification Compliant ConnectionCursor mapper
*
* @see <a href="https://facebook.github.io/relay/graphql/connections.htm">Connection Specification</a>
*/
@GraphQLTypeMapper(type = ConnectionCursor.class)
public class ConnectionCursorMapper implements IGraphQLTypeMapper {
@Override | public boolean handlesType(IGraphQLObjectMapper graphQLObjectMapper, Type type) { |
bpatters/schemagen-graphql | src/test/java/com/bretpatterson/schemagen/graphql/GraphQLSchemaBuilderTest.java | // Path: src/test/java/com/bretpatterson/schemagen/graphql/impl/common/JacksonTypeFactory.java
// public class JacksonTypeFactory implements ITypeFactory {
// ObjectMapper objectMapper;
//
// public JacksonTypeFactory(ObjectMapper objectMapper) {
// this.objectMapper = objectMapper;
// }
//
// @Override
// public Object convertToType(Type type, Object arg) {
// try {
// return objectMapper.readValue(objectMapper.writeValueAsString(arg), TypeFactory.defaultInstance().constructType(type));
// } catch(IOException ex) {
// return Throwables.propagate(ex);
// }
//
// }
// }
| import com.bretpatterson.schemagen.graphql.annotations.GraphQLController;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLDescription;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLMutation;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLParam;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLQuery;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeConverter;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLName;
import com.bretpatterson.schemagen.graphql.datafetchers.DefaultTypeConverter;
import com.bretpatterson.schemagen.graphql.impl.common.JacksonTypeFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import graphql.ExecutionResult;
import graphql.GraphQL;
import graphql.Scalars;
import graphql.schema.DataFetcher;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLInputObjectType;
import graphql.schema.GraphQLObjectType;
import graphql.schema.GraphQLSchema;
import org.junit.Test;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; | public String getName() {
return name;
}
}
@Test
public void testController() {
GraphQLSchema schema = GraphQLSchemaBuilder.newBuilder().registerGraphQLControllerObjects(ImmutableList.<Object> of(new TestController())).build();
GraphQLFieldDefinition queryType = schema.getQueryType().getFieldDefinition("testType");
assertEquals("testType", queryType.getName());
assertEquals("TestType", queryType.getType().getName());
}
@Test
public void testQueryArguments() {
GraphQLSchema schema = GraphQLSchemaBuilder.newBuilder().registerGraphQLControllerObjects(ImmutableList.<Object> of(new TestController())).build();
GraphQLFieldDefinition queryType = schema.getQueryType().getFieldDefinition("testQueryArguments");
assertEquals("testQueryArguments", queryType.getName());
assertEquals(Scalars.GraphQLString, queryType.getArgument("string").getType());
assertEquals(Scalars.GraphQLInt, queryType.getArgument("int").getType());
assertEquals(GraphQLInputObjectType.class, queryType.getArgument("test").getType().getClass());
assertEquals("RenamedTestInputType_Input", queryType.getArgument("test").getType().getName());
}
@SuppressWarnings("unchecked")
@Test
public void testMutation() {
GraphQLSchema schema = GraphQLSchemaBuilder.newBuilder() | // Path: src/test/java/com/bretpatterson/schemagen/graphql/impl/common/JacksonTypeFactory.java
// public class JacksonTypeFactory implements ITypeFactory {
// ObjectMapper objectMapper;
//
// public JacksonTypeFactory(ObjectMapper objectMapper) {
// this.objectMapper = objectMapper;
// }
//
// @Override
// public Object convertToType(Type type, Object arg) {
// try {
// return objectMapper.readValue(objectMapper.writeValueAsString(arg), TypeFactory.defaultInstance().constructType(type));
// } catch(IOException ex) {
// return Throwables.propagate(ex);
// }
//
// }
// }
// Path: src/test/java/com/bretpatterson/schemagen/graphql/GraphQLSchemaBuilderTest.java
import com.bretpatterson.schemagen.graphql.annotations.GraphQLController;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLDescription;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLMutation;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLParam;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLQuery;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeConverter;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLName;
import com.bretpatterson.schemagen.graphql.datafetchers.DefaultTypeConverter;
import com.bretpatterson.schemagen.graphql.impl.common.JacksonTypeFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import graphql.ExecutionResult;
import graphql.GraphQL;
import graphql.Scalars;
import graphql.schema.DataFetcher;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLInputObjectType;
import graphql.schema.GraphQLObjectType;
import graphql.schema.GraphQLSchema;
import org.junit.Test;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public String getName() {
return name;
}
}
@Test
public void testController() {
GraphQLSchema schema = GraphQLSchemaBuilder.newBuilder().registerGraphQLControllerObjects(ImmutableList.<Object> of(new TestController())).build();
GraphQLFieldDefinition queryType = schema.getQueryType().getFieldDefinition("testType");
assertEquals("testType", queryType.getName());
assertEquals("TestType", queryType.getType().getName());
}
@Test
public void testQueryArguments() {
GraphQLSchema schema = GraphQLSchemaBuilder.newBuilder().registerGraphQLControllerObjects(ImmutableList.<Object> of(new TestController())).build();
GraphQLFieldDefinition queryType = schema.getQueryType().getFieldDefinition("testQueryArguments");
assertEquals("testQueryArguments", queryType.getName());
assertEquals(Scalars.GraphQLString, queryType.getArgument("string").getType());
assertEquals(Scalars.GraphQLInt, queryType.getArgument("int").getType());
assertEquals(GraphQLInputObjectType.class, queryType.getArgument("test").getType().getClass());
assertEquals("RenamedTestInputType_Input", queryType.getArgument("test").getType().getName());
}
@SuppressWarnings("unchecked")
@Test
public void testMutation() {
GraphQLSchema schema = GraphQLSchemaBuilder.newBuilder() | .registerTypeFactory(new JacksonTypeFactory(new ObjectMapper())) |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/datafetchers/DefaultMethodDataFetcher.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/ITypeFactory.java
// public interface ITypeFactory {
// /**
// * This object needs to know how to convert objects to the specified type. This is used
// * to convert query Parameters to the correct type before method invocation.
// * Object type of the arg can be any object type within java we exposed through GraphQL as a parameter.
// * IE everyone of your query/mutation parameter objects must be handled by this object.
// * Jackson object mapper is a simple way of doing this. IE:
// * <pre>
// * {@code
// * {@liter @Override}
// * public Object convertToType(Type type, Object arg) {
// * try {
// * return objectMapper.readValue(objectMapper.writeValueAsString(arg), TypeFactory.defaultInstance().constructType(type));
// * } catch(IOException ex) {
// * return Throwables.propagate(ex);
// * }
// *
// * }
// * }</pre>
// *
// * @param type The type to convert the object to. This is a ParameterizedType if the original value is so you can recursively determine
// * what value you should convert to. IE: {@code List<List<Object>>}
// * @param arg The GraphQL version of the argument value IE: Primitive, Object, List of ...
// * @return
// */
// Object convertToType(Type type, Object arg);
// }
| import com.bretpatterson.schemagen.graphql.ITypeFactory;
import com.google.common.base.Optional;
import com.google.common.base.Throwables;
import com.google.common.collect.Maps;
import graphql.language.Field;
import graphql.schema.DataFetchingEnvironment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.LinkedHashMap;
import java.util.Map; | package com.bretpatterson.schemagen.graphql.datafetchers;
/**
* Implementation of a IMethodDataFetcher that will invoke a method call with the provided GraphQL arguments. If null and a default value is
* provided for the argument then the default value will be used, otherwise null will be sent to the method. Parameter objects are converted
* from <i>GraphQL</i> Deserialized types to the arguments declared type using the regisered {@link ITypeFactory}.
*/
public class DefaultMethodDataFetcher implements IMethodDataFetcher {
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultMethodDataFetcher.class); | // Path: src/main/java/com/bretpatterson/schemagen/graphql/ITypeFactory.java
// public interface ITypeFactory {
// /**
// * This object needs to know how to convert objects to the specified type. This is used
// * to convert query Parameters to the correct type before method invocation.
// * Object type of the arg can be any object type within java we exposed through GraphQL as a parameter.
// * IE everyone of your query/mutation parameter objects must be handled by this object.
// * Jackson object mapper is a simple way of doing this. IE:
// * <pre>
// * {@code
// * {@liter @Override}
// * public Object convertToType(Type type, Object arg) {
// * try {
// * return objectMapper.readValue(objectMapper.writeValueAsString(arg), TypeFactory.defaultInstance().constructType(type));
// * } catch(IOException ex) {
// * return Throwables.propagate(ex);
// * }
// *
// * }
// * }</pre>
// *
// * @param type The type to convert the object to. This is a ParameterizedType if the original value is so you can recursively determine
// * what value you should convert to. IE: {@code List<List<Object>>}
// * @param arg The GraphQL version of the argument value IE: Primitive, Object, List of ...
// * @return
// */
// Object convertToType(Type type, Object arg);
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/datafetchers/DefaultMethodDataFetcher.java
import com.bretpatterson.schemagen.graphql.ITypeFactory;
import com.google.common.base.Optional;
import com.google.common.base.Throwables;
import com.google.common.collect.Maps;
import graphql.language.Field;
import graphql.schema.DataFetchingEnvironment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.LinkedHashMap;
import java.util.Map;
package com.bretpatterson.schemagen.graphql.datafetchers;
/**
* Implementation of a IMethodDataFetcher that will invoke a method call with the provided GraphQL arguments. If null and a default value is
* provided for the argument then the default value will be used, otherwise null will be sent to the method. Parameter objects are converted
* from <i>GraphQL</i> Deserialized types to the arguments declared type using the regisered {@link ITypeFactory}.
*/
public class DefaultMethodDataFetcher implements IMethodDataFetcher {
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultMethodDataFetcher.class); | protected ITypeFactory typeFactory; |
bpatters/schemagen-graphql | schemagen-graphql-joda/src/main/java/com/bretpatterson/schemagen/graphql/typemappers/org/joda/money/MoneyMapper.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
| import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.Scalars;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLOutputType;
import org.joda.money.Money;
import java.lang.reflect.Type; | package com.bretpatterson.schemagen.graphql.typemappers.org.joda.money;
/**
* Created by bpatterson on 1/19/16.
*/
@GraphQLTypeMapper(type=Money.class)
public class MoneyMapper implements IGraphQLTypeMapper {
@Override | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
// Path: schemagen-graphql-joda/src/main/java/com/bretpatterson/schemagen/graphql/typemappers/org/joda/money/MoneyMapper.java
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.Scalars;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLOutputType;
import org.joda.money.Money;
import java.lang.reflect.Type;
package com.bretpatterson.schemagen.graphql.typemappers.org.joda.money;
/**
* Created by bpatterson on 1/19/16.
*/
@GraphQLTypeMapper(type=Money.class)
public class MoneyMapper implements IGraphQLTypeMapper {
@Override | public boolean handlesType(IGraphQLObjectMapper graphQLObjectMapper, Type type) { |
bpatters/schemagen-graphql | src/test/java/com/bretpatterson/schemagen/graphql/typemappers/relay/ConnectionCursorMapperTest.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
| import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.relay.ConnectionCursor;
import graphql.Scalars;
import graphql.schema.GraphQLNonNull;
import graphql.schema.GraphQLOutputType;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import java.lang.reflect.Type;
import static org.junit.Assert.*;
import static org.mockito.BDDMockito.*; | package com.bretpatterson.schemagen.graphql.typemappers.relay;
@RunWith(MockitoJUnitRunner.class)
public class ConnectionCursorMapperTest {
@Mock | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
// Path: src/test/java/com/bretpatterson/schemagen/graphql/typemappers/relay/ConnectionCursorMapperTest.java
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.relay.ConnectionCursor;
import graphql.Scalars;
import graphql.schema.GraphQLNonNull;
import graphql.schema.GraphQLOutputType;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import java.lang.reflect.Type;
import static org.junit.Assert.*;
import static org.mockito.BDDMockito.*;
package com.bretpatterson.schemagen.graphql.typemappers.relay;
@RunWith(MockitoJUnitRunner.class)
public class ConnectionCursorMapperTest {
@Mock | private IGraphQLObjectMapper mockMapper; |
bpatters/schemagen-graphql | src/test/java/com/bretpatterson/schemagen/graphql/relay/dao/GameDAO.java | // Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/model/IGame.java
// public interface IGame {
//
// Long getId();
//
// IGame setId(Long id);
//
// String getName();
//
// IGame setName(String name);
//
// List<IUser> getUsers();
//
// IGame setUsers(List<IUser> users);
// }
//
// Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/model/IUser.java
// public interface IUser {
//
// Long getId();
//
// IUser setId(Long id);
//
// String getName();
//
// IUser setName(String name);
//
// String getEmail();
//
// IUser setEmail(String email);
// }
//
// Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/model/PagedList.java
// public class PagedList<T> {
//
// private List<T> items;
// private boolean hasPreviousPage;
// private boolean hasNextPage;
//
// private PagedList(List<T> items, boolean hasPreviousPage, boolean hasNextPage) {
// this.items = items;
// this.setHasPreviousPage(hasPreviousPage);
// this.setHasNextPage(hasNextPage);
// }
//
// public static <T> PagedList<T> of(List<T> items, boolean hasPreviousPage, boolean hasNextPage) {
// return new PagedList<T>(items, hasPreviousPage, hasNextPage);
// }
//
// public List<T> getItems() {
// return items;
// }
//
// public void setItems(List<T> items) {
// this.items = items;
// }
//
// public boolean isHasPreviousPage() {
// return hasPreviousPage;
// }
//
// public void setHasPreviousPage(boolean hasPreviousPage) {
// this.hasPreviousPage = hasPreviousPage;
// }
//
// public boolean isHasNextPage() {
// return hasNextPage;
// }
//
// public void setHasNextPage(boolean hasNextPage) {
// this.hasNextPage = hasNextPage;
// }
// }
| import com.bretpatterson.schemagen.graphql.relay.model.IGame;
import com.bretpatterson.schemagen.graphql.relay.model.IUser;
import com.bretpatterson.schemagen.graphql.relay.model.PagedList;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import java.util.Iterator;
import java.util.List;
import static com.google.common.base.Preconditions.checkArgument; | package com.bretpatterson.schemagen.graphql.relay.dao;
/**
* Simple in memory story for all game objects
*/
public class GameDAO {
private List<IGame> games = Lists.newArrayList(); | // Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/model/IGame.java
// public interface IGame {
//
// Long getId();
//
// IGame setId(Long id);
//
// String getName();
//
// IGame setName(String name);
//
// List<IUser> getUsers();
//
// IGame setUsers(List<IUser> users);
// }
//
// Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/model/IUser.java
// public interface IUser {
//
// Long getId();
//
// IUser setId(Long id);
//
// String getName();
//
// IUser setName(String name);
//
// String getEmail();
//
// IUser setEmail(String email);
// }
//
// Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/model/PagedList.java
// public class PagedList<T> {
//
// private List<T> items;
// private boolean hasPreviousPage;
// private boolean hasNextPage;
//
// private PagedList(List<T> items, boolean hasPreviousPage, boolean hasNextPage) {
// this.items = items;
// this.setHasPreviousPage(hasPreviousPage);
// this.setHasNextPage(hasNextPage);
// }
//
// public static <T> PagedList<T> of(List<T> items, boolean hasPreviousPage, boolean hasNextPage) {
// return new PagedList<T>(items, hasPreviousPage, hasNextPage);
// }
//
// public List<T> getItems() {
// return items;
// }
//
// public void setItems(List<T> items) {
// this.items = items;
// }
//
// public boolean isHasPreviousPage() {
// return hasPreviousPage;
// }
//
// public void setHasPreviousPage(boolean hasPreviousPage) {
// this.hasPreviousPage = hasPreviousPage;
// }
//
// public boolean isHasNextPage() {
// return hasNextPage;
// }
//
// public void setHasNextPage(boolean hasNextPage) {
// this.hasNextPage = hasNextPage;
// }
// }
// Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/dao/GameDAO.java
import com.bretpatterson.schemagen.graphql.relay.model.IGame;
import com.bretpatterson.schemagen.graphql.relay.model.IUser;
import com.bretpatterson.schemagen.graphql.relay.model.PagedList;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import java.util.Iterator;
import java.util.List;
import static com.google.common.base.Preconditions.checkArgument;
package com.bretpatterson.schemagen.graphql.relay.dao;
/**
* Simple in memory story for all game objects
*/
public class GameDAO {
private List<IGame> games = Lists.newArrayList(); | private List<IUser> users = Lists.newArrayList(); |
bpatters/schemagen-graphql | src/test/java/com/bretpatterson/schemagen/graphql/relay/dao/GameDAO.java | // Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/model/IGame.java
// public interface IGame {
//
// Long getId();
//
// IGame setId(Long id);
//
// String getName();
//
// IGame setName(String name);
//
// List<IUser> getUsers();
//
// IGame setUsers(List<IUser> users);
// }
//
// Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/model/IUser.java
// public interface IUser {
//
// Long getId();
//
// IUser setId(Long id);
//
// String getName();
//
// IUser setName(String name);
//
// String getEmail();
//
// IUser setEmail(String email);
// }
//
// Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/model/PagedList.java
// public class PagedList<T> {
//
// private List<T> items;
// private boolean hasPreviousPage;
// private boolean hasNextPage;
//
// private PagedList(List<T> items, boolean hasPreviousPage, boolean hasNextPage) {
// this.items = items;
// this.setHasPreviousPage(hasPreviousPage);
// this.setHasNextPage(hasNextPage);
// }
//
// public static <T> PagedList<T> of(List<T> items, boolean hasPreviousPage, boolean hasNextPage) {
// return new PagedList<T>(items, hasPreviousPage, hasNextPage);
// }
//
// public List<T> getItems() {
// return items;
// }
//
// public void setItems(List<T> items) {
// this.items = items;
// }
//
// public boolean isHasPreviousPage() {
// return hasPreviousPage;
// }
//
// public void setHasPreviousPage(boolean hasPreviousPage) {
// this.hasPreviousPage = hasPreviousPage;
// }
//
// public boolean isHasNextPage() {
// return hasNextPage;
// }
//
// public void setHasNextPage(boolean hasNextPage) {
// this.hasNextPage = hasNextPage;
// }
// }
| import com.bretpatterson.schemagen.graphql.relay.model.IGame;
import com.bretpatterson.schemagen.graphql.relay.model.IUser;
import com.bretpatterson.schemagen.graphql.relay.model.PagedList;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import java.util.Iterator;
import java.util.List;
import static com.google.common.base.Preconditions.checkArgument; | package com.bretpatterson.schemagen.graphql.relay.dao;
/**
* Simple in memory story for all game objects
*/
public class GameDAO {
private List<IGame> games = Lists.newArrayList();
private List<IUser> users = Lists.newArrayList();
private long lastGameId = 0;
private long lastUserId = 0;
| // Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/model/IGame.java
// public interface IGame {
//
// Long getId();
//
// IGame setId(Long id);
//
// String getName();
//
// IGame setName(String name);
//
// List<IUser> getUsers();
//
// IGame setUsers(List<IUser> users);
// }
//
// Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/model/IUser.java
// public interface IUser {
//
// Long getId();
//
// IUser setId(Long id);
//
// String getName();
//
// IUser setName(String name);
//
// String getEmail();
//
// IUser setEmail(String email);
// }
//
// Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/model/PagedList.java
// public class PagedList<T> {
//
// private List<T> items;
// private boolean hasPreviousPage;
// private boolean hasNextPage;
//
// private PagedList(List<T> items, boolean hasPreviousPage, boolean hasNextPage) {
// this.items = items;
// this.setHasPreviousPage(hasPreviousPage);
// this.setHasNextPage(hasNextPage);
// }
//
// public static <T> PagedList<T> of(List<T> items, boolean hasPreviousPage, boolean hasNextPage) {
// return new PagedList<T>(items, hasPreviousPage, hasNextPage);
// }
//
// public List<T> getItems() {
// return items;
// }
//
// public void setItems(List<T> items) {
// this.items = items;
// }
//
// public boolean isHasPreviousPage() {
// return hasPreviousPage;
// }
//
// public void setHasPreviousPage(boolean hasPreviousPage) {
// this.hasPreviousPage = hasPreviousPage;
// }
//
// public boolean isHasNextPage() {
// return hasNextPage;
// }
//
// public void setHasNextPage(boolean hasNextPage) {
// this.hasNextPage = hasNextPage;
// }
// }
// Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/dao/GameDAO.java
import com.bretpatterson.schemagen.graphql.relay.model.IGame;
import com.bretpatterson.schemagen.graphql.relay.model.IUser;
import com.bretpatterson.schemagen.graphql.relay.model.PagedList;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import java.util.Iterator;
import java.util.List;
import static com.google.common.base.Preconditions.checkArgument;
package com.bretpatterson.schemagen.graphql.relay.dao;
/**
* Simple in memory story for all game objects
*/
public class GameDAO {
private List<IGame> games = Lists.newArrayList();
private List<IUser> users = Lists.newArrayList();
private long lastGameId = 0;
private long lastUserId = 0;
| public PagedList<IGame> findGames(Optional<Integer> first, Optional<Integer> last, Optional<Long> before, Optional<Long> after) { |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/typemappers/java/net/URIMapper.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
| import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.Scalars;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLOutputType;
import java.lang.reflect.Type;
import java.net.URI; | package com.bretpatterson.schemagen.graphql.typemappers.java.net;
/**
* Default URI mapper that converts a URI to a GraphQLString
*/
@GraphQLTypeMapper(type=URI.class)
public class URIMapper implements IGraphQLTypeMapper {
@Override | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/typemappers/java/net/URIMapper.java
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.Scalars;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLOutputType;
import java.lang.reflect.Type;
import java.net.URI;
package com.bretpatterson.schemagen.graphql.typemappers.java.net;
/**
* Default URI mapper that converts a URI to a GraphQLString
*/
@GraphQLTypeMapper(type=URI.class)
public class URIMapper implements IGraphQLTypeMapper {
@Override | public boolean handlesType(IGraphQLObjectMapper graphQLObjectMapper, Type type) { |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/impl/RelayTypeNamingStrategy.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
| import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLName;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type; | package com.bretpatterson.schemagen.graphql.impl;
/**
* Created by bpatterson on 2/10/16.
*/
public class RelayTypeNamingStrategy extends SimpleTypeNamingStrategy {
public RelayTypeNamingStrategy(String delimiter, String inputTypePostfix) {
super(delimiter, inputTypePostfix);
}
public RelayTypeNamingStrategy() {
}
@Override | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/impl/RelayTypeNamingStrategy.java
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLName;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
package com.bretpatterson.schemagen.graphql.impl;
/**
* Created by bpatterson on 2/10/16.
*/
public class RelayTypeNamingStrategy extends SimpleTypeNamingStrategy {
public RelayTypeNamingStrategy(String delimiter, String inputTypePostfix) {
super(delimiter, inputTypePostfix);
}
public RelayTypeNamingStrategy() {
}
@Override | public String getTypeName(IGraphQLObjectMapper graphQLObjectMapper, Type type) { |
bpatters/schemagen-graphql | src/main/java/com/bretpatterson/schemagen/graphql/typemappers/java/util/DateMapper.java | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
| import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.Scalars;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLInputObjectField;
import graphql.schema.GraphQLInputObjectType;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLObjectType;
import graphql.schema.GraphQLOutputType;
import java.lang.reflect.Type;
import java.util.Date; | package com.bretpatterson.schemagen.graphql.typemappers.java.util;
/**
* Default Date Mapper that converts a Date to a GraphQL Long
*/
@GraphQLTypeMapper(type= Date.class)
public class DateMapper implements IGraphQLTypeMapper {
@Override | // Path: src/main/java/com/bretpatterson/schemagen/graphql/IGraphQLObjectMapper.java
// public interface IGraphQLObjectMapper {
//
// /**
// * Get the object responsible for naming GraphQL types.
// * @return
// */
// ITypeNamingStrategy getTypeNamingStrategy();
//
// /**
// * Get an input definition for the specified type.
// * @param type
// */
// GraphQLInputType getInputType(Type type);
//
// /**
// * Get an output definition for the specified type.
// * @param type
// */
// GraphQLOutputType getOutputType(Type type);
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLInputType> getInputTypeCache();
//
// /**
// * Get the Input Type cache. This is useful for custom type mappers who
// * might need to add TypeReference's to the cache when they need to process
// * an object that contains a two way dependency between itself and another object.
// */
// IGraphQLTypeCache<GraphQLOutputType> getOutputTypeCache();
//
// /**
// * Returns the object responsible for object type conversion.
// * @return
// */
// ITypeFactory getTypeFactory();
//
// /**
// * Get the raw type of this object for generic types
// * @param type
// * @return
// */
// Class<?> getClassFromType(Type type);
//
// /**
// * Returns all input types created.
// * @return
// */
// Set<GraphQLType> getInputTypes();
//
// /**
// * Get the datafetcher factory
// * @return
// */
// IDataFetcherFactory getDataFetcherFactory() ;
//
// /**
// *
// * @param dataFetcherFactory
// */
// void setDataFetcherFactory(IDataFetcherFactory dataFetcherFactory);
//
// /**
// * Get the default datafetcher for methods
// * @return
// */
// Class<? extends IDataFetcher> getDefaultMethodDataFetcher();
//
// /**
// * Set the default data fetcher used for methods
// * @param defaultMethodDataFetcher
// */
// void setDefaultMethodDataFetcher(Class<? extends IDataFetcher> defaultMethodDataFetcher);
//
// Collection<GraphQLFieldDefinition> getGraphQLFieldDefinitions(Optional<Object> targetObject, Type type, Class<?> classItem, Optional<List<Field>> fields, Optional<List<Method>> methods);
// }
// Path: src/main/java/com/bretpatterson/schemagen/graphql/typemappers/java/util/DateMapper.java
import com.bretpatterson.schemagen.graphql.IGraphQLObjectMapper;
import com.bretpatterson.schemagen.graphql.annotations.GraphQLTypeMapper;
import com.bretpatterson.schemagen.graphql.typemappers.IGraphQLTypeMapper;
import graphql.Scalars;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLInputObjectField;
import graphql.schema.GraphQLInputObjectType;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLObjectType;
import graphql.schema.GraphQLOutputType;
import java.lang.reflect.Type;
import java.util.Date;
package com.bretpatterson.schemagen.graphql.typemappers.java.util;
/**
* Default Date Mapper that converts a Date to a GraphQL Long
*/
@GraphQLTypeMapper(type= Date.class)
public class DateMapper implements IGraphQLTypeMapper {
@Override | public boolean handlesType(IGraphQLObjectMapper graphQLObjectMapper, Type type) { |
bpatters/schemagen-graphql | src/test/java/com/bretpatterson/schemagen/graphql/relay/model/relay/factories/RelayUserFactory.java | // Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/controller/UserDTO.java
// @GraphQLName(name="User")
// public class UserDTO implements INode {
// private String id;
// private String name;
// private String email;
//
//
// @Override
// public String getId() {
// return id;
// }
//
// public UserDTO setId(String id) {
// this.id = id;
//
// return this;
// }
//
// public String getName() {
// return name;
// }
//
// public UserDTO setName(String name) {
// this.name = name;
//
// return this;
// }
//
// public String getEmail() {
// return email;
// }
//
// public UserDTO setEmail(String email) {
// this.email = email;
//
// return this;
// }
// }
//
// Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/model/impl/User.java
// public class User implements IUser {
// private Long id;
// private String name;
// private String email;
//
// @Override
// public Long getId() {
// return id;
// }
//
// @Override
// public IUser setId(Long id) {
// this.id = id;
//
// return this;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public IUser setName(String name) {
// this.name = name;
//
// return this;
// }
//
// @Override
// public String getEmail() {
// return email;
// }
//
// @Override
// public IUser setEmail(String email) {
// this.email = email;
//
// return this;
// }
// }
| import com.bretpatterson.schemagen.graphql.relay.IRelayNodeFactory;
import com.bretpatterson.schemagen.graphql.relay.annotations.RelayNodeFactory;
import com.bretpatterson.schemagen.graphql.relay.controller.GameController;
import com.bretpatterson.schemagen.graphql.relay.controller.UserDTO;
import com.bretpatterson.schemagen.graphql.relay.model.impl.User; | package com.bretpatterson.schemagen.graphql.relay.model.relay.factories;
/**
* Factory that knows how to turn node ids into User objects
*/
@RelayNodeFactory(types = { User.class })
public class RelayUserFactory implements IRelayNodeFactory {
private static final String NODE_PREFIX = "user:";
GameController gameController;
public RelayUserFactory(GameController gameController) {
this.gameController = gameController;
}
@Override | // Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/controller/UserDTO.java
// @GraphQLName(name="User")
// public class UserDTO implements INode {
// private String id;
// private String name;
// private String email;
//
//
// @Override
// public String getId() {
// return id;
// }
//
// public UserDTO setId(String id) {
// this.id = id;
//
// return this;
// }
//
// public String getName() {
// return name;
// }
//
// public UserDTO setName(String name) {
// this.name = name;
//
// return this;
// }
//
// public String getEmail() {
// return email;
// }
//
// public UserDTO setEmail(String email) {
// this.email = email;
//
// return this;
// }
// }
//
// Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/model/impl/User.java
// public class User implements IUser {
// private Long id;
// private String name;
// private String email;
//
// @Override
// public Long getId() {
// return id;
// }
//
// @Override
// public IUser setId(Long id) {
// this.id = id;
//
// return this;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public IUser setName(String name) {
// this.name = name;
//
// return this;
// }
//
// @Override
// public String getEmail() {
// return email;
// }
//
// @Override
// public IUser setEmail(String email) {
// this.email = email;
//
// return this;
// }
// }
// Path: src/test/java/com/bretpatterson/schemagen/graphql/relay/model/relay/factories/RelayUserFactory.java
import com.bretpatterson.schemagen.graphql.relay.IRelayNodeFactory;
import com.bretpatterson.schemagen.graphql.relay.annotations.RelayNodeFactory;
import com.bretpatterson.schemagen.graphql.relay.controller.GameController;
import com.bretpatterson.schemagen.graphql.relay.controller.UserDTO;
import com.bretpatterson.schemagen.graphql.relay.model.impl.User;
package com.bretpatterson.schemagen.graphql.relay.model.relay.factories;
/**
* Factory that knows how to turn node ids into User objects
*/
@RelayNodeFactory(types = { User.class })
public class RelayUserFactory implements IRelayNodeFactory {
private static final String NODE_PREFIX = "user:";
GameController gameController;
public RelayUserFactory(GameController gameController) {
this.gameController = gameController;
}
@Override | public UserDTO newObjectFromID(String objectId) { |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/UIPreferenceFragment.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui;
public abstract class UIPreferenceFragment extends PreferenceFragment implements IFragment, UIInterface {
private Core mCore;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
| // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/UIPreferenceFragment.java
import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui;
public abstract class UIPreferenceFragment extends PreferenceFragment implements IFragment, UIInterface {
private Core mCore;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
| mCore = CoreFactory.getCore(); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/UIPreferenceFragment.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui;
public abstract class UIPreferenceFragment extends PreferenceFragment implements IFragment, UIInterface {
private Core mCore;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mCore = CoreFactory.getCore();
| // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/UIPreferenceFragment.java
import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui;
public abstract class UIPreferenceFragment extends PreferenceFragment implements IFragment, UIInterface {
private Core mCore;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mCore = CoreFactory.getCore();
| ((UIPlugin) mCore.getPlugin(Core.PLUGIN_UI)).registerUI(this); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UIPreferenceCategory.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.view.View;
import android.widget.TextView;
import com.beerbong.zipinst.R;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.preference.PreferenceCategory;
import android.util.AttributeSet;
import android.util.TypedValue; |
public UIPreferenceCategory(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIPreferenceCategory(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
Context context = getContext();
Resources res = context.getResources();
if (mTextColor == 0) {
TypedValue typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(R.attr.fragmentTitleColor, typedValue, true);
mTextColor = typedValue.resourceId;
typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(android.R.attr.textAppearanceMedium, typedValue, true);
mAppearanceMedium = typedValue.resourceId;
}
TextView titleView = (TextView) view.findViewById(android.R.id.title);
if (titleView != null) {
titleView.setTextAppearance(context, mAppearanceMedium);
titleView.setTextColor(res.getColor(mTextColor));
float size = res.getDimension(R.dimen.fragment_title_size);
titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
//titleView.setBackgroundColor(mTextColor);
} | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UIPreferenceCategory.java
import android.view.View;
import android.widget.TextView;
import com.beerbong.zipinst.R;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.preference.PreferenceCategory;
import android.util.AttributeSet;
import android.util.TypedValue;
public UIPreferenceCategory(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIPreferenceCategory(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
Context context = getContext();
Resources res = context.getResources();
if (mTextColor == 0) {
TypedValue typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(R.attr.fragmentTitleColor, typedValue, true);
mTextColor = typedValue.resourceId;
typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(android.R.attr.textAppearanceMedium, typedValue, true);
mAppearanceMedium = typedValue.resourceId;
}
TextView titleView = (TextView) view.findViewById(android.R.id.title);
if (titleView != null) {
titleView.setTextAppearance(context, mAppearanceMedium);
titleView.setTextColor(res.getColor(mTextColor));
float size = res.getDimension(R.dimen.fragment_title_size);
titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
//titleView.setBackgroundColor(mTextColor);
} | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UIPreferenceCategory.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.view.View;
import android.widget.TextView;
import com.beerbong.zipinst.R;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.preference.PreferenceCategory;
import android.util.AttributeSet;
import android.util.TypedValue; |
public UIPreferenceCategory(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIPreferenceCategory(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
Context context = getContext();
Resources res = context.getResources();
if (mTextColor == 0) {
TypedValue typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(R.attr.fragmentTitleColor, typedValue, true);
mTextColor = typedValue.resourceId;
typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(android.R.attr.textAppearanceMedium, typedValue, true);
mAppearanceMedium = typedValue.resourceId;
}
TextView titleView = (TextView) view.findViewById(android.R.id.title);
if (titleView != null) {
titleView.setTextAppearance(context, mAppearanceMedium);
titleView.setTextColor(res.getColor(mTextColor));
float size = res.getDimension(R.dimen.fragment_title_size);
titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
//titleView.setBackgroundColor(mTextColor);
} | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UIPreferenceCategory.java
import android.view.View;
import android.widget.TextView;
import com.beerbong.zipinst.R;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.preference.PreferenceCategory;
import android.util.AttributeSet;
import android.util.TypedValue;
public UIPreferenceCategory(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIPreferenceCategory(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
Context context = getContext();
Resources res = context.getResources();
if (mTextColor == 0) {
TypedValue typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(R.attr.fragmentTitleColor, typedValue, true);
mTextColor = typedValue.resourceId;
typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(android.R.attr.textAppearanceMedium, typedValue, true);
mAppearanceMedium = typedValue.resourceId;
}
TextView titleView = (TextView) view.findViewById(android.R.id.title);
if (titleView != null) {
titleView.setTextAppearance(context, mAppearanceMedium);
titleView.setTextColor(res.getColor(mTextColor));
float size = res.getDimension(R.dimen.fragment_title_size);
titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
//titleView.setBackgroundColor(mTextColor);
} | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UIPreferenceCategory.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.view.View;
import android.widget.TextView;
import com.beerbong.zipinst.R;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.preference.PreferenceCategory;
import android.util.AttributeSet;
import android.util.TypedValue; |
public UIPreferenceCategory(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIPreferenceCategory(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
Context context = getContext();
Resources res = context.getResources();
if (mTextColor == 0) {
TypedValue typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(R.attr.fragmentTitleColor, typedValue, true);
mTextColor = typedValue.resourceId;
typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(android.R.attr.textAppearanceMedium, typedValue, true);
mAppearanceMedium = typedValue.resourceId;
}
TextView titleView = (TextView) view.findViewById(android.R.id.title);
if (titleView != null) {
titleView.setTextAppearance(context, mAppearanceMedium);
titleView.setTextColor(res.getColor(mTextColor));
float size = res.getDimension(R.dimen.fragment_title_size);
titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
//titleView.setBackgroundColor(mTextColor);
} | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UIPreferenceCategory.java
import android.view.View;
import android.widget.TextView;
import com.beerbong.zipinst.R;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.preference.PreferenceCategory;
import android.util.AttributeSet;
import android.util.TypedValue;
public UIPreferenceCategory(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIPreferenceCategory(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
Context context = getContext();
Resources res = context.getResources();
if (mTextColor == 0) {
TypedValue typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(R.attr.fragmentTitleColor, typedValue, true);
mTextColor = typedValue.resourceId;
typedValue = new TypedValue();
((Activity) context).getTheme().resolveAttribute(android.R.attr.textAppearanceMedium, typedValue, true);
mAppearanceMedium = typedValue.resourceId;
}
TextView titleView = (TextView) view.findViewById(android.R.id.title);
if (titleView != null) {
titleView.setTextAppearance(context, mAppearanceMedium);
titleView.setTextColor(res.getColor(mTextColor));
float size = res.getDimension(R.dimen.fragment_title_size);
titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
//titleView.setBackgroundColor(mTextColor);
} | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/core/plugins/update/impl/GooUpdater.java | // Path: src/com/beerbong/zipinst/core/plugins/update/Updater.java
// public interface Updater extends URLStringReaderListener, HttpStringReaderListener {
//
// public class RomInfo {
//
// public int id;
// public String filename;
// public String path;
// public String folder;
// public String md5;
// public String type;
// public String description;
// public int is_flashable;
// public long modified;
// public int downloads;
// public int status;
// public String additional_info;
// public String short_url;
// public int developer_id;
// public String developerid;
// public String board;
// public String rom;
// public long version;
// public int gapps_package;
// public int incremental_file;
// }
//
// public static final String PROPERTY_DEVICE = "ro.product.device";
//
// public static interface UpdaterListener {
//
// public void versionFound(RomInfo info);
// public void versionError(String error);
// }
//
// public String getRomName();
//
// public int getRomVersion();
//
// public void searchVersion();
//
// public boolean isScanning();
// }
//
// Path: src/com/beerbong/zipinst/http/URLStringReader.java
// public class URLStringReader extends AsyncTask<String, Void, Void> {
//
// public static interface URLStringReaderListener {
//
// public void onReadEnd(String buffer);
// public void onReadError(Exception ex);
// };
//
// private URLStringReaderListener mListener;
// private String mBuffer;
// private Exception mException;
//
// public URLStringReader(URLStringReaderListener listener) {
// mListener = listener;
// }
//
// @Override
// protected Void doInBackground(String... params) {
// try {
// mBuffer = readString(params[0]);
// return null;
// } catch (Exception ex) {
// ex.printStackTrace();
// mException = ex;
// }
// return null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// if (mListener != null) {
// if (mException != null) {
// mListener.onReadError(mException);
// } else {
// mListener.onReadEnd(mBuffer);
// }
// }
// }
//
// private String readString(String urlStr) throws Exception {
// URL url = new URL(urlStr);
// URLConnection yc = url.openConnection();
// BufferedReader in = null;
// StringBuffer sb = new StringBuffer();
// try {
// in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
// String inputLine;
// while ((inputLine = in.readLine()) != null)
// sb.append(inputLine);
// } finally {
// if (in != null)
// in.close();
// }
// return sb.toString();
// }
// }
//
// Path: src/com/beerbong/zipinst/io/SystemProperties.java
// public class SystemProperties {
//
// private static final int ALARM_ID = 122303221;
//
// public static String getProperty(String prop) {
// try {
// Process p = Runtime.getRuntime().exec("getprop " + prop);
// p.waitFor();
// BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
// String line = input.readLine();
// return "".equals(line) ? null : line;
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static boolean isNetworkAvailable(Context context) {
// ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
// return activeNetworkInfo != null && activeNetworkInfo.isConnected();
// }
//
// public static void setAlarm(Context context, long time, boolean trigger) {
//
// Intent i = new Intent(context, NotificationAlarm.class);
// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// PendingIntent pi = PendingIntent
// .getBroadcast(context, ALARM_ID, i, PendingIntent.FLAG_UPDATE_CURRENT);
//
// AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// am.cancel(pi);
// if (time > 0) {
// am.setInexactRepeating(AlarmManager.RTC_WAKEUP, trigger ? 0 : time, time, pi);
// }
// }
//
// public static boolean alarmExists(Context context) {
// return (PendingIntent.getBroadcast(context, ALARM_ID, new Intent(context,
// NotificationAlarm.class), PendingIntent.FLAG_NO_CREATE) != null);
// }
// }
| import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
import com.beerbong.zipinst.core.plugins.update.Updater;
import com.beerbong.zipinst.http.URLStringReader;
import com.beerbong.zipinst.io.SystemProperties; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.core.plugins.update.impl;
public class GooUpdater implements Updater {
public static final String PROPERTY_GOO_DEVELOPER = "ro.goo.developerid";
public static final String PROPERTY_GOO_ROM = "ro.goo.rom";
public static final String PROPERTY_GOO_VERSION = "ro.goo.version";
private UpdaterListener mListener;
private List<RomInfo> mFoundRoms;
private int mScanning = 0;
public GooUpdater(UpdaterListener listener) {
mListener = listener;
}
public String getDeveloperId() { | // Path: src/com/beerbong/zipinst/core/plugins/update/Updater.java
// public interface Updater extends URLStringReaderListener, HttpStringReaderListener {
//
// public class RomInfo {
//
// public int id;
// public String filename;
// public String path;
// public String folder;
// public String md5;
// public String type;
// public String description;
// public int is_flashable;
// public long modified;
// public int downloads;
// public int status;
// public String additional_info;
// public String short_url;
// public int developer_id;
// public String developerid;
// public String board;
// public String rom;
// public long version;
// public int gapps_package;
// public int incremental_file;
// }
//
// public static final String PROPERTY_DEVICE = "ro.product.device";
//
// public static interface UpdaterListener {
//
// public void versionFound(RomInfo info);
// public void versionError(String error);
// }
//
// public String getRomName();
//
// public int getRomVersion();
//
// public void searchVersion();
//
// public boolean isScanning();
// }
//
// Path: src/com/beerbong/zipinst/http/URLStringReader.java
// public class URLStringReader extends AsyncTask<String, Void, Void> {
//
// public static interface URLStringReaderListener {
//
// public void onReadEnd(String buffer);
// public void onReadError(Exception ex);
// };
//
// private URLStringReaderListener mListener;
// private String mBuffer;
// private Exception mException;
//
// public URLStringReader(URLStringReaderListener listener) {
// mListener = listener;
// }
//
// @Override
// protected Void doInBackground(String... params) {
// try {
// mBuffer = readString(params[0]);
// return null;
// } catch (Exception ex) {
// ex.printStackTrace();
// mException = ex;
// }
// return null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// if (mListener != null) {
// if (mException != null) {
// mListener.onReadError(mException);
// } else {
// mListener.onReadEnd(mBuffer);
// }
// }
// }
//
// private String readString(String urlStr) throws Exception {
// URL url = new URL(urlStr);
// URLConnection yc = url.openConnection();
// BufferedReader in = null;
// StringBuffer sb = new StringBuffer();
// try {
// in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
// String inputLine;
// while ((inputLine = in.readLine()) != null)
// sb.append(inputLine);
// } finally {
// if (in != null)
// in.close();
// }
// return sb.toString();
// }
// }
//
// Path: src/com/beerbong/zipinst/io/SystemProperties.java
// public class SystemProperties {
//
// private static final int ALARM_ID = 122303221;
//
// public static String getProperty(String prop) {
// try {
// Process p = Runtime.getRuntime().exec("getprop " + prop);
// p.waitFor();
// BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
// String line = input.readLine();
// return "".equals(line) ? null : line;
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static boolean isNetworkAvailable(Context context) {
// ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
// return activeNetworkInfo != null && activeNetworkInfo.isConnected();
// }
//
// public static void setAlarm(Context context, long time, boolean trigger) {
//
// Intent i = new Intent(context, NotificationAlarm.class);
// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// PendingIntent pi = PendingIntent
// .getBroadcast(context, ALARM_ID, i, PendingIntent.FLAG_UPDATE_CURRENT);
//
// AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// am.cancel(pi);
// if (time > 0) {
// am.setInexactRepeating(AlarmManager.RTC_WAKEUP, trigger ? 0 : time, time, pi);
// }
// }
//
// public static boolean alarmExists(Context context) {
// return (PendingIntent.getBroadcast(context, ALARM_ID, new Intent(context,
// NotificationAlarm.class), PendingIntent.FLAG_NO_CREATE) != null);
// }
// }
// Path: src/com/beerbong/zipinst/core/plugins/update/impl/GooUpdater.java
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
import com.beerbong.zipinst.core.plugins.update.Updater;
import com.beerbong.zipinst.http.URLStringReader;
import com.beerbong.zipinst.io.SystemProperties;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.core.plugins.update.impl;
public class GooUpdater implements Updater {
public static final String PROPERTY_GOO_DEVELOPER = "ro.goo.developerid";
public static final String PROPERTY_GOO_ROM = "ro.goo.rom";
public static final String PROPERTY_GOO_VERSION = "ro.goo.version";
private UpdaterListener mListener;
private List<RomInfo> mFoundRoms;
private int mScanning = 0;
public GooUpdater(UpdaterListener listener) {
mListener = listener;
}
public String getDeveloperId() { | return SystemProperties.getProperty(PROPERTY_GOO_DEVELOPER); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/core/plugins/update/impl/GooUpdater.java | // Path: src/com/beerbong/zipinst/core/plugins/update/Updater.java
// public interface Updater extends URLStringReaderListener, HttpStringReaderListener {
//
// public class RomInfo {
//
// public int id;
// public String filename;
// public String path;
// public String folder;
// public String md5;
// public String type;
// public String description;
// public int is_flashable;
// public long modified;
// public int downloads;
// public int status;
// public String additional_info;
// public String short_url;
// public int developer_id;
// public String developerid;
// public String board;
// public String rom;
// public long version;
// public int gapps_package;
// public int incremental_file;
// }
//
// public static final String PROPERTY_DEVICE = "ro.product.device";
//
// public static interface UpdaterListener {
//
// public void versionFound(RomInfo info);
// public void versionError(String error);
// }
//
// public String getRomName();
//
// public int getRomVersion();
//
// public void searchVersion();
//
// public boolean isScanning();
// }
//
// Path: src/com/beerbong/zipinst/http/URLStringReader.java
// public class URLStringReader extends AsyncTask<String, Void, Void> {
//
// public static interface URLStringReaderListener {
//
// public void onReadEnd(String buffer);
// public void onReadError(Exception ex);
// };
//
// private URLStringReaderListener mListener;
// private String mBuffer;
// private Exception mException;
//
// public URLStringReader(URLStringReaderListener listener) {
// mListener = listener;
// }
//
// @Override
// protected Void doInBackground(String... params) {
// try {
// mBuffer = readString(params[0]);
// return null;
// } catch (Exception ex) {
// ex.printStackTrace();
// mException = ex;
// }
// return null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// if (mListener != null) {
// if (mException != null) {
// mListener.onReadError(mException);
// } else {
// mListener.onReadEnd(mBuffer);
// }
// }
// }
//
// private String readString(String urlStr) throws Exception {
// URL url = new URL(urlStr);
// URLConnection yc = url.openConnection();
// BufferedReader in = null;
// StringBuffer sb = new StringBuffer();
// try {
// in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
// String inputLine;
// while ((inputLine = in.readLine()) != null)
// sb.append(inputLine);
// } finally {
// if (in != null)
// in.close();
// }
// return sb.toString();
// }
// }
//
// Path: src/com/beerbong/zipinst/io/SystemProperties.java
// public class SystemProperties {
//
// private static final int ALARM_ID = 122303221;
//
// public static String getProperty(String prop) {
// try {
// Process p = Runtime.getRuntime().exec("getprop " + prop);
// p.waitFor();
// BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
// String line = input.readLine();
// return "".equals(line) ? null : line;
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static boolean isNetworkAvailable(Context context) {
// ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
// return activeNetworkInfo != null && activeNetworkInfo.isConnected();
// }
//
// public static void setAlarm(Context context, long time, boolean trigger) {
//
// Intent i = new Intent(context, NotificationAlarm.class);
// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// PendingIntent pi = PendingIntent
// .getBroadcast(context, ALARM_ID, i, PendingIntent.FLAG_UPDATE_CURRENT);
//
// AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// am.cancel(pi);
// if (time > 0) {
// am.setInexactRepeating(AlarmManager.RTC_WAKEUP, trigger ? 0 : time, time, pi);
// }
// }
//
// public static boolean alarmExists(Context context) {
// return (PendingIntent.getBroadcast(context, ALARM_ID, new Intent(context,
// NotificationAlarm.class), PendingIntent.FLAG_NO_CREATE) != null);
// }
// }
| import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
import com.beerbong.zipinst.core.plugins.update.Updater;
import com.beerbong.zipinst.http.URLStringReader;
import com.beerbong.zipinst.io.SystemProperties; | public String getRomName() {
return SystemProperties.getProperty(PROPERTY_GOO_ROM);
}
@Override
public int getRomVersion() {
String version = SystemProperties.getProperty(PROPERTY_GOO_VERSION);
if (version != null) {
try {
return Integer.parseInt(version);
} catch (NumberFormatException ex) {
}
}
return -1;
}
@Override
public void searchVersion() {
mScanning = 0;
mFoundRoms = new ArrayList<RomInfo>();
searchGoo("/devs/" + getDeveloperId());
}
@Override
public boolean isScanning() {
return mScanning > 0;
}
private void searchGoo(String path) {
mScanning++; | // Path: src/com/beerbong/zipinst/core/plugins/update/Updater.java
// public interface Updater extends URLStringReaderListener, HttpStringReaderListener {
//
// public class RomInfo {
//
// public int id;
// public String filename;
// public String path;
// public String folder;
// public String md5;
// public String type;
// public String description;
// public int is_flashable;
// public long modified;
// public int downloads;
// public int status;
// public String additional_info;
// public String short_url;
// public int developer_id;
// public String developerid;
// public String board;
// public String rom;
// public long version;
// public int gapps_package;
// public int incremental_file;
// }
//
// public static final String PROPERTY_DEVICE = "ro.product.device";
//
// public static interface UpdaterListener {
//
// public void versionFound(RomInfo info);
// public void versionError(String error);
// }
//
// public String getRomName();
//
// public int getRomVersion();
//
// public void searchVersion();
//
// public boolean isScanning();
// }
//
// Path: src/com/beerbong/zipinst/http/URLStringReader.java
// public class URLStringReader extends AsyncTask<String, Void, Void> {
//
// public static interface URLStringReaderListener {
//
// public void onReadEnd(String buffer);
// public void onReadError(Exception ex);
// };
//
// private URLStringReaderListener mListener;
// private String mBuffer;
// private Exception mException;
//
// public URLStringReader(URLStringReaderListener listener) {
// mListener = listener;
// }
//
// @Override
// protected Void doInBackground(String... params) {
// try {
// mBuffer = readString(params[0]);
// return null;
// } catch (Exception ex) {
// ex.printStackTrace();
// mException = ex;
// }
// return null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// if (mListener != null) {
// if (mException != null) {
// mListener.onReadError(mException);
// } else {
// mListener.onReadEnd(mBuffer);
// }
// }
// }
//
// private String readString(String urlStr) throws Exception {
// URL url = new URL(urlStr);
// URLConnection yc = url.openConnection();
// BufferedReader in = null;
// StringBuffer sb = new StringBuffer();
// try {
// in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
// String inputLine;
// while ((inputLine = in.readLine()) != null)
// sb.append(inputLine);
// } finally {
// if (in != null)
// in.close();
// }
// return sb.toString();
// }
// }
//
// Path: src/com/beerbong/zipinst/io/SystemProperties.java
// public class SystemProperties {
//
// private static final int ALARM_ID = 122303221;
//
// public static String getProperty(String prop) {
// try {
// Process p = Runtime.getRuntime().exec("getprop " + prop);
// p.waitFor();
// BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
// String line = input.readLine();
// return "".equals(line) ? null : line;
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static boolean isNetworkAvailable(Context context) {
// ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
// return activeNetworkInfo != null && activeNetworkInfo.isConnected();
// }
//
// public static void setAlarm(Context context, long time, boolean trigger) {
//
// Intent i = new Intent(context, NotificationAlarm.class);
// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// PendingIntent pi = PendingIntent
// .getBroadcast(context, ALARM_ID, i, PendingIntent.FLAG_UPDATE_CURRENT);
//
// AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// am.cancel(pi);
// if (time > 0) {
// am.setInexactRepeating(AlarmManager.RTC_WAKEUP, trigger ? 0 : time, time, pi);
// }
// }
//
// public static boolean alarmExists(Context context) {
// return (PendingIntent.getBroadcast(context, ALARM_ID, new Intent(context,
// NotificationAlarm.class), PendingIntent.FLAG_NO_CREATE) != null);
// }
// }
// Path: src/com/beerbong/zipinst/core/plugins/update/impl/GooUpdater.java
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
import com.beerbong.zipinst.core.plugins.update.Updater;
import com.beerbong.zipinst.http.URLStringReader;
import com.beerbong.zipinst.io.SystemProperties;
public String getRomName() {
return SystemProperties.getProperty(PROPERTY_GOO_ROM);
}
@Override
public int getRomVersion() {
String version = SystemProperties.getProperty(PROPERTY_GOO_VERSION);
if (version != null) {
try {
return Integer.parseInt(version);
} catch (NumberFormatException ex) {
}
}
return -1;
}
@Override
public void searchVersion() {
mScanning = 0;
mFoundRoms = new ArrayList<RomInfo>();
searchGoo("/devs/" + getDeveloperId());
}
@Override
public boolean isScanning() {
return mScanning > 0;
}
private void searchGoo(String path) {
mScanning++; | new URLStringReader(this).execute("http://goo.im/json2&path=" + path + "&ro_board=" |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UIMultiSelectListPreference.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.content.Context;
import android.preference.MultiSelectListPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIMultiSelectListPreference extends MultiSelectListPreference {
public UIMultiSelectListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIMultiSelectListPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UIMultiSelectListPreference.java
import android.content.Context;
import android.preference.MultiSelectListPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIMultiSelectListPreference extends MultiSelectListPreference {
public UIMultiSelectListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIMultiSelectListPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UIMultiSelectListPreference.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.content.Context;
import android.preference.MultiSelectListPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIMultiSelectListPreference extends MultiSelectListPreference {
public UIMultiSelectListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIMultiSelectListPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UIMultiSelectListPreference.java
import android.content.Context;
import android.preference.MultiSelectListPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIMultiSelectListPreference extends MultiSelectListPreference {
public UIMultiSelectListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIMultiSelectListPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/preference/UIMultiSelectListPreference.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.content.Context;
import android.preference.MultiSelectListPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIMultiSelectListPreference extends MultiSelectListPreference {
public UIMultiSelectListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIMultiSelectListPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/preference/UIMultiSelectListPreference.java
import android.content.Context;
import android.preference.MultiSelectListPreference;
import android.util.AttributeSet;
import android.view.View;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui.preference;
public class UIMultiSelectListPreference extends MultiSelectListPreference {
public UIMultiSelectListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public UIMultiSelectListPreference(Context context) {
super(context);
}
@Override
protected void onBindView(View view) {
super.onBindView(view); | ((UIPlugin) CoreFactory.getCore().getPlugin(Core.PLUGIN_UI)).redraw(view); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/io/SystemProperties.java | // Path: src/com/beerbong/zipinst/NotificationAlarm.java
// public class NotificationAlarm extends BroadcastReceiver {
//
// private RomUpdater mRomUpdater;
//
// @Override
// public void onReceive(Context context, Intent intent) {
//
// if (mRomUpdater == null) {
// mRomUpdater = new RomUpdater(context);
// }
//
// if (SystemProperties.isNetworkAvailable(context)) {
// mRomUpdater.check();
// }
// }
// }
| import java.io.BufferedReader;
import java.io.InputStreamReader;
import com.beerbong.zipinst.NotificationAlarm;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.io;
public class SystemProperties {
private static final int ALARM_ID = 122303221;
public static String getProperty(String prop) {
try {
Process p = Runtime.getRuntime().exec("getprop " + prop);
p.waitFor();
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = input.readLine();
return "".equals(line) ? null : line;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static boolean isNetworkAvailable(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
public static void setAlarm(Context context, long time, boolean trigger) {
| // Path: src/com/beerbong/zipinst/NotificationAlarm.java
// public class NotificationAlarm extends BroadcastReceiver {
//
// private RomUpdater mRomUpdater;
//
// @Override
// public void onReceive(Context context, Intent intent) {
//
// if (mRomUpdater == null) {
// mRomUpdater = new RomUpdater(context);
// }
//
// if (SystemProperties.isNetworkAvailable(context)) {
// mRomUpdater.check();
// }
// }
// }
// Path: src/com/beerbong/zipinst/io/SystemProperties.java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import com.beerbong.zipinst.NotificationAlarm;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.io;
public class SystemProperties {
private static final int ALARM_ID = 122303221;
public static String getProperty(String prop) {
try {
Process p = Runtime.getRuntime().exec("getprop " + prop);
p.waitFor();
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = input.readLine();
return "".equals(line) ? null : line;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static boolean isNetworkAvailable(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
public static void setAlarm(Context context, long time, boolean trigger) {
| Intent i = new Intent(context, NotificationAlarm.class); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/UIFragment.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.view.ViewGroup;
import java.io.Serializable;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui;
public abstract class UIFragment extends Fragment implements IFragment, UIInterface, Serializable {
private Core mCore;
private View mMainView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
| // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/UIFragment.java
import android.view.ViewGroup;
import java.io.Serializable;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui;
public abstract class UIFragment extends Fragment implements IFragment, UIInterface, Serializable {
private Core mCore;
private View mMainView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
| mCore = CoreFactory.getCore(); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/ui/UIFragment.java | // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
| import android.view.ViewGroup;
import java.io.Serializable;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui;
public abstract class UIFragment extends Fragment implements IFragment, UIInterface, Serializable {
private Core mCore;
private View mMainView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mCore = CoreFactory.getCore();
| // Path: src/com/beerbong/zipinst/core/Core.java
// public interface Core extends Serializable {
//
// public static final String PLUGIN_UI = "UIPlugin";
// public static final String PLUGIN_SUPERUSER = "SuperUserPlugin";
// public static final String PLUGIN_RECOVERY = "RecoveryPlugin";
// public static final String PLUGIN_STORAGE = "StoragePlugin";
// public static final String PLUGIN_REBOOT = "RebootPlugin";
// public static final String PLUGIN_LICENSE = "LicensePlugin";
// public static final String PLUGIN_UPDATE = "UpdatePlugin";
//
// public interface CoreListener {
//
// public void pluginStarted(String name);
//
// public void pluginStopped(String name);
//
// public void coreMessage(int resId);
//
// public void coreStarted();
//
// public void coreStopped();
// }
//
// public void destroy();
//
// public boolean isStarted();
//
// public Context getContext();
//
// public void setContext(Context context);
//
// public Plugin getPlugin(String name);
//
// public Preferences getPreferences();
//
// public CloudStorage getCloudStorage();
//
// public void setCloudStorage(int cloudStorage);
//
// public ONandroid getONandroid();
//
// public Version getVersion();
//
// public void moveToInstall();
// }
//
// Path: src/com/beerbong/zipinst/core/CoreFactory.java
// public class CoreFactory {
//
// private static Core sInstance;
//
// public static synchronized void init(Context context) {
// init(context, null);
// }
//
// public static synchronized void init(Context context, CoreListener listener) {
// if (sInstance == null) {
// sInstance = new CoreImpl(context, listener);
// } else {
// sInstance.setContext(context);
// }
// }
//
// public static Core getCore() {
// return sInstance;
// }
//
// }
//
// Path: src/com/beerbong/zipinst/core/plugins/ui/UIPlugin.java
// public class UIPlugin extends Plugin {
//
// private static final String ROBOTO_THIN = "font/Roboto-Light.ttf";
//
// private Map<String, UIInterface> mUiInterfaces;
// private Typeface mRobotoThin;
//
// public UIPlugin(Core core) {
// super(core, Core.PLUGIN_UI);
// }
//
// @Override
// public void start() {
// ((CoreImpl) getCore()).setMessage(R.string.initializing_ui);
//
//
// (new AsyncTask<Void, Void, Void>() {
//
// @Override
// protected Void doInBackground(Void... params) {
// mUiInterfaces = new HashMap<String, UIInterface>();
//
// mRobotoThin = Typeface
// .createFromAsset(getCore().getContext().getAssets(), ROBOTO_THIN);
// return (Void) null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// started();
// }
// }).execute((Void) null);
// }
//
// @Override
// public void stop() {
// stopped();
// }
//
// public void unregisterUI(UIInterface uIInterface) {
// if (mUiInterfaces != null) {
// mUiInterfaces.remove(uIInterface.getClass().getName());
// }
// }
//
// public void registerUI(UIInterface uIInterface) {
// boolean darkTheme = getCore().getPreferences().isDarkTheme();
// uIInterface.setTheme(darkTheme ? R.style.AppTheme_Dark
// : R.style.AppTheme);
//
// redraw(uIInterface);
//
// if (mUiInterfaces != null) {
// mUiInterfaces.put(uIInterface.getClass().getName(), uIInterface);
// }
// }
//
// public void redraw() {
// Iterator<String> it = mUiInterfaces.keySet().iterator();
// while (it.hasNext()) {
// String key = it.next();
// UIInterface uiInterface = mUiInterfaces.get(key);
// redraw(uiInterface);
// }
// }
//
// public void redraw(UIInterface uIInterface) {
// redraw(uIInterface.getMainView());
// }
//
// public void redraw(View view) {
// setFont(view);
// }
//
// private void setFont(View view) {
// if (view == null) {
// return;
// }
// if (view instanceof ViewGroup) {
// int count = ((ViewGroup) view).getChildCount();
// for (int i = 0; i < count; i++) {
// setFont(((ViewGroup) view).getChildAt(i));
// }
// } else if (view instanceof TextView) {
// ((TextView) view).setTypeface(mRobotoThin);
// }
// }
//
// }
// Path: src/com/beerbong/zipinst/ui/UIFragment.java
import android.view.ViewGroup;
import java.io.Serializable;
import com.beerbong.zipinst.core.Core;
import com.beerbong.zipinst.core.CoreFactory;
import com.beerbong.zipinst.core.plugins.ui.UIPlugin;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.ui;
public abstract class UIFragment extends Fragment implements IFragment, UIInterface, Serializable {
private Core mCore;
private View mMainView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mCore = CoreFactory.getCore();
| ((UIPlugin) mCore.getPlugin(Core.PLUGIN_UI)).registerUI(this); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/core/plugins/update/impl/OUCUpdater.java | // Path: src/com/beerbong/zipinst/core/plugins/update/Updater.java
// public interface Updater extends URLStringReaderListener, HttpStringReaderListener {
//
// public class RomInfo {
//
// public int id;
// public String filename;
// public String path;
// public String folder;
// public String md5;
// public String type;
// public String description;
// public int is_flashable;
// public long modified;
// public int downloads;
// public int status;
// public String additional_info;
// public String short_url;
// public int developer_id;
// public String developerid;
// public String board;
// public String rom;
// public long version;
// public int gapps_package;
// public int incremental_file;
// }
//
// public static final String PROPERTY_DEVICE = "ro.product.device";
//
// public static interface UpdaterListener {
//
// public void versionFound(RomInfo info);
// public void versionError(String error);
// }
//
// public String getRomName();
//
// public int getRomVersion();
//
// public void searchVersion();
//
// public boolean isScanning();
// }
//
// Path: src/com/beerbong/zipinst/http/HttpStringReader.java
// public class HttpStringReader extends AsyncTask<String, Void, Void> {
//
// public static interface HttpStringReaderListener {
//
// public void onReadEnd(String buffer);
// public void onReadError(Exception ex);
// };
//
// private HttpStringReaderListener mListener;
// private String mResponse;
// private Exception mException;
//
// public HttpStringReader(HttpStringReaderListener listener) {
// mListener = listener;
// }
//
// @Override
// protected Void doInBackground(String... urls) {
// try {
// HttpClient client = new DefaultHttpClient();
// HttpGet get = new HttpGet(urls[0]);
// HttpResponse r = client.execute(get);
// int status = r.getStatusLine().getStatusCode();
// HttpEntity e = r.getEntity();
// if (status == 200) {
// mResponse = EntityUtils.toString(e);
// } else {
// if (e != null) e.consumeContent();
// String error = "Server responded with error " + status;
// mException = new Exception(error);
// }
// } catch (Exception ex) {
// ex.printStackTrace();
// mException = ex;
// }
// return null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// if (mListener != null) {
// if (mException != null) {
// mListener.onReadError(mException);
// } else {
// mListener.onReadEnd(mResponse);
// }
// }
// }
// }
//
// Path: src/com/beerbong/zipinst/io/SystemProperties.java
// public class SystemProperties {
//
// private static final int ALARM_ID = 122303221;
//
// public static String getProperty(String prop) {
// try {
// Process p = Runtime.getRuntime().exec("getprop " + prop);
// p.waitFor();
// BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
// String line = input.readLine();
// return "".equals(line) ? null : line;
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static boolean isNetworkAvailable(Context context) {
// ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
// return activeNetworkInfo != null && activeNetworkInfo.isConnected();
// }
//
// public static void setAlarm(Context context, long time, boolean trigger) {
//
// Intent i = new Intent(context, NotificationAlarm.class);
// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// PendingIntent pi = PendingIntent
// .getBroadcast(context, ALARM_ID, i, PendingIntent.FLAG_UPDATE_CURRENT);
//
// AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// am.cancel(pi);
// if (time > 0) {
// am.setInexactRepeating(AlarmManager.RTC_WAKEUP, trigger ? 0 : time, time, pi);
// }
// }
//
// public static boolean alarmExists(Context context) {
// return (PendingIntent.getBroadcast(context, ALARM_ID, new Intent(context,
// NotificationAlarm.class), PendingIntent.FLAG_NO_CREATE) != null);
// }
// }
| import java.util.ArrayList;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import com.beerbong.zipinst.core.plugins.update.Updater;
import com.beerbong.zipinst.http.HttpStringReader;
import com.beerbong.zipinst.io.SystemProperties; | /*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.core.plugins.update.impl;
public class OUCUpdater implements Updater {
public static final String URL = "https://www.otaupdatecenter.pro/pages/romupdate.php";
public static final String PROPERTY_OTA_ID = "otaupdater.otaid";
public static final String PROPERTY_OTA_VER = "otaupdater.otaver";
public static final String PROPERTY_OTA_TIME = "otaupdater.otatime";
private UpdaterListener mListener;
private boolean mScanning = false;
public OUCUpdater(UpdaterListener listener) {
mListener = listener;
}
@Override
public String getRomName() { | // Path: src/com/beerbong/zipinst/core/plugins/update/Updater.java
// public interface Updater extends URLStringReaderListener, HttpStringReaderListener {
//
// public class RomInfo {
//
// public int id;
// public String filename;
// public String path;
// public String folder;
// public String md5;
// public String type;
// public String description;
// public int is_flashable;
// public long modified;
// public int downloads;
// public int status;
// public String additional_info;
// public String short_url;
// public int developer_id;
// public String developerid;
// public String board;
// public String rom;
// public long version;
// public int gapps_package;
// public int incremental_file;
// }
//
// public static final String PROPERTY_DEVICE = "ro.product.device";
//
// public static interface UpdaterListener {
//
// public void versionFound(RomInfo info);
// public void versionError(String error);
// }
//
// public String getRomName();
//
// public int getRomVersion();
//
// public void searchVersion();
//
// public boolean isScanning();
// }
//
// Path: src/com/beerbong/zipinst/http/HttpStringReader.java
// public class HttpStringReader extends AsyncTask<String, Void, Void> {
//
// public static interface HttpStringReaderListener {
//
// public void onReadEnd(String buffer);
// public void onReadError(Exception ex);
// };
//
// private HttpStringReaderListener mListener;
// private String mResponse;
// private Exception mException;
//
// public HttpStringReader(HttpStringReaderListener listener) {
// mListener = listener;
// }
//
// @Override
// protected Void doInBackground(String... urls) {
// try {
// HttpClient client = new DefaultHttpClient();
// HttpGet get = new HttpGet(urls[0]);
// HttpResponse r = client.execute(get);
// int status = r.getStatusLine().getStatusCode();
// HttpEntity e = r.getEntity();
// if (status == 200) {
// mResponse = EntityUtils.toString(e);
// } else {
// if (e != null) e.consumeContent();
// String error = "Server responded with error " + status;
// mException = new Exception(error);
// }
// } catch (Exception ex) {
// ex.printStackTrace();
// mException = ex;
// }
// return null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// if (mListener != null) {
// if (mException != null) {
// mListener.onReadError(mException);
// } else {
// mListener.onReadEnd(mResponse);
// }
// }
// }
// }
//
// Path: src/com/beerbong/zipinst/io/SystemProperties.java
// public class SystemProperties {
//
// private static final int ALARM_ID = 122303221;
//
// public static String getProperty(String prop) {
// try {
// Process p = Runtime.getRuntime().exec("getprop " + prop);
// p.waitFor();
// BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
// String line = input.readLine();
// return "".equals(line) ? null : line;
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static boolean isNetworkAvailable(Context context) {
// ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
// return activeNetworkInfo != null && activeNetworkInfo.isConnected();
// }
//
// public static void setAlarm(Context context, long time, boolean trigger) {
//
// Intent i = new Intent(context, NotificationAlarm.class);
// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// PendingIntent pi = PendingIntent
// .getBroadcast(context, ALARM_ID, i, PendingIntent.FLAG_UPDATE_CURRENT);
//
// AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// am.cancel(pi);
// if (time > 0) {
// am.setInexactRepeating(AlarmManager.RTC_WAKEUP, trigger ? 0 : time, time, pi);
// }
// }
//
// public static boolean alarmExists(Context context) {
// return (PendingIntent.getBroadcast(context, ALARM_ID, new Intent(context,
// NotificationAlarm.class), PendingIntent.FLAG_NO_CREATE) != null);
// }
// }
// Path: src/com/beerbong/zipinst/core/plugins/update/impl/OUCUpdater.java
import java.util.ArrayList;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import com.beerbong.zipinst.core.plugins.update.Updater;
import com.beerbong.zipinst.http.HttpStringReader;
import com.beerbong.zipinst.io.SystemProperties;
/*
* Copyright 2014 ZipInstaller Project
*
* This file is part of ZipInstaller.
*
* ZipInstaller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZipInstaller is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZipInstaller. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beerbong.zipinst.core.plugins.update.impl;
public class OUCUpdater implements Updater {
public static final String URL = "https://www.otaupdatecenter.pro/pages/romupdate.php";
public static final String PROPERTY_OTA_ID = "otaupdater.otaid";
public static final String PROPERTY_OTA_VER = "otaupdater.otaver";
public static final String PROPERTY_OTA_TIME = "otaupdater.otatime";
private UpdaterListener mListener;
private boolean mScanning = false;
public OUCUpdater(UpdaterListener listener) {
mListener = listener;
}
@Override
public String getRomName() { | return SystemProperties.getProperty(PROPERTY_OTA_ID); |
beerbong/com_beerbong_zipinst | src/com/beerbong/zipinst/core/plugins/update/impl/OUCUpdater.java | // Path: src/com/beerbong/zipinst/core/plugins/update/Updater.java
// public interface Updater extends URLStringReaderListener, HttpStringReaderListener {
//
// public class RomInfo {
//
// public int id;
// public String filename;
// public String path;
// public String folder;
// public String md5;
// public String type;
// public String description;
// public int is_flashable;
// public long modified;
// public int downloads;
// public int status;
// public String additional_info;
// public String short_url;
// public int developer_id;
// public String developerid;
// public String board;
// public String rom;
// public long version;
// public int gapps_package;
// public int incremental_file;
// }
//
// public static final String PROPERTY_DEVICE = "ro.product.device";
//
// public static interface UpdaterListener {
//
// public void versionFound(RomInfo info);
// public void versionError(String error);
// }
//
// public String getRomName();
//
// public int getRomVersion();
//
// public void searchVersion();
//
// public boolean isScanning();
// }
//
// Path: src/com/beerbong/zipinst/http/HttpStringReader.java
// public class HttpStringReader extends AsyncTask<String, Void, Void> {
//
// public static interface HttpStringReaderListener {
//
// public void onReadEnd(String buffer);
// public void onReadError(Exception ex);
// };
//
// private HttpStringReaderListener mListener;
// private String mResponse;
// private Exception mException;
//
// public HttpStringReader(HttpStringReaderListener listener) {
// mListener = listener;
// }
//
// @Override
// protected Void doInBackground(String... urls) {
// try {
// HttpClient client = new DefaultHttpClient();
// HttpGet get = new HttpGet(urls[0]);
// HttpResponse r = client.execute(get);
// int status = r.getStatusLine().getStatusCode();
// HttpEntity e = r.getEntity();
// if (status == 200) {
// mResponse = EntityUtils.toString(e);
// } else {
// if (e != null) e.consumeContent();
// String error = "Server responded with error " + status;
// mException = new Exception(error);
// }
// } catch (Exception ex) {
// ex.printStackTrace();
// mException = ex;
// }
// return null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// if (mListener != null) {
// if (mException != null) {
// mListener.onReadError(mException);
// } else {
// mListener.onReadEnd(mResponse);
// }
// }
// }
// }
//
// Path: src/com/beerbong/zipinst/io/SystemProperties.java
// public class SystemProperties {
//
// private static final int ALARM_ID = 122303221;
//
// public static String getProperty(String prop) {
// try {
// Process p = Runtime.getRuntime().exec("getprop " + prop);
// p.waitFor();
// BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
// String line = input.readLine();
// return "".equals(line) ? null : line;
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static boolean isNetworkAvailable(Context context) {
// ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
// return activeNetworkInfo != null && activeNetworkInfo.isConnected();
// }
//
// public static void setAlarm(Context context, long time, boolean trigger) {
//
// Intent i = new Intent(context, NotificationAlarm.class);
// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// PendingIntent pi = PendingIntent
// .getBroadcast(context, ALARM_ID, i, PendingIntent.FLAG_UPDATE_CURRENT);
//
// AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// am.cancel(pi);
// if (time > 0) {
// am.setInexactRepeating(AlarmManager.RTC_WAKEUP, trigger ? 0 : time, time, pi);
// }
// }
//
// public static boolean alarmExists(Context context) {
// return (PendingIntent.getBroadcast(context, ALARM_ID, new Intent(context,
// NotificationAlarm.class), PendingIntent.FLAG_NO_CREATE) != null);
// }
// }
| import java.util.ArrayList;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import com.beerbong.zipinst.core.plugins.update.Updater;
import com.beerbong.zipinst.http.HttpStringReader;
import com.beerbong.zipinst.io.SystemProperties; |
String date = json.getString("date");
date = date.replace("-", "");
RomInfo info = new RomInfo();
info.md5 = json.getString("md5");
info.version = Long.parseLong(date);
info.path = json.getString("url");
info.filename = json.getString("rom") + "-" + json.getString("date") + ".zip";
if (getRomVersion() < info.version) {
mListener.versionFound(info);
}
} catch (Exception ex) {
ex.printStackTrace();
mListener.versionError(null);
}
}
@Override
public void onReadError(Exception ex) {
mListener.versionError(null);
}
@Override
public void searchVersion() {
mScanning = true;
ArrayList<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
params.add(new BasicNameValuePair("device", android.os.Build.DEVICE.toLowerCase()));
params.add(new BasicNameValuePair("rom", getRomName())); | // Path: src/com/beerbong/zipinst/core/plugins/update/Updater.java
// public interface Updater extends URLStringReaderListener, HttpStringReaderListener {
//
// public class RomInfo {
//
// public int id;
// public String filename;
// public String path;
// public String folder;
// public String md5;
// public String type;
// public String description;
// public int is_flashable;
// public long modified;
// public int downloads;
// public int status;
// public String additional_info;
// public String short_url;
// public int developer_id;
// public String developerid;
// public String board;
// public String rom;
// public long version;
// public int gapps_package;
// public int incremental_file;
// }
//
// public static final String PROPERTY_DEVICE = "ro.product.device";
//
// public static interface UpdaterListener {
//
// public void versionFound(RomInfo info);
// public void versionError(String error);
// }
//
// public String getRomName();
//
// public int getRomVersion();
//
// public void searchVersion();
//
// public boolean isScanning();
// }
//
// Path: src/com/beerbong/zipinst/http/HttpStringReader.java
// public class HttpStringReader extends AsyncTask<String, Void, Void> {
//
// public static interface HttpStringReaderListener {
//
// public void onReadEnd(String buffer);
// public void onReadError(Exception ex);
// };
//
// private HttpStringReaderListener mListener;
// private String mResponse;
// private Exception mException;
//
// public HttpStringReader(HttpStringReaderListener listener) {
// mListener = listener;
// }
//
// @Override
// protected Void doInBackground(String... urls) {
// try {
// HttpClient client = new DefaultHttpClient();
// HttpGet get = new HttpGet(urls[0]);
// HttpResponse r = client.execute(get);
// int status = r.getStatusLine().getStatusCode();
// HttpEntity e = r.getEntity();
// if (status == 200) {
// mResponse = EntityUtils.toString(e);
// } else {
// if (e != null) e.consumeContent();
// String error = "Server responded with error " + status;
// mException = new Exception(error);
// }
// } catch (Exception ex) {
// ex.printStackTrace();
// mException = ex;
// }
// return null;
// }
//
// @Override
// protected void onPostExecute(Void result) {
// if (mListener != null) {
// if (mException != null) {
// mListener.onReadError(mException);
// } else {
// mListener.onReadEnd(mResponse);
// }
// }
// }
// }
//
// Path: src/com/beerbong/zipinst/io/SystemProperties.java
// public class SystemProperties {
//
// private static final int ALARM_ID = 122303221;
//
// public static String getProperty(String prop) {
// try {
// Process p = Runtime.getRuntime().exec("getprop " + prop);
// p.waitFor();
// BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
// String line = input.readLine();
// return "".equals(line) ? null : line;
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static boolean isNetworkAvailable(Context context) {
// ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
// return activeNetworkInfo != null && activeNetworkInfo.isConnected();
// }
//
// public static void setAlarm(Context context, long time, boolean trigger) {
//
// Intent i = new Intent(context, NotificationAlarm.class);
// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//
// PendingIntent pi = PendingIntent
// .getBroadcast(context, ALARM_ID, i, PendingIntent.FLAG_UPDATE_CURRENT);
//
// AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// am.cancel(pi);
// if (time > 0) {
// am.setInexactRepeating(AlarmManager.RTC_WAKEUP, trigger ? 0 : time, time, pi);
// }
// }
//
// public static boolean alarmExists(Context context) {
// return (PendingIntent.getBroadcast(context, ALARM_ID, new Intent(context,
// NotificationAlarm.class), PendingIntent.FLAG_NO_CREATE) != null);
// }
// }
// Path: src/com/beerbong/zipinst/core/plugins/update/impl/OUCUpdater.java
import java.util.ArrayList;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import com.beerbong.zipinst.core.plugins.update.Updater;
import com.beerbong.zipinst.http.HttpStringReader;
import com.beerbong.zipinst.io.SystemProperties;
String date = json.getString("date");
date = date.replace("-", "");
RomInfo info = new RomInfo();
info.md5 = json.getString("md5");
info.version = Long.parseLong(date);
info.path = json.getString("url");
info.filename = json.getString("rom") + "-" + json.getString("date") + ".zip";
if (getRomVersion() < info.version) {
mListener.versionFound(info);
}
} catch (Exception ex) {
ex.printStackTrace();
mListener.versionError(null);
}
}
@Override
public void onReadError(Exception ex) {
mListener.versionError(null);
}
@Override
public void searchVersion() {
mScanning = true;
ArrayList<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
params.add(new BasicNameValuePair("device", android.os.Build.DEVICE.toLowerCase()));
params.add(new BasicNameValuePair("rom", getRomName())); | new HttpStringReader(this).execute(URL + "?" + URLEncodedUtils.format(params, "UTF-8")); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.