text:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!--

    Copyright © Microsoft Open Technologies, Inc.

    All Rights Reserved

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS
    OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
    ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A
    PARTICULAR PURPOSE, MERCHANTABILITY OR NON-INFRINGEMENT.

    See the Apache License, Version 2.0 for the specific language
    governing permissions and limitations under the License.

-->
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
  <edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="1.0">
    <Schema Namespace="NorthwindModel" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
      <EntityType Name="Category">
        <Key>
          <PropertyRef Name="CategoryID" />
        </Key>
        <Property Name="CategoryID" Type="Edm.Int32" Nullable="false" p8:StoreGeneratedPattern="Identity" xmlns:p8="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
        <Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="Description" Type="Edm.String" Nullable="true" MaxLength="Max" Unicode="true" FixedLength="false" />
        <Property Name="Picture" Type="Edm.Binary" Nullable="true" MaxLength="Max" FixedLength="false" />
        <NavigationProperty Name="Products" Relationship="NorthwindModel.FK_Products_Categories" FromRole="Categories" ToRole="Products" />
      </EntityType>
      <EntityType Name="CustomerDemographic">
        <Key>
          <PropertyRef Name="CustomerTypeID" />
        </Key>
        <Property Name="CustomerTypeID" Type="Edm.String" Nullable="false" MaxLength="10" Unicode="true" FixedLength="true" />
        <Property Name="CustomerDesc" Type="Edm.String" Nullable="true" MaxLength="Max" Unicode="true" FixedLength="false" />
        <NavigationProperty Name="Customers" Relationship="NorthwindModel.CustomerCustomerDemo" FromRole="CustomerDemographics" ToRole="Customers" />
      </EntityType>
      <EntityType Name="Customer">
        <Key>
          <PropertyRef Name="CustomerID" />
        </Key>
        <Property Name="CustomerID" Type="Edm.String" Nullable="false" MaxLength="5" Unicode="true" FixedLength="true" />
        <Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" />
        <Property Name="ContactName" Type="Edm.String" Nullable="true" MaxLength="30" Unicode="true" FixedLength="false" />
        <Property Name="ContactTitle" Type="Edm.String" Nullable="true" MaxLength="30" Unicode="true" FixedLength="false" />
        <Property Name="Address" Type="Edm.String" Nullable="true" MaxLength="60" Unicode="true" FixedLength="false" />
        <Property Name="City" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="Region" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="PostalCode" Type="Edm.String" Nullable="true" MaxLength="10" Unicode="true" FixedLength="false" />
        <Property Name="Country" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="Phone" Type="Edm.String" Nullable="true" MaxLength="24" Unicode="true" FixedLength="false" />
        <Property Name="Fax" Type="Edm.String" Nullable="true" MaxLength="24" Unicode="true" FixedLength="false" />
        <NavigationProperty Name="Orders" Relationship="NorthwindModel.FK_Orders_Customers" FromRole="Customers" ToRole="Orders" />
        <NavigationProperty Name="CustomerDemographics" Relationship="NorthwindModel.CustomerCustomerDemo" FromRole="Customers" ToRole="CustomerDemographics" />
      </EntityType>
      <EntityType Name="Employee">
        <Key>
          <PropertyRef Name="EmployeeID" />
        </Key>
        <Property Name="EmployeeID" Type="Edm.Int32" Nullable="false" p8:StoreGeneratedPattern="Identity" xmlns:p8="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
        <Property Name="LastName" Type="Edm.String" Nullable="false" MaxLength="20" Unicode="true" FixedLength="false" />
        <Property Name="FirstName" Type="Edm.String" Nullable="false" MaxLength="10" Unicode="true" FixedLength="false" />
        <Property Name="Title" Type="Edm.String" Nullable="true" MaxLength="30" Unicode="true" FixedLength="false" />
        <Property Name="TitleOfCourtesy" Type="Edm.String" Nullable="true" MaxLength="25" Unicode="true" FixedLength="false" />
        <Property Name="BirthDate" Type="Edm.DateTime" Nullable="true" />
        <Property Name="HireDate" Type="Edm.DateTime" Nullable="true" />
        <Property Name="Address" Type="Edm.String" Nullable="true" MaxLength="60" Unicode="true" FixedLength="false" />
        <Property Name="City" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="Region" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="PostalCode" Type="Edm.String" Nullable="true" MaxLength="10" Unicode="true" FixedLength="false" />
        <Property Name="Country" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="HomePhone" Type="Edm.String" Nullable="true" MaxLength="24" Unicode="true" FixedLength="false" />
        <Property Name="Extension" Type="Edm.String" Nullable="true" MaxLength="4" Unicode="true" FixedLength="false" />
        <Property Name="Photo" Type="Edm.Binary" Nullable="true" MaxLength="Max" FixedLength="false" />
        <Property Name="Notes" Type="Edm.String" Nullable="true" MaxLength="Max" Unicode="true" FixedLength="false" />
        <Property Name="ReportsTo" Type="Edm.Int32" Nullable="true" />
        <Property Name="PhotoPath" Type="Edm.String" Nullable="true" MaxLength="255" Unicode="true" FixedLength="false" />
        <NavigationProperty Name="Employees1" Relationship="NorthwindModel.FK_Employees_Employees" FromRole="Employees" ToRole="Employees1" />
        <NavigationProperty Name="Employee1" Relationship="NorthwindModel.FK_Employees_Employees" FromRole="Employees1" ToRole="Employees" />
        <NavigationProperty Name="Orders" Relationship="NorthwindModel.FK_Orders_Employees" FromRole="Employees" ToRole="Orders" />
        <NavigationProperty Name="Territories" Relationship="NorthwindModel.EmployeeTerritories" FromRole="Employees" ToRole="Territories" />
      </EntityType>
      <EntityType Name="Order_Detail">
        <Key>
          <PropertyRef Name="OrderID" />
          <PropertyRef Name="ProductID" />
        </Key>
        <Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
        <Property Name="ProductID" Type="Edm.Int32" Nullable="false" />
        <Property Name="UnitPrice" Type="Edm.Decimal" Nullable="false" Precision="19" Scale="4" />
        <Property Name="Quantity" Type="Edm.Int16" Nullable="false" />
        <Property Name="Discount" Type="Edm.Single" Nullable="false" />
        <NavigationProperty Name="Order" Relationship="NorthwindModel.FK_Order_Details_Orders" FromRole="Order_Details" ToRole="Orders" />
        <NavigationProperty Name="Product" Relationship="NorthwindModel.FK_Order_Details_Products" FromRole="Order_Details" ToRole="Products" />
      </EntityType>
      <EntityType Name="Order">
        <Key>
          <PropertyRef Name="OrderID" />
        </Key>
        <Property Name="OrderID" Type="Edm.Int32" Nullable="false" p8:StoreGeneratedPattern="Identity" xmlns:p8="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
        <Property Name="CustomerID" Type="Edm.String" Nullable="true" MaxLength="5" Unicode="true" FixedLength="true" />
        <Property Name="EmployeeID" Type="Edm.Int32" Nullable="true" />
        <Property Name="OrderDate" Type="Edm.DateTime" Nullable="true" />
        <Property Name="RequiredDate" Type="Edm.DateTime" Nullable="true" />
        <Property Name="ShippedDate" Type="Edm.DateTime" Nullable="true" />
        <Property Name="ShipVia" Type="Edm.Int32" Nullable="true" />
        <Property Name="Freight" Type="Edm.Decimal" Nullable="true" Precision="19" Scale="4" />
        <Property Name="ShipName" Type="Edm.String" Nullable="true" MaxLength="40" Unicode="true" FixedLength="false" />
        <Property Name="ShipAddress" Type="Edm.String" Nullable="true" MaxLength="60" Unicode="true" FixedLength="false" />
        <Property Name="ShipCity" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="ShipRegion" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="ShipPostalCode" Type="Edm.String" Nullable="true" MaxLength="10" Unicode="true" FixedLength="false" />
        <Property Name="ShipCountry" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <NavigationProperty Name="Customer" Relationship="NorthwindModel.FK_Orders_Customers" FromRole="Orders" ToRole="Customers" />
        <NavigationProperty Name="Employee" Relationship="NorthwindModel.FK_Orders_Employees" FromRole="Orders" ToRole="Employees" />
        <NavigationProperty Name="Order_Details" Relationship="NorthwindModel.FK_Order_Details_Orders" FromRole="Orders" ToRole="Order_Details" />
        <NavigationProperty Name="Shipper" Relationship="NorthwindModel.FK_Orders_Shippers" FromRole="Orders" ToRole="Shippers" />
      </EntityType>
      <EntityType Name="Product">
        <Key>
          <PropertyRef Name="ProductID" />
        </Key>
        <Property Name="ProductID" Type="Edm.Int32" Nullable="false" p8:StoreGeneratedPattern="Identity" xmlns:p8="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
        <Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" />
        <Property Name="SupplierID" Type="Edm.Int32" Nullable="true" />
        <Property Name="CategoryID" Type="Edm.Int32" Nullable="true" />
        <Property Name="QuantityPerUnit" Type="Edm.String" Nullable="true" MaxLength="20" Unicode="true" FixedLength="false" />
        <Property Name="UnitPrice" Type="Edm.Decimal" Nullable="true" Precision="19" Scale="4" />
        <Property Name="UnitsInStock" Type="Edm.Int16" Nullable="true" />
        <Property Name="UnitsOnOrder" Type="Edm.Int16" Nullable="true" />
        <Property Name="ReorderLevel" Type="Edm.Int16" Nullable="true" />
        <Property Name="Discontinued" Type="Edm.Boolean" Nullable="false" />
        <NavigationProperty Name="Category" Relationship="NorthwindModel.FK_Products_Categories" FromRole="Products" ToRole="Categories" />
        <NavigationProperty Name="Order_Details" Relationship="NorthwindModel.FK_Order_Details_Products" FromRole="Products" ToRole="Order_Details" />
        <NavigationProperty Name="Supplier" Relationship="NorthwindModel.FK_Products_Suppliers" FromRole="Products" ToRole="Suppliers" />
      </EntityType>
      <EntityType Name="Region">
        <Key>
          <PropertyRef Name="RegionID" />
        </Key>
        <Property Name="RegionID" Type="Edm.Int32" Nullable="false" />
        <Property Name="RegionDescription" Type="Edm.String" Nullable="false" MaxLength="50" Unicode="true" FixedLength="true" />
        <NavigationProperty Name="Territories" Relationship="NorthwindModel.FK_Territories_Region" FromRole="Region" ToRole="Territories" />
      </EntityType>
      <EntityType Name="Shipper">
        <Key>
          <PropertyRef Name="ShipperID" />
        </Key>
        <Property Name="ShipperID" Type="Edm.Int32" Nullable="false" p8:StoreGeneratedPattern="Identity" xmlns:p8="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
        <Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" />
        <Property Name="Phone" Type="Edm.String" Nullable="true" MaxLength="24" Unicode="true" FixedLength="false" />
        <NavigationProperty Name="Orders" Relationship="NorthwindModel.FK_Orders_Shippers" FromRole="Shippers" ToRole="Orders" />
      </EntityType>
      <EntityType Name="Supplier">
        <Key>
          <PropertyRef Name="SupplierID" />
        </Key>
        <Property Name="SupplierID" Type="Edm.Int32" Nullable="false" p8:StoreGeneratedPattern="Identity" xmlns:p8="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
        <Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" />
        <Property Name="ContactName" Type="Edm.String" Nullable="true" MaxLength="30" Unicode="true" FixedLength="false" />
        <Property Name="ContactTitle" Type="Edm.String" Nullable="true" MaxLength="30" Unicode="true" FixedLength="false" />
        <Property Name="Address" Type="Edm.String" Nullable="true" MaxLength="60" Unicode="true" FixedLength="false" />
        <Property Name="City" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="Region" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="PostalCode" Type="Edm.String" Nullable="true" MaxLength="10" Unicode="true" FixedLength="false" />
        <Property Name="Country" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="Phone" Type="Edm.String" Nullable="true" MaxLength="24" Unicode="true" FixedLength="false" />
        <Property Name="Fax" Type="Edm.String" Nullable="true" MaxLength="24" Unicode="true" FixedLength="false" />
        <Property Name="HomePage" Type="Edm.String" Nullable="true" MaxLength="Max" Unicode="true" FixedLength="false" />
        <NavigationProperty Name="Products" Relationship="NorthwindModel.FK_Products_Suppliers" FromRole="Suppliers" ToRole="Products" />
      </EntityType>
      <EntityType Name="Territory">
        <Key>
          <PropertyRef Name="TerritoryID" />
        </Key>
        <Property Name="TerritoryID" Type="Edm.String" Nullable="false" MaxLength="20" Unicode="true" FixedLength="false" />
        <Property Name="TerritoryDescription" Type="Edm.String" Nullable="false" MaxLength="50" Unicode="true" FixedLength="true" />
        <Property Name="RegionID" Type="Edm.Int32" Nullable="false" />
        <NavigationProperty Name="Region" Relationship="NorthwindModel.FK_Territories_Region" FromRole="Territories" ToRole="Region" />
        <NavigationProperty Name="Employees" Relationship="NorthwindModel.EmployeeTerritories" FromRole="Territories" ToRole="Employees" />
      </EntityType>
      <EntityType Name="Alphabetical_list_of_product">
        <Key>
          <PropertyRef Name="ProductID" />
          <PropertyRef Name="ProductName" />
          <PropertyRef Name="Discontinued" />
          <PropertyRef Name="CategoryName" />
        </Key>
        <Property Name="ProductID" Type="Edm.Int32" Nullable="false" />
        <Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" />
        <Property Name="SupplierID" Type="Edm.Int32" Nullable="true" />
        <Property Name="CategoryID" Type="Edm.Int32" Nullable="true" />
        <Property Name="QuantityPerUnit" Type="Edm.String" Nullable="true" MaxLength="20" Unicode="true" FixedLength="false" />
        <Property Name="UnitPrice" Type="Edm.Decimal" Nullable="true" Precision="19" Scale="4" />
        <Property Name="UnitsInStock" Type="Edm.Int16" Nullable="true" />
        <Property Name="UnitsOnOrder" Type="Edm.Int16" Nullable="true" />
        <Property Name="ReorderLevel" Type="Edm.Int16" Nullable="true" />
        <Property Name="Discontinued" Type="Edm.Boolean" Nullable="false" />
        <Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" Unicode="true" FixedLength="false" />
      </EntityType>
      <EntityType Name="Category_Sales_for_1997">
        <Key>
          <PropertyRef Name="CategoryName" />
        </Key>
        <Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="CategorySales" Type="Edm.Decimal" Nullable="true" Precision="19" Scale="4" />
      </EntityType>
      <EntityType Name="Current_Product_List">
        <Key>
          <PropertyRef Name="ProductID" />
          <PropertyRef Name="ProductName" />
        </Key>
        <Property Name="ProductID" Type="Edm.Int32" Nullable="false" p8:StoreGeneratedPattern="Identity" xmlns:p8="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
        <Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" />
      </EntityType>
      <EntityType Name="Customer_and_Suppliers_by_City">
        <Key>
          <PropertyRef Name="CompanyName" />
          <PropertyRef Name="Relationship" />
        </Key>
        <Property Name="City" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" />
        <Property Name="ContactName" Type="Edm.String" Nullable="true" MaxLength="30" Unicode="true" FixedLength="false" />
        <Property Name="Relationship" Type="Edm.String" Nullable="false" MaxLength="9" Unicode="false" FixedLength="false" />
      </EntityType>
      <EntityType Name="Invoice">
        <Key>
          <PropertyRef Name="CustomerName" />
          <PropertyRef Name="Salesperson" />
          <PropertyRef Name="OrderID" />
          <PropertyRef Name="ShipperName" />
          <PropertyRef Name="ProductID" />
          <PropertyRef Name="ProductName" />
          <PropertyRef Name="UnitPrice" />
          <PropertyRef Name="Quantity" />
          <PropertyRef Name="Discount" />
        </Key>
        <Property Name="ShipName" Type="Edm.String" Nullable="true" MaxLength="40" Unicode="true" FixedLength="false" />
        <Property Name="ShipAddress" Type="Edm.String" Nullable="true" MaxLength="60" Unicode="true" FixedLength="false" />
        <Property Name="ShipCity" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="ShipRegion" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="ShipPostalCode" Type="Edm.String" Nullable="true" MaxLength="10" Unicode="true" FixedLength="false" />
        <Property Name="ShipCountry" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="CustomerID" Type="Edm.String" Nullable="true" MaxLength="5" Unicode="true" FixedLength="true" />
        <Property Name="CustomerName" Type="Edm.String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" />
        <Property Name="Address" Type="Edm.String" Nullable="true" MaxLength="60" Unicode="true" FixedLength="false" />
        <Property Name="City" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="Region" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="PostalCode" Type="Edm.String" Nullable="true" MaxLength="10" Unicode="true" FixedLength="false" />
        <Property Name="Country" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="Salesperson" Type="Edm.String" Nullable="false" MaxLength="31" Unicode="true" FixedLength="false" />
        <Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
        <Property Name="OrderDate" Type="Edm.DateTime" Nullable="true" />
        <Property Name="RequiredDate" Type="Edm.DateTime" Nullable="true" />
        <Property Name="ShippedDate" Type="Edm.DateTime" Nullable="true" />
        <Property Name="ShipperName" Type="Edm.String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" />
        <Property Name="ProductID" Type="Edm.Int32" Nullable="false" />
        <Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" />
        <Property Name="UnitPrice" Type="Edm.Decimal" Nullable="false" Precision="19" Scale="4" />
        <Property Name="Quantity" Type="Edm.Int16" Nullable="false" />
        <Property Name="Discount" Type="Edm.Single" Nullable="false" />
        <Property Name="ExtendedPrice" Type="Edm.Decimal" Nullable="true" Precision="19" Scale="4" />
        <Property Name="Freight" Type="Edm.Decimal" Nullable="true" Precision="19" Scale="4" />
      </EntityType>
      <EntityType Name="Order_Details_Extended">
        <Key>
          <PropertyRef Name="OrderID" />
          <PropertyRef Name="ProductID" />
          <PropertyRef Name="ProductName" />
          <PropertyRef Name="UnitPrice" />
          <PropertyRef Name="Quantity" />
          <PropertyRef Name="Discount" />
        </Key>
        <Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
        <Property Name="ProductID" Type="Edm.Int32" Nullable="false" />
        <Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" />
        <Property Name="UnitPrice" Type="Edm.Decimal" Nullable="false" Precision="19" Scale="4" />
        <Property Name="Quantity" Type="Edm.Int16" Nullable="false" />
        <Property Name="Discount" Type="Edm.Single" Nullable="false" />
        <Property Name="ExtendedPrice" Type="Edm.Decimal" Nullable="true" Precision="19" Scale="4" />
      </EntityType>
      <EntityType Name="Order_Subtotal">
        <Key>
          <PropertyRef Name="OrderID" />
        </Key>
        <Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
        <Property Name="Subtotal" Type="Edm.Decimal" Nullable="true" Precision="19" Scale="4" />
      </EntityType>
      <EntityType Name="Orders_Qry">
        <Key>
          <PropertyRef Name="OrderID" />
          <PropertyRef Name="CompanyName" />
        </Key>
        <Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
        <Property Name="CustomerID" Type="Edm.String" Nullable="true" MaxLength="5" Unicode="true" FixedLength="true" />
        <Property Name="EmployeeID" Type="Edm.Int32" Nullable="true" />
        <Property Name="OrderDate" Type="Edm.DateTime" Nullable="true" />
        <Property Name="RequiredDate" Type="Edm.DateTime" Nullable="true" />
        <Property Name="ShippedDate" Type="Edm.DateTime" Nullable="true" />
        <Property Name="ShipVia" Type="Edm.Int32" Nullable="true" />
        <Property Name="Freight" Type="Edm.Decimal" Nullable="true" Precision="19" Scale="4" />
        <Property Name="ShipName" Type="Edm.String" Nullable="true" MaxLength="40" Unicode="true" FixedLength="false" />
        <Property Name="ShipAddress" Type="Edm.String" Nullable="true" MaxLength="60" Unicode="true" FixedLength="false" />
        <Property Name="ShipCity" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="ShipRegion" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="ShipPostalCode" Type="Edm.String" Nullable="true" MaxLength="10" Unicode="true" FixedLength="false" />
        <Property Name="ShipCountry" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" />
        <Property Name="Address" Type="Edm.String" Nullable="true" MaxLength="60" Unicode="true" FixedLength="false" />
        <Property Name="City" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="Region" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="PostalCode" Type="Edm.String" Nullable="true" MaxLength="10" Unicode="true" FixedLength="false" />
        <Property Name="Country" Type="Edm.String" Nullable="true" MaxLength="15" Unicode="true" FixedLength="false" />
      </EntityType>
      <EntityType Name="Product_Sales_for_1997">
        <Key>
          <PropertyRef Name="CategoryName" />
          <PropertyRef Name="ProductName" />
        </Key>
        <Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" />
        <Property Name="ProductSales" Type="Edm.Decimal" Nullable="true" Precision="19" Scale="4" />
      </EntityType>
      <EntityType Name="Products_Above_Average_Price">
        <Key>
          <PropertyRef Name="ProductName" />
        </Key>
        <Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" />
        <Property Name="UnitPrice" Type="Edm.Decimal" Nullable="true" Precision="19" Scale="4" />
      </EntityType>
      <EntityType Name="Products_by_Category">
        <Key>
          <PropertyRef Name="CategoryName" />
          <PropertyRef Name="ProductName" />
          <PropertyRef Name="Discontinued" />
        </Key>
        <Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" />
        <Property Name="QuantityPerUnit" Type="Edm.String" Nullable="true" MaxLength="20" Unicode="true" FixedLength="false" />
        <Property Name="UnitsInStock" Type="Edm.Int16" Nullable="true" />
        <Property Name="Discontinued" Type="Edm.Boolean" Nullable="false" />
      </EntityType>
      <EntityType Name="Sales_by_Category">
        <Key>
          <PropertyRef Name="CategoryID" />
          <PropertyRef Name="CategoryName" />
          <PropertyRef Name="ProductName" />
        </Key>
        <Property Name="CategoryID" Type="Edm.Int32" Nullable="false" />
        <Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" Unicode="true" FixedLength="false" />
        <Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" />
        <Property Name="ProductSales" Type="Edm.Decimal" Nullable="true" Precision="19" Scale="4" />
      </EntityType>
      <EntityType Name="Sales_Totals_by_Amount">
        <Key>
          <PropertyRef Name="OrderID" />
          <PropertyRef Name="CompanyName" />
        </Key>
        <Property Name="SaleAmount" Type="Edm.Decimal" Nullable="true" Precision="19" Scale="4" />
        <Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
        <Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" />
        <Property Name="ShippedDate" Type="Edm.DateTime" Nullable="true" />
      </EntityType>
      <EntityType Name="Summary_of_Sales_by_Quarter">
        <Key>
          <PropertyRef Name="OrderID" />
        </Key>
        <Property Name="ShippedDate" Type="Edm.DateTime" Nullable="true" />
        <Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
        <Property Name="Subtotal" Type="Edm.Decimal" Nullable="true" Precision="19" Scale="4" />
      </EntityType>
      <EntityType Name="Summary_of_Sales_by_Year">
        <Key>
          <PropertyRef Name="OrderID" />
        </Key>
        <Property Name="ShippedDate" Type="Edm.DateTime" Nullable="true" />
        <Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
        <Property Name="Subtotal" Type="Edm.Decimal" Nullable="true" Precision="19" Scale="4" />
      </EntityType>
      <Association Name="FK_Products_Categories">
        <End Role="Categories" Type="NorthwindModel.Category" Multiplicity="0..1" />
        <End Role="Products" Type="NorthwindModel.Product" Multiplicity="*" />
        <ReferentialConstraint>
          <Principal Role="Categories">
            <PropertyRef Name="CategoryID" />
          </Principal>
          <Dependent Role="Products">
            <PropertyRef Name="CategoryID" />
          </Dependent>
        </ReferentialConstraint>
      </Association>
      <Association Name="FK_Orders_Customers">
        <End Role="Customers" Type="NorthwindModel.Customer" Multiplicity="0..1" />
        <End Role="Orders" Type="NorthwindModel.Order" Multiplicity="*" />
        <ReferentialConstraint>
          <Principal Role="Customers">
            <PropertyRef Name="CustomerID" />
          </Principal>
          <Dependent Role="Orders">
            <PropertyRef Name="CustomerID" />
          </Dependent>
        </ReferentialConstraint>
      </Association>
      <Association Name="FK_Employees_Employees">
        <End Role="Employees" Type="NorthwindModel.Employee" Multiplicity="0..1" />
        <End Role="Employees1" Type="NorthwindModel.Employee" Multiplicity="*" />
        <ReferentialConstraint>
          <Principal Role="Employees">
            <PropertyRef Name="EmployeeID" />
          </Principal>
          <Dependent Role="Employees1">
            <PropertyRef Name="ReportsTo" />
          </Dependent>
        </ReferentialConstraint>
      </Association>
      <Association Name="FK_Orders_Employees">
        <End Role="Employees" Type="NorthwindModel.Employee" Multiplicity="0..1" />
        <End Role="Orders" Type="NorthwindModel.Order" Multiplicity="*" />
        <ReferentialConstraint>
          <Principal Role="Employees">
            <PropertyRef Name="EmployeeID" />
          </Principal>
          <Dependent Role="Orders">
            <PropertyRef Name="EmployeeID" />
          </Dependent>
        </ReferentialConstraint>
      </Association>
      <Association Name="FK_Order_Details_Orders">
        <End Role="Orders" Type="NorthwindModel.Order" Multiplicity="1" />
        <End Role="Order_Details" Type="NorthwindModel.Order_Detail" Multiplicity="*" />
        <ReferentialConstraint>
          <Principal Role="Orders">
            <PropertyRef Name="OrderID" />
          </Principal>
          <Dependent Role="Order_Details">
            <PropertyRef Name="OrderID" />
          </Dependent>
        </ReferentialConstraint>
      </Association>
      <Association Name="FK_Order_Details_Products">
        <End Role="Products" Type="NorthwindModel.Product" Multiplicity="1" />
        <End Role="Order_Details" Type="NorthwindModel.Order_Detail" Multiplicity="*" />
        <ReferentialConstraint>
          <Principal Role="Products">
            <PropertyRef Name="ProductID" />
          </Principal>
          <Dependent Role="Order_Details">
            <PropertyRef Name="ProductID" />
          </Dependent>
        </ReferentialConstraint>
      </Association>
      <Association Name="FK_Orders_Shippers">
        <End Role="Shippers" Type="NorthwindModel.Shipper" Multiplicity="0..1" />
        <End Role="Orders" Type="NorthwindModel.Order" Multiplicity="*" />
        <ReferentialConstraint>
          <Principal Role="Shippers">
            <PropertyRef Name="ShipperID" />
          </Principal>
          <Dependent Role="Orders">
            <PropertyRef Name="ShipVia" />
          </Dependent>
        </ReferentialConstraint>
      </Association>
      <Association Name="FK_Products_Suppliers">
        <End Role="Suppliers" Type="NorthwindModel.Supplier" Multiplicity="0..1" />
        <End Role="Products" Type="NorthwindModel.Product" Multiplicity="*" />
        <ReferentialConstraint>
          <Principal Role="Suppliers">
            <PropertyRef Name="SupplierID" />
          </Principal>
          <Dependent Role="Products">
            <PropertyRef Name="SupplierID" />
          </Dependent>
        </ReferentialConstraint>
      </Association>
      <Association Name="FK_Territories_Region">
        <End Role="Region" Type="NorthwindModel.Region" Multiplicity="1" />
        <End Role="Territories" Type="NorthwindModel.Territory" Multiplicity="*" />
        <ReferentialConstraint>
          <Principal Role="Region">
            <PropertyRef Name="RegionID" />
          </Principal>
          <Dependent Role="Territories">
            <PropertyRef Name="RegionID" />
          </Dependent>
        </ReferentialConstraint>
      </Association>
      <Association Name="CustomerCustomerDemo">
        <End Role="CustomerDemographics" Type="NorthwindModel.CustomerDemographic" Multiplicity="*" />
        <End Role="Customers" Type="NorthwindModel.Customer" Multiplicity="*" />
      </Association>
      <Association Name="EmployeeTerritories">
        <End Role="Employees" Type="NorthwindModel.Employee" Multiplicity="*" />
        <End Role="Territories" Type="NorthwindModel.Territory" Multiplicity="*" />
      </Association>
    </Schema>
    <Schema Namespace="ODataWeb.Northwind.Model" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
      <EntityContainer Name="NorthwindEntities" p7:LazyLoadingEnabled="true" m:IsDefaultEntityContainer="true" xmlns:p7="http://schemas.microsoft.com/ado/2009/02/edm/annotation">
        <EntitySet Name="Categories" EntityType="NorthwindModel.Category" />
        <EntitySet Name="CustomerDemographics" EntityType="NorthwindModel.CustomerDemographic" />
        <EntitySet Name="Customers" EntityType="NorthwindModel.Customer" />
        <EntitySet Name="Employees" EntityType="NorthwindModel.Employee" />
        <EntitySet Name="Order_Details" EntityType="NorthwindModel.Order_Detail" />
        <EntitySet Name="Orders" EntityType="NorthwindModel.Order" />
        <EntitySet Name="Products" EntityType="NorthwindModel.Product" />
        <EntitySet Name="Regions" EntityType="NorthwindModel.Region" />
        <EntitySet Name="Shippers" EntityType="NorthwindModel.Shipper" />
        <EntitySet Name="Suppliers" EntityType="NorthwindModel.Supplier" />
        <EntitySet Name="Territories" EntityType="NorthwindModel.Territory" />
        <EntitySet Name="Alphabetical_list_of_products" EntityType="NorthwindModel.Alphabetical_list_of_product" />
        <EntitySet Name="Category_Sales_for_1997" EntityType="NorthwindModel.Category_Sales_for_1997" />
        <EntitySet Name="Current_Product_Lists" EntityType="NorthwindModel.Current_Product_List" />
        <EntitySet Name="Customer_and_Suppliers_by_Cities" EntityType="NorthwindModel.Customer_and_Suppliers_by_City" />
        <EntitySet Name="Invoices" EntityType="NorthwindModel.Invoice" />
        <EntitySet Name="Order_Details_Extendeds" EntityType="NorthwindModel.Order_Details_Extended" />
        <EntitySet Name="Order_Subtotals" EntityType="NorthwindModel.Order_Subtotal" />
        <EntitySet Name="Orders_Qries" EntityType="NorthwindModel.Orders_Qry" />
        <EntitySet Name="Product_Sales_for_1997" EntityType="NorthwindModel.Product_Sales_for_1997" />
        <EntitySet Name="Products_Above_Average_Prices" EntityType="NorthwindModel.Products_Above_Average_Price" />
        <EntitySet Name="Products_by_Categories" EntityType="NorthwindModel.Products_by_Category" />
        <EntitySet Name="Sales_by_Categories" EntityType="NorthwindModel.Sales_by_Category" />
        <EntitySet Name="Sales_Totals_by_Amounts" EntityType="NorthwindModel.Sales_Totals_by_Amount" />
        <EntitySet Name="Summary_of_Sales_by_Quarters" EntityType="NorthwindModel.Summary_of_Sales_by_Quarter" />
        <EntitySet Name="Summary_of_Sales_by_Years" EntityType="NorthwindModel.Summary_of_Sales_by_Year" />
        <AssociationSet Name="FK_Products_Categories" Association="NorthwindModel.FK_Products_Categories">
          <End Role="Categories" EntitySet="Categories" />
          <End Role="Products" EntitySet="Products" />
        </AssociationSet>
        <AssociationSet Name="FK_Orders_Customers" Association="NorthwindModel.FK_Orders_Customers">
          <End Role="Customers" EntitySet="Customers" />
          <End Role="Orders" EntitySet="Orders" />
        </AssociationSet>
        <AssociationSet Name="FK_Employees_Employees" Association="NorthwindModel.FK_Employees_Employees">
          <End Role="Employees" EntitySet="Employees" />
          <End Role="Employees1" EntitySet="Employees" />
        </AssociationSet>
        <AssociationSet Name="FK_Orders_Employees" Association="NorthwindModel.FK_Orders_Employees">
          <End Role="Employees" EntitySet="Employees" />
          <End Role="Orders" EntitySet="Orders" />
        </AssociationSet>
        <AssociationSet Name="FK_Order_Details_Orders" Association="NorthwindModel.FK_Order_Details_Orders">
          <End Role="Orders" EntitySet="Orders" />
          <End Role="Order_Details" EntitySet="Order_Details" />
        </AssociationSet>
        <AssociationSet Name="FK_Order_Details_Products" Association="NorthwindModel.FK_Order_Details_Products">
          <End Role="Products" EntitySet="Products" />
          <End Role="Order_Details" EntitySet="Order_Details" />
        </AssociationSet>
        <AssociationSet Name="FK_Orders_Shippers" Association="NorthwindModel.FK_Orders_Shippers">
          <End Role="Shippers" EntitySet="Shippers" />
          <End Role="Orders" EntitySet="Orders" />
        </AssociationSet>
        <AssociationSet Name="FK_Products_Suppliers" Association="NorthwindModel.FK_Products_Suppliers">
          <End Role="Suppliers" EntitySet="Suppliers" />
          <End Role="Products" EntitySet="Products" />
        </AssociationSet>
        <AssociationSet Name="FK_Territories_Region" Association="NorthwindModel.FK_Territories_Region">
          <End Role="Region" EntitySet="Regions" />
          <End Role="Territories" EntitySet="Territories" />
        </AssociationSet>
        <AssociationSet Name="CustomerCustomerDemo" Association="NorthwindModel.CustomerCustomerDemo">
          <End Role="CustomerDemographics" EntitySet="CustomerDemographics" />
          <End Role="Customers" EntitySet="Customers" />
        </AssociationSet>
        <AssociationSet Name="EmployeeTerritories" Association="NorthwindModel.EmployeeTerritories">
          <End Role="Employees" EntitySet="Employees" />
          <End Role="Territories" EntitySet="Territories" />
        </AssociationSet>
      </EntityContainer>
    </Schema>
  </edmx:DataServices>
</edmx:Edmx>


text:
<?php

namespace Google\Cloud\Vision\Tests\Snippet\Annotation;

use Google\Cloud\Core\Testing\Snippet\SnippetTestCase;
use Google\Cloud\Core\Testing\TestHelpers;
use Google\Cloud\Vision\Annotation\Face;
use Google\Cloud\Vision\Connection\ConnectionInterface;
use Google\Cloud\Vision\VisionClient;
use Prophecy\Argument;

/**
 * @group vision
 */
class FaceTest extends SnippetTestCase
{
    private $faceData;
    private $face;

    public function setUp()
    {
        $this->faceData = [
            'landmarks' => [[]],
            'boundingPoly' => 'testBoundingPoly',
            'fdBoundingPoly' => 'testFdBoundingPoly',
            "rollAngle" => 'testrollAngle',
            "panAngle" => 'testpanAngle',
            "tiltAngle" => 'testtiltAngle',
            "detectionConfidence" => 'testdetectionConfidence',
            "landmarkingConfidence" => 'testlandmarkingConfidence',
            "joyLikelihood" => 'VERY_LIKELY',
            "sorrowLikelihood" => 'VERY_LIKELY',
            "angerLikelihood" => 'VERY_LIKELY',
            "surpriseLikelihood" => 'VERY_LIKELY',
            "underExposedLikelihood" => 'VERY_LIKELY',
            "blurredLikelihood" => 'VERY_LIKELY',
            "headwearLikelihood" => 'VERY_LIKELY',
        ];

        $this->face = new Face($this->faceData);
    }

    public function testClass()
    {
        $snippet = $this->snippetFromClass(Face::class);

        $connection = $this->prophesize(ConnectionInterface::class);
        $connection->annotate(Argument::any())
            ->willReturn([
                'responses' => [
                    [
                        'faceAnnotations' => [
                            [
                                'landmarks' => [
                                    []
                                ]
                            ]
                        ]
                    ]
                ]
            ]);

        $vision = TestHelpers::stub(VisionClient::class);
        $vision->___setProperty('connection', $connection->reveal());

        $snippet->addLocal('vision', $vision);

        $snippet->replace(
            "__DIR__ . '/assets/family-photo.jpg'",
            "'php://temp'"
        );
        $snippet->replace(
            '$vision = new VisionClient();',
            ''
        );

        $res = $snippet->invoke('face');
        $this->assertInstanceOf(Face::class, $res->returnVal());
    }

    public function testInfo()
    {
        $snippet = $this->snippetFromMagicMethod(Face::class, 'info');
        $snippet->addLocal('face', $this->face);
        $this->assertEquals($this->faceData, $snippet->invoke('info')->returnVal());
    }

    public function testLandmarks()
    {
        $snippet = $this->snippetFromMethod(Face::class, 'landmarks');
        $snippet->addLocal('face', new Face([
            'landmarks' => [
                [
                    'type' => 'LEFT_EYE',
                    'position' => 'foo'
                ]
            ]
        ]));

        $res = $snippet->invoke('leftEye');
        $this->assertEquals('foo', $res->returnVal());
    }

    public function testBoundingpoly()
    {
        $snippet = $this->snippetFromMagicMethod(Face::class, 'boundingPoly');
        $snippet->addLocal('face', $this->face);

        $res = $snippet->invoke();
        $this->assertEquals($this->faceData['boundingPoly'], $res->output());
    }

    public function testFdboundingpoly()
    {
        $snippet = $this->snippetFromMagicMethod(Face::class, 'fdBoundingPoly');
        $snippet->addLocal('face', $this->face);

        $res = $snippet->invoke();
        $this->assertEquals($this->faceData['fdBoundingPoly'], $res->output());
    }

    public function testRollangle()
    {
        $snippet = $this->snippetFromMagicMethod(Face::class, 'rollAngle');
        $snippet->addLocal('face', $this->face);

        $res = $snippet->invoke();
        $this->assertEquals($this->faceData['rollAngle'], $res->output());
    }

    public function testPanangle()
    {
        $snippet = $this->snippetFromMagicMethod(Face::class, 'panAngle');
        $snippet->addLocal('face', $this->face);

        $res = $snippet->invoke();
        $this->assertEquals($this->faceData['panAngle'], $res->output());
    }

    public function testTiltangle()
    {
        $snippet = $this->snippetFromMagicMethod(Face::class, 'tiltAngle');
        $snippet->addLocal('face', $this->face);

        $res = $snippet->invoke();
        $this->assertEquals($this->faceData['tiltAngle'], $res->output());
    }

    public function testDetectionconfidence()
    {
        $snippet = $this->snippetFromMagicMethod(Face::class, 'detectionConfidence');
        $snippet->addLocal('face', $this->face);

        $res = $snippet->invoke();
        $this->assertEquals($this->faceData['detectionConfidence'], $res->output());
    }

    public function testLandmarkingconfidence()
    {
        $snippet = $this->snippetFromMagicMethod(Face::class, 'landmarkingConfidence');
        $snippet->addLocal('face', $this->face);

        $res = $snippet->invoke();
        $this->assertEquals($this->faceData['landmarkingConfidence'], $res->output());
    }

    public function testJoylikelihood()
    {
        $snippet = $this->snippetFromMagicMethod(Face::class, 'joyLikelihood');
        $snippet->addLocal('face', $this->face);

        $res = $snippet->invoke();
        $this->assertEquals($this->faceData['joyLikelihood'], $res->output());
    }

    public function testSorrowlikelihood()
    {
        $snippet = $this->snippetFromMagicMethod(Face::class, 'sorrowLikelihood');
        $snippet->addLocal('face', $this->face);

        $res = $snippet->invoke();
        $this->assertEquals($this->faceData['sorrowLikelihood'], $res->output());
    }

    public function testAngerlikelihood()
    {
        $snippet = $this->snippetFromMagicMethod(Face::class, 'angerLikelihood');
        $snippet->addLocal('face', $this->face);

        $res = $snippet->invoke();
        $this->assertEquals($this->faceData['angerLikelihood'], $res->output());
    }

    public function testSurpriselikelihood()
    {
        $snippet = $this->snippetFromMagicMethod(Face::class, 'surpriseLikelihood');
        $snippet->addLocal('face', $this->face);

        $res = $snippet->invoke();
        $this->assertEquals($this->faceData['surpriseLikelihood'], $res->output());
    }

    public function testUnderexposedlikelihood()
    {
        $snippet = $this->snippetFromMagicMethod(Face::class, 'underExposedLikelihood');
        $snippet->addLocal('face', $this->face);

        $res = $snippet->invoke();
        $this->assertEquals($this->faceData['underExposedLikelihood'], $res->output());
    }

    public function testBlurredlikelihood()
    {
        $snippet = $this->snippetFromMagicMethod(Face::class, 'blurredLikelihood');
        $snippet->addLocal('face', $this->face);

        $res = $snippet->invoke();
        $this->assertEquals($this->faceData['blurredLikelihood'], $res->output());
    }

    public function testHeadwearlikelihood()
    {
        $snippet = $this->snippetFromMagicMethod(Face::class, 'headwearLikelihood');
        $snippet->addLocal('face', $this->face);

        $res = $snippet->invoke();
        $this->assertEquals($this->faceData['headwearLikelihood'], $res->output());
    }

    /**
     * @dataProvider boolTests
     */
    public function testFaceBoolTests($method, $output)
    {
        $snippet = $this->snippetFromMethod(Face::class, $method);
        $snippet->addLocal('face', $this->face);

        $res = $snippet->invoke();
        $this->assertEquals($output, $res->output());
    }

    public function boolTests()
    {
        return [
            ['isJoyful', 'Face is Joyful'],
            ['isSorrowful', 'Face is Sorrowful'],
            ['isAngry', 'Face is Angry'],
            ['isSurprised', 'Face is Surprised'],
            ['isUnderExposed', 'Face is Under Exposed'],
            ['isBlurred', 'Face is Blurred'],
            ['hasHeadwear', 'Face has Headwear']
        ];
    }
}

redpajama_set_name: RedPajamaGithub


text:
"""Patch v1pysdk to use non-file credential stores"""

import logging
import httplib2
import urllib2

from urllib import urlencode
from urllib2 import HTTPBasicAuthHandler, HTTPCookieProcessor

from expiringdict import ExpiringDict
from functools import wraps
from urlparse import urlparse
from v1pysdk.client import V1Server
from v1pysdk.v1meta import V1Meta

try:
    from xml.etree import ElementTree
except ImportError:  # pragma: no cover
    from elementtree import ElementTree

logger = logging.getLogger(__name__)

class property_required(object):
    """Decorate a method to require certian properties be populated"""

    def __init__(self, *args):
        """Arguments to the decorator are proprties which must be non-None"""
        self.props = args

    def __call__(self, fn):
        """Called once durring decoration, returns the real func to be called"""

        @wraps(fn)
        def wrapped_fn(herself, *args, **kwargs):
            for prop in self.props:
                if getattr(herself, prop, None) is None:
                    msg = 'Required property {0} is missing from {1}'.format(prop, herself)
                    logger.error(msg)
                    raise ValueError(msg)
            return fn(herself, *args, **kwargs)

        return wrapped_fn

class HelgaV1Meta(V1Meta):  # pragma: no cover
    def __init__(self, *args, **kw):
        # Coppied from V1Meta, but use our own Server class
        self.server = HelgaOauthV1Server(*args, **kw)
        # ...And a cache that expires
        self.global_cache = ExpiringDict(max_len=100, max_age_seconds=10)
        self.dirtylist = []

    def asset_class(self, asset_type_name):
        Klass = super(HelgaV1Meta, self).asset_class(asset_type_name)
        # Always use the current V1Meta instance, not the closed in one
        Klass._v1_v1meta = self
        return Klass

class HelgaOauthV1Server(V1Server):
    "Accesses a V1 HTTP server as a client of the XML API protocol"
    API_PATH = "/rest-1.oauth.v1"

    def __init__(self, address="localhost", instance="VersionOne.Web", password='',
                 scheme="http", instance_url=None, credentials=None, use_password_as_token=False):
        # How hacky is this?
        self.logger = logging.getLogger(__name__ + '.v1_client')
        self.logger.setLevel(logging.INFO)
        # Do not make super call, base implementation requires username/password
        if instance_url:
            self.instance_url = instance_url
            parsed = urlparse(instance_url)
            self.address = parsed.netloc
            self.instance = parsed.path.strip('/')
            self.scheme = parsed.scheme
        else:
            self.address = address
            self.instance = instance.strip('/')
            self.scheme = scheme
            self.instance_url = self.build_url('')

        self.httpclient = None

        if credentials is not None:
            self.set_credentials(credentials)

        # Cheating to support tokens, since I know the internals
        if use_password_as_token:
            self.username = ''
            self.password = password
            self.use_password_as_token = use_password_as_token
            self._install_opener()
            # Become the parent class (for opener style get/post methods
            self.__class__ = V1Server

    def _install_opener(self):
        base_url = self.build_url('')
        password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
        password_manager.add_password(None, base_url, self.username, self.password)
        # only use the first Auth_handler to avoid the busted NTLM handler
        self.opener = urllib2.build_opener(HTTPBasicAuthHandler(password_manager))
        if self.use_password_as_token:
            self.opener.addheaders.append(('Authorization', 'Bearer ' + self.password))
        self.opener.add_handler(HTTPCookieProcessor())
        # No attempt is made to clear the cache when the creds change.
        # We assume all users have the same read-access.

    def set_credentials(self, creds):
        # If there are memory leaks, they might come from here
        self.httpclient = httplib2.Http()
        creds.authorize(self.httpclient)

    @property_required('httpclient')
    def http_get(self, url):
        return self.httpclient.request(url, method='GET')  # pragma: no cover

    @property_required('httpclient')
    def http_post(self, url, data=''):
        return self.httpclient.request(url, method='POST', body=data)  # pragma: no cover

    def fetch(self, path, query='', postdata=None):
        "Perform an HTTP GET or POST depending on whether postdata is present"
        url = self.build_url(path, query=query)
        try:
            if postdata is not None:
                if isinstance(postdata, dict):
                    postdata = urlencode(postdata)
                response, body = self.http_post(url, postdata)
            else:
                response, body = self.http_get(url)
            return (None, body)
        except httplib2.HttpLib2ErrorWithResponse, e:
            if e.response.status == 401:
                raise  # pragma: no cover
            body = e.content
            return (e, body)

    def get_asset_xml(self, asset_type_name, oid):
        path = self.API_PATH + '/Data/{0}/{1}'.format(asset_type_name, oid)
        return self.get_xml(path)

    def get_query_xml(self, asset_type_name, where=None, sel=None):
        path = self.API_PATH + '/Data/{0}'.format(asset_type_name)
        query = {}
        if where is not None:
                query['Where'] = where
        if sel is not None:
                query['sel'] = sel
        return self.get_xml(path, query=query)

    def execute_operation(self, asset_type_name, oid, opname):
        path = self.API_PATH + '/Data/{0}/{1}'.format(asset_type_name, oid)
        query = {'op': opname}
        return self.get_xml(path, query=query, postdata={})

    def get_attr(self, asset_type_name, oid, attrname):
        path = self.API_PATH + '/Data/{0}/{1}/{2}'.format(asset_type_name, oid, attrname)
        return self.get_xml(path)

    def create_asset(self, asset_type_name, xmldata, context_oid=''):
        body = ElementTree.tostring(xmldata, encoding="utf-8")
        query = {}
        if context_oid:
            query = {'ctx': context_oid}
        path = self.API_PATH + '/Data/{0}'.format(asset_type_name)
        return self.get_xml(path, query=query, postdata=body)

    def update_asset(self, asset_type_name, oid, update_doc):
        newdata = ElementTree.tostring(update_doc, encoding='utf-8')
        path = self.API_PATH + '/Data/{0}/{1}'.format(asset_type_name, oid)
        return self.get_xml(path, postdata=newdata)


text:
package msglnk.rest

import javax.ws.rs.ApplicationPath
import java.util
import scala.collection.JavaConverters._

@ApplicationPath("/rest")
class ApplicationConfig extends javax.ws.rs.core.Application {
    override def getClasses: util.Set[Class[_]] = {
        Set[Class[_]](classOf[Mail], classOf[Session], classOf[SessionReader], classOf[KeepAlive]).asJava
    }
}


text:
package nl.jqno.equalsverifier.api;

import java.util.*;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.EqualsVerifierReport;
import nl.jqno.equalsverifier.Func.Func1;
import nl.jqno.equalsverifier.Func.Func2;
import nl.jqno.equalsverifier.Warning;
import nl.jqno.equalsverifier.internal.checkers.*;
import nl.jqno.equalsverifier.internal.exceptions.MessagingException;
import nl.jqno.equalsverifier.internal.prefabvalues.FactoryCache;
import nl.jqno.equalsverifier.internal.reflection.SealedClassesHelper;
import nl.jqno.equalsverifier.internal.util.*;
import nl.jqno.equalsverifier.internal.util.Formatter;

/**
 * Helps to construct an {@link EqualsVerifier} test with a fluent API.
 *
 * @param <T> The class under test.
 */
public class SingleTypeEqualsVerifierApi<T> implements EqualsVerifierApi<T> {

    private final Class<T> type;
    private final Set<String> actualFields;

    private EnumSet<Warning> warningsToSuppress = EnumSet.noneOf(Warning.class);
    private boolean usingGetClass = false;
    private boolean hasRedefinedSuperclass = false;
    private Class<? extends T> redefinedSubclass = null;
    private FactoryCache factoryCache = new FactoryCache();
    private CachedHashCodeInitializer<T> cachedHashCodeInitializer = CachedHashCodeInitializer.passthrough();
    private Set<String> allExcludedFields = new HashSet<>();
    private Set<String> allIncludedFields = new HashSet<>();
    private Set<String> nonnullFields = new HashSet<>();
    private Set<String> ignoredAnnotationClassNames = new HashSet<>();
    private List<T> equalExamples = new ArrayList<>();
    private List<T> unequalExamples = new ArrayList<>();

    /**
     * Constructor.
     *
     * @param type The class for which the {@code equals} method should be tested.
     */
    public SingleTypeEqualsVerifierApi(Class<T> type) {
        this.type = type;
        actualFields = FieldNameExtractor.extractFieldNames(type);
    }

    /**
     * Constructor.
     *
     * @param type The class for which the {@code equals} method should be tested.
     * @param warningsToSuppress A list of warnings to suppress in {@code EqualsVerifier}.
     * @param factoryCache Factories that can be used to create values.
     * @param usingGetClass Whether {@code getClass} is used in the implementation of the {@code
     *     equals} method, instead of an {@code instanceof} check.
     */
    public SingleTypeEqualsVerifierApi(
        Class<T> type,
        EnumSet<Warning> warningsToSuppress,
        FactoryCache factoryCache,
        boolean usingGetClass
    ) {
        this(type);
        this.warningsToSuppress = EnumSet.copyOf(warningsToSuppress);
        this.factoryCache = this.factoryCache.merge(factoryCache);
        this.usingGetClass = usingGetClass;
    }

    /**
     * Constructor, only to be called by {@link RelaxedEqualsVerifierApi#andUnequalExamples(Object,
     * Object[])}.
     */
    /* package protected */SingleTypeEqualsVerifierApi(
        Class<T> type,
        List<T> equalExamples,
        List<T> unequalExamples
    ) {
        this(type);
        this.equalExamples = equalExamples;
        this.unequalExamples = unequalExamples;
    }

    /** {@inheritDoc} */
    @Override
    public SingleTypeEqualsVerifierApi<T> suppress(Warning... warnings) {
        Collections.addAll(warningsToSuppress, warnings);
        Validations.validateWarnings(warningsToSuppress);
        Validations.validateWarningsAndFields(
            warningsToSuppress,
            allIncludedFields,
            allExcludedFields
        );
        Validations.validateNonnullFields(nonnullFields, warningsToSuppress);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public <S> SingleTypeEqualsVerifierApi<T> withPrefabValues(Class<S> otherType, S red, S blue) {
        PrefabValuesApi.addPrefabValues(factoryCache, otherType, red, blue);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public <S> SingleTypeEqualsVerifierApi<T> withGenericPrefabValues(
        Class<S> otherType,
        Func1<?, S> factory
    ) {
        PrefabValuesApi.addGenericPrefabValues(factoryCache, otherType, factory);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public <S> SingleTypeEqualsVerifierApi<T> withGenericPrefabValues(
        Class<S> otherType,
        Func2<?, ?, S> factory
    ) {
        PrefabValuesApi.addGenericPrefabValues(factoryCache, otherType, factory);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public SingleTypeEqualsVerifierApi<T> usingGetClass() {
        this.usingGetClass = true;
        return this;
    }

    /**
     * Signals that all given fields are not relevant for the {@code equals} contract. {@code
     * EqualsVerifier} will not fail if one of these fields does not affect the outcome of {@code
     * equals}, but it will fail if one of these fields does affect the outcome of {@code equals}.
     *
     *
Note that these fields will still be used to test for null-ness, among other things.
     *
     * @param fields Fields that should be ignored.
     * @return {@code this}, for easy method chaining.
     */
    public SingleTypeEqualsVerifierApi<T> withIgnoredFields(String... fields) {
        return withFieldsAddedAndValidated(allExcludedFields, Arrays.asList(fields));
    }

    /**
     * Signals that all given fields, and only the given fields, are relevant for the
     * {@code equals} contract. {@code EqualsVerifier} will fail if one of these fields does not
     * affect the outcome of {@code equals}, and it will fail if a field that isn't listed here,
     * does affect the outcome of {@code equals}.
     *
     * @param fields Fields that should be ignored.
     * @return {@code this}, for easy method chaining.
     */
    public SingleTypeEqualsVerifierApi<T> withOnlyTheseFields(String... fields) {
        return withFieldsAddedAndValidated(allIncludedFields, Arrays.asList(fields));
    }

    private SingleTypeEqualsVerifierApi<T> withFieldsAddedAndValidated(
        Set<String> collection,
        List<String> specifiedFields
    ) {
        collection.addAll(specifiedFields);

        Validations.validateFields(allIncludedFields, allExcludedFields);
        Validations.validateFieldNamesExist(type, specifiedFields, actualFields);
        Validations.validateWarningsAndFields(
            warningsToSuppress,
            allIncludedFields,
            allExcludedFields
        );
        return this;
    }

    /**
     * Signals that all given fields can never be null, and {@code EqualsVerifier} therefore doesn't
     * have to verify that proper null checks are in place for these fields.
     *
     *
This can be used instead of {link #suppress(Warning...)}, which provides the same
     * behaviour for all fields, when only some fields are never null but others are.
     *
     * @param fields Fields that can never be null.
     * @return {@code this}, for easy method chaining.
     */
    public SingleTypeEqualsVerifierApi<T> withNonnullFields(String... fields) {
        List<String> fieldsAsList = Arrays.asList(fields);
        nonnullFields.addAll(fieldsAsList);
        Validations.validateFieldNamesExist(type, fieldsAsList, actualFields);
        Validations.validateNonnullFields(nonnullFields, warningsToSuppress);
        return this;
    }

    /**
     * Signals that all given annotations are to be ignored by EqualsVerifier.
     *
     *
For instance, EqualsVerifier normally doesn't perform null verifications on fields marked
     * with an {@code @Nonnull} annotation. However, if this method is called with a {@code
     * Nonnull.class} parameter, the null verifications will be performed after all.
     *
     * @param annotations Annotations to ignore.
     * @return {@code this}, for easy method chaining.
     */
    public SingleTypeEqualsVerifierApi<T> withIgnoredAnnotations(Class<?>... annotations) {
        Validations.validateGivenAnnotations(annotations);
        for (Class<?> ignoredAnnotation : annotations) {
            ignoredAnnotationClassNames.add(ignoredAnnotation.getCanonicalName());
        }
        return this;
    }

    /**
     * Signals that T is part of an inheritance hierarchy where {@code equals} is overridden. Call
     * this method if T has overridden {@code equals} and {@code hashCode}, and one or more of T's
     * superclasses have as well.
     *
     *
T itself does not necessarily have to have subclasses that redefine {@code equals} and
     * {@code hashCode}.
     *
     * @return {@code this}, for easy method chaining.
     */
    public SingleTypeEqualsVerifierApi<T> withRedefinedSuperclass() {
        this.hasRedefinedSuperclass = true;
        return this;
    }

    /**
     * Supplies a reference to a subclass of T in which {@code equals} is overridden. Calling this
     * method is mandatory if {@code equals} is not final and a strong verification is performed.
     *
     *
Note that, for each subclass that overrides {@code equals}, {@link EqualsVerifier} should
     * be used as well to verify its adherence to the contracts.
     *
     * @param subclass A subclass of T for which no instance can be equal to any instance of T.
     * @return {@code this}, for easy method chaining.
     * @see Warning#STRICT_INHERITANCE
     */
    public SingleTypeEqualsVerifierApi<T> withRedefinedSubclass(Class<? extends T> subclass) {
        this.redefinedSubclass = subclass;
        return this;
    }

    /**
     * Signals that T caches its hashCode, instead of re-calculating it each time the {@code
     * hashCode()} method is called.
     *
     *
There are 3 conditions to verify cached hashCodes:
     *
     *
First, the class under test must have a private int field that contains the cached
     * hashCode.
     *
     *
Second, the class under test must have a private method that calculates the hashCode. The
     * method must return an int and may not take any parameters. It should be used by the
     * constructor or the hashCode method of the class under test to initialize the cached hashCode.
     * This may lead to slightly awkward production code, but unfortunately, it is necessary for
     * EqualsVerifier to verify that the hashCode is correct.
     *
     *
Finally, only immutable objects can be verified. In other words, {@code
     * withCachedHashCode} can not be used when {@link Warning#NONFINAL_FIELDS} is suppressed.
     *
     * @param cachedHashCodeField The name of the field which stores the cached hash code.
     * @param calculateHashCodeMethod The name of the method which recomputes the hash code. It
     *     should return an int and take no parameters.
     * @param example An instance of the class under test, to verify that the hashCode has been
     *     initialized properly.
     * @return {@code this}, for easy method chaining.
     */
    public SingleTypeEqualsVerifierApi<T> withCachedHashCode(
        String cachedHashCodeField,
        String calculateHashCodeMethod,
        T example
    ) {
        cachedHashCodeInitializer =
            new CachedHashCodeInitializer<>(
                type,
                cachedHashCodeField,
                calculateHashCodeMethod,
                example
            );
        return this;
    }

    /**
     * Signals that T uses Lombok to cache its hashCode, instead of re-calculating it each time the
     * {@code hashCode()} method is called.
     *
     * @param example An instance of the class under test, to verify that the hashCode has been
     *     initialized properly.
     * @return {@code this}, for easy method chaining.
     * @see #withCachedHashCode(String, String, Object)
     */
    public SingleTypeEqualsVerifierApi<T> withLombokCachedHashCode(T example) {
        cachedHashCodeInitializer = CachedHashCodeInitializer.lombokCachedHashcode(example);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public SingleTypeEqualsVerifierApi<T> withResetCaches() {
        ObjenesisWrapper.reset();
        return this;
    }

    /**
     * Performs the verification of the contracts for {@code equals} and {@code hashCode} and throws
     * an {@link AssertionError} if there is a problem.
     *
     * @throws AssertionError If the contract is not met, or if {@link EqualsVerifier}'s
     *     preconditions do not hold.
     */
    public void verify() {
        try {
            performVerification();
        } catch (MessagingException e) {
            throw new AssertionError(buildErrorMessage(e.getDescription(), true), e);
        } catch (Throwable e) {
            throw new AssertionError(buildErrorMessage(e.getMessage(), true), e);
        }
    }

    /**
     * Performs the verification of the contracts for {@code equals} and {@code hashCode} and
     * returns an {@link EqualsVerifierReport} with the results of the verification.
     *
     * @return An {@link EqualsVerifierReport} that indicates whether the contract is met and
     *     whether {@link EqualsVerifier}'s preconditions hold.
     */
    public EqualsVerifierReport report() {
        return report(true);
    }

    public EqualsVerifierReport report(boolean showUrl) {
        try {
            performVerification();
            return EqualsVerifierReport.success(type);
        } catch (MessagingException e) {
            return EqualsVerifierReport.failure(
                type,
                buildErrorMessage(e.getDescription(), showUrl),
                e
            );
        } catch (Throwable e) {
            return EqualsVerifierReport.failure(
                type,
                buildErrorMessage(e.getMessage(), showUrl),
                e
            );
        }
    }

    private String buildErrorMessage(String description, boolean showUrl) {
        String message = description == null ? "<no message>" : description;
        return Formatter
            .of(
                "EqualsVerifier found a problem in class %%.\n-> %%\n\n" + WEBSITE_URL,
                type.getName(),
                message
            )
            .format();
    }

    private void performVerification() {
        if (type.isEnum() || type.isInterface() || SealedClassesHelper.isSealed(type)) {
            return;
        }
        Validations.validateClassCanBeVerified(type);

        Configuration<T> config = buildConfig();
        Validations.validateProcessedAnnotations(
            type,
            config.getAnnotationCache(),
            warningsToSuppress,
            allIncludedFields,
            allExcludedFields
        );

        verifyWithoutExamples(config);
        verifyWithExamples(config);
    }

    private Configuration<T> buildConfig() {
        return Configuration.build(
            type,
            allExcludedFields,
            allIncludedFields,
            nonnullFields,
            cachedHashCodeInitializer,
            hasRedefinedSuperclass,
            redefinedSubclass,
            usingGetClass,
            warningsToSuppress,
            factoryCache,
            ignoredAnnotationClassNames,
            actualFields,
            equalExamples,
            unequalExamples
        );
    }

    private void verifyWithoutExamples(Configuration<T> config) {
        Checker[] checkers = {
            new SignatureChecker<>(config),
            new AbstractDelegationChecker<>(config),
            new NullChecker<>(config),
            new RecordChecker<>(config),
            new CachedHashCodeChecker<>(config)
        };

        for (Checker checker : checkers) {
            checker.check();
        }
    }

    private void verifyWithExamples(Configuration<T> config) {
        Checker[] checkers = {
            new ExamplesChecker<>(config),
            new HierarchyChecker<>(config),
            new FieldsChecker<>(config),
            new MapEntryHashCodeRequirementChecker<>(config)
        };

        for (Checker checker : checkers) {
            checker.check();
        }
    }
}


text:
/* AUTO-GENERATED FILE.  DO NOT MODIFY.
 *
 * This class was automatically generated by the
 * aapt tool from the resource data it found.  It
 * should not be modified by hand.
 */

package mit.six.ui.travelbook;

public final class R {
    public static final class attr {
    }
    public static final class drawable {
        public static final int camera=0x7f020000;
        public static final int ic_launcher=0x7f020001;
        public static final int star=0x7f020002;
        public static final int stripes=0x7f020003;
        public static final int stripes_repeat=0x7f020004;
    }
    public static final class id {
        public static final int contacts_button=0x7f060008;
        public static final int contacts_list=0x7f06000c;
        public static final int entry_date_edit=0x7f060006;
        public static final int entry_list=0x7f06000f;
        public static final int entry_text_edit=0x7f06000b;
        public static final int map_view=0x7f06000d;
        public static final int menu_delete=0x7f060003;
        public static final int menu_edit=0x7f060002;
        public static final int menu_save=0x7f060004;
        public static final int menu_share=0x7f060000;
        public static final int menu_view=0x7f060001;
        public static final int navigate_between_posts=0x7f060010;
        public static final int photo_button=0x7f060007;
        public static final int photo_list=0x7f06000a;
        public static final int scroll_view=0x7f06000e;
        public static final int view_edit=0x7f060005;
        public static final int view_photo_scroll=0x7f060009;
    }
    public static final class integer {
        public static final int db_version=0x7f050000;
    }
    public static final class layout {
        public static final int edit=0x7f030000;
        public static final int map=0x7f030001;
        public static final int map_horizontal=0x7f030002;
        public static final int view=0x7f030003;
    }
    public static final class string {
        public static final int add_entry=0x7f040004;
        public static final int app_description=0x7f040002;
        public static final int app_name=0x7f040001;
        public static final int db_name=0x7f040000;
        public static final int hello=0x7f040003;
    }
}


text:
Ti=Record

0.sec=A "record" is one or more statements made in a context.  We can express this as:

1.sec=One or more Key/Values, and

2.sec=One or more links to a context (other Records).

=[G/Z/ol/s2]


text:
package controllers.api;

import com.avaje.ebean.ExpressionList;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import models.ArticleCollection;
import models.BackendBasicModel;
import models.Language;
import play.mvc.Controller;
import play.mvc.Result;
import utils.TypeAheadDatum;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Roger
 * Date: 10.11.13
 * Time: 03:22
 */
public class ArticleCollectionAPIController extends Controller {

    public static Result list() throws JsonProcessingException {

        ObjectMapper objectMapper = new ObjectMapper();

        return ok(objectMapper.writeValueAsString(ArticleCollection.find.all()));
    }

    public static Result lookup() throws JsonProcessingException {

        String querystring = request().getQueryString("q");
        String limit = request().getQueryString("limit");

        Integer rowcount = (limit != null && !limit.trim().isEmpty() ? Integer.parseInt(limit) : 100);

        ExpressionList<ArticleCollection> searchexpression = ArticleCollection.find.fetch("languages").where().ilike("languages.name", "%" + querystring + "%").ne("rowStatus", "d").ne("rowStatus", "s");

        List<ArticleCollection> addressList = ( rowcount != null && rowcount > 0 ? searchexpression.setMaxRows(rowcount).findList() : searchexpression.findList() );

        List<TypeAheadDatum> nodeList = new ArrayList<TypeAheadDatum>();

        for(ArticleCollection ArticleCollection : addressList) {

            TypeAheadDatum datum = new TypeAheadDatum();
            datum.value = ArticleCollection.getName(Language.getEnglish());
            datum.tokens.add(ArticleCollection.getName(Language.getEnglish()));
            datum.id = ArticleCollection.id;

            nodeList.add(datum);
        }

        ObjectMapper objectMapper = new ObjectMapper();

        return ok(objectMapper.writeValueAsString(nodeList));
    }

    public static Result get(Long id) throws JsonProcessingException {

        if(id == null || id <= 0) {
            return badRequest();
        }

        ArticleCollection addressFunctionToLoad = ArticleCollection.find.byId(id);
        if(addressFunctionToLoad == null) {
            return notFound("ArticleCollection with ID " + id.toString() + " was not found!");
        }

        ObjectMapper objectMapper = new ObjectMapper();

        return ok(objectMapper.writeValueAsString(addressFunctionToLoad));

    }

    public static Result save() throws JsonProcessingException, ParseException {

        if(request().body() == null) {
            return badRequest("body ist null");
        }

        if( request().body().asJson() == null) {
            return badRequest("body json ist null");
        }

        JsonNode body = request().body().asJson();

        if(body.isObject()) {

            Long id = ( body.get("id") == null ? null : body.get("id").asLong());
            ArticleCollection addressFunctionToSave = null;

            if(id != null && id > 0) {
                addressFunctionToSave = ArticleCollection.find.byId(id);
                if(addressFunctionToSave == null) {
                    return notFound("ArticleCollection with ID " + id.toString() + " was not found!");
                }
            }
            else {
                addressFunctionToSave = new ArticleCollection();
                addressFunctionToSave.rowStatus = BackendBasicModel.RowStatus.ACTIVE;
            }

            addressFunctionToSave.setName(Language.getEnglish(), body.get("name").asText());

            addressFunctionToSave.save();

            ObjectMapper objectMapper = new ObjectMapper();

            return ok(objectMapper.writeValueAsString(addressFunctionToSave));
        }

        return badRequest("body JSON is not an object!");
    }

    public static Result delete() {
        if(request().body() == null) {
            return badRequest("body ist null");
        }

        if( request().body().asJson() == null) {
            return badRequest("body json ist null");
        }

        JsonNode body = request().body().asJson();

        if(body.isObject()) {

            Long id = ( body.get("id") == null ? null : body.get("id").asLong());

            if(id == null || id <= 0) {
                // not saved address dont have to be deleted
                return ok();
            }

            ArticleCollection addressToDelete = ArticleCollection.find.byId(id);
            if(addressToDelete == null) {
                return notFound("Address with ID " + id.toString() + " was not found!");
            }

            addressToDelete.delete();

            return ok("{ \"message\":\"ArticleCollection gelöscht!\"}");
        }

        return badRequest("body JSON is not an object!");
    }
}