Skip to content

Instantly share code, notes, and snippets.

View inspiran's full-sized avatar

Daniel Kucharski inspiran

View GitHub Profile
@inspiran
inspiran / partial_rest_view_thoughts
Created October 4, 2012 09:08
Partial REST view

The Problem:

Good REST design assumes a single URI to identify a given resource. In the enterprise sphere this might cause an unneeded overhead. Take for instance a product entity as an example. Looking at it from a customer point of view you would be interested in information such as name, price, description and availability. From a purchaser point of view (the person in the company buying this product from its suppliers) he doesn't care about the customer prices. He cares about data related to the purchasing of this product such as last_purchased_supplier, suppliers, supplier prices and so on. Again the customer 1)should not care about the purchasing data associated to a product and 2) not be allowed to see it anyhow.

For a record, in SAP a product has more than 100 columns. A sales order item has more than 150 columns, although there are reasons for this complexity needless to say that not everybody needs all data returned.

A Solution:

One solution could be to introduce the concept of a RestReso

Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for doctrine/mongodb dev-master -> satisfiable by doctrine/mongodb dev-master.
- Installation request for doctrine/mongodb-odm dev-master -> satisfiable by doctrine/mongodb-odm dev-master.
- Installation request for symfony/monolog-bundle dev-master -> satisfiable by symfony/monolog-bundle dev-master.
- doctrine/mongodb 1.0.x-dev requires symfony/console >=2.0,<2.2-dev -> satisfiable by symfony/console v2.1.0-BETA1, symfony/console v2.1.0-BETA2, symfony/symfony v2.1.0-BETA1, symfony/console v2.0.13, symfony/symfony v2.0.13, symfony/console 2.0.4, symfony/console 2.0.5, symfony/console 2.0.6, symfony/console 2.0.7, symfony/symfony 2.0.7, symfony/console v2.1.0, symfony/console v2.1.0-RC2, symfony/symfony v2.0.17, symfony/symfony v2.1.0-RC1, symfony/symfony v2.1.0-RC2, symfony/console v2.0.16, symfony/console v2.0.17, symfony/console v2.1.0-BETA3, symfony/console v2.1.0-BETA4, symfony/c
@inspiran
inspiran / SimpleCartPricingProvider.php
Created June 13, 2012 21:19
Vespolina - injectable taxation hints
protected function preparePricingContextForTaxation($pricingContext)
{
//Find out if the tax zone was supplied
$taxZone = $pricingContext->get('taxZone');
if (null == $taxZone) {
//Check if a fulfillment address was explicitly set
$address = $pricingContext->get('fulfillmentAddress');
{
"name": "vespolina/vespolina-sandbox",
"type": "symfony-bundle",
"description": "Vespolina sandbox.",
"keywords": ["shop", "ecommerce", "cart", "item"],
"homepage": "http://vespolina-project.org",
"license": "MIT",
"authors": [
{
"name": "Vespolina Team",
<?php
/**
* (c) 2011-2012 Vespolina Project http://www.vespolina-project.org
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Vespolina\CartBundle\Pricing;
@inspiran
inspiran / gist:1918849
Created February 26, 2012 20:30
Activiti export
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://activiti.org/bpmn20">
<process id="Beb1" name="Review And Approve Activiti Process">
<startEvent id="start" name="Start" activiti:formKey="wf:submitReviewTask"></startEvent>
<userTask id="reviewTask" name="Review Task" activiti:assignee="${bpm_assignee.properties.userName}" activiti:formKey="wf:activitiReviewTask">
<extensionElements>
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:s
@inspiran
inspiran / pricing.twig
Created February 7, 2012 23:20
Vespolina pricing declaration based on twig alike syntax
{% pricingSet "packable_product" %}
{% element "packaging_cost" %}
{% element "net_value" %}
{% element "net_value_with_packaging_cost" %}
{% element "tax_amount" %}
{% element "unit_price_with_tax" %}
{% endpricingset %}
{% pricingSet "cart_item" %}
{% element "total_discount" %}
{
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.2",
"symfony/symfony": "2.1.0-dev",
"symfony/doctrine-bridge": "master-dev",
"twig/extensions": "*",
"doctrine/doctrine-fixtures-bundle": "master-dev",
public function testSalesOrderCreate()
{
$salesOrderService = $this->getKernel()->getContainer()->get('vespolina.order_document');
$salesOrder = $salesOrderService->createOrder('default_b2c');
$salesOrderItem1 = $salesOrderService->createItem($salesOrder);
$productA = $this->getMockForAbstractClass('Vespolina\ProductBundle\Model\Product');
$productB = $this->getMockForAbstractClass('Vespolina\ProductBundle\Model\Product');
@inspiran
inspiran / gist:913426
Created April 11, 2011 12:22
github error
vespolina@server:/var/www/vhosts/vespolina.org/httpdocs/vespolina-site# git push origin
Enter passphrase for key '/home/vespolina/.ssh/id_rsa':
Counting objects: 170, done.
Delta compression using up to 8 threads.
fatal: unable to create thread: Resource temporarily unavailable
error: pack-objects died with strange error