Skip to content

Instantly share code, notes, and snippets.

@stdray
Created January 22, 2015 21:28
Show Gist options
  • Select an option

  • Save stdray/551672501c811243de3c to your computer and use it in GitHub Desktop.

Select an option

Save stdray/551672501c811243de3c to your computer and use it in GitHub Desktop.
using Nemerle;
using Nemerle.Collections;
using Nemerle.Text;
using Nemerle.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using NBox.Data;
namespace NBox.Data.XsdProvider.Tests
{
using Spark.Marketing.Ru.XMLSchema.Plans;
using Spark.Marketing.Ru.XMLSchema.SharedCore;
using Spark.Marketing.Ru.XMLSchema.SharedSystem;
using ZakupkiV1 = Zakupki.Gov.Ru.Oos.Types.V1;
using NBox.Data.Combinators;
using Common;
public class PlanGraphMapper
{
public MapPlanGraphType(src : ZakupkiV1.zfcs_tenderPlanType) : PlanGraphType
{
entity() <-
{
Customer <-
{
Person <-
{
GeneralInfo <-
{
def customer = src.customerInfo.customer;
INN = customer.INN;
KPP = customer.KPP;
PhysicalAddress = customer.factAddress;
PostalAddress = customer.postAddress;
RussianFullName = customer.fullName;
RussianShortName = customer.shortName;
}
}
PersonContacts = array
[
entity() <-
{
ContactInfo <-
{
def contact = src.responsibleContactInfo;
ContactFio = contact.lastName + " " + contact.firstName + " " + contact.middleName;
Email = contact.email;
Fax = array [ contact.fax ];
FirstName = contact.firstName;
LastName = contact.lastName;
MiddleName = contact.middleName;
Phone = array [ contact.phone ];
}
}
];
}
IdentityInfo <-
{
PlanGraphIdentity = src.commonInfo.planNumber;
}
MainInfo <-
{
Description = src.commonInfo.description;
DatesInfo <-
{
ConfirmDate = date(src.commonInfo.confirmDate);
CreationDate = date(src.commonInfo.createDate);
}
Year = str(src.commonInfo.year);
Description = src.commonInfo.description;
}
PublishInfo <-
{
Date = date(src.commonInfo.publishDate);
ModificationInfo = src.printForm.url;
Version = str(src.commonInfo.versionNumber);
}
StateInfo <-
{
State = PlanGraphTypeStateInfoState.Published;
StatePublishDate = date(src.commonInfo.publishDate);
}
}
}
public MapPlanGraphPositions(src : ZakupkiV1.zfcs_tenderPlanType) : array[PlanGraphPositionType]
{
from pos in src.providedPurchases.positions
select entity() <-
{
Conditions <-
{
Advance = pos.purchaseConditions.advance;
ContractFinanceCondition <-
{
Amount = tryParseDecimal(pos.purchaseConditions.contractFinCondition?.amount);
Procedure = pos.purchaseConditions.contractFinCondition?.procedure;
}
Graph <-
{
def graph = pos.purchaseConditions.purchaseGraph;
ContractExecutionDate = date(graph.contractExecutionTerm);
ContractExecutionStages = graph.contractExecutionStages;
Periodicity = graph.periodicity;
TenderPlacingDate = date(graph.purchasePlacingTerm);
}
Preferences =
from pref in pos.purchaseConditions.preferensesRequirement?.preferenses
select entity() <-
{
Preference <-
{
Code = str(pref.code);
Name = pref.name
}
Value = decimal(pref.prefValue);
}
Prohibitions = pos.purchaseConditions.prohibitions;
Requirements =
from req in pos.purchaseConditions.preferensesRequirement?.requirements
select entity() <-
{
Content = req.content;
Requirement <-
{
Code = str(req.code);
Name = req.name;
}
}
TenderFinanceCondition <-
{
Amount = tryParseDecimal(pos.purchaseConditions.purchaseFinCondition?.amount);
Procedure = pos.purchaseConditions.purchaseFinCondition?.procedure;
}
}
IdentityInfo <-
{
PlanGraphIdentity = src.commonInfo.planNumber;
PlanGraphPositionIdentity = pos.commonInfo.positionNumber;
}
MainInfo <-
{
Currency <-
{
Code = pos.commonInfo.contractCurrency.code;
Name = pos.commonInfo.contractCurrency.name
}
Name = pos.commonInfo.contractSubjectName;
PlacingWay <-
{
Code = pos.commonInfo.placingWay.code;
Name = pos.commonInfo.placingWay.name;
}
StartPrice = tryParseDecimal(pos.commonInfo.contractMaxPrice);
}
OptionalInfo <-
{
KBKs = match(pos.commonInfo.Item)
{
| null => null;
| amountKBKs is ZakupkiV1.zfcs_tenderPlanPositionKBKsType =>
from kbk in amountKBKs.KBK
select kbk.code;
| amountKBKsYears is ZakupkiV1.zfcs_PositionKBKsYearsType =>
from kbk in amountKBKsYears.KBK
select kbk.code;
}
KOSGUs = match(pos.commonInfo.Item1)
{
| null => null;
| amountKOSGUs is ZakupkiV1.zfcs_tenderPlanPositionKOSGUsType =>
from kosgu in amountKOSGUs.KOSGU
select entity() <-
{
Code = kosgu.code;
}
| amountKOSGUsYears is ZakupkiV1.zfcs_PositionKOSGUsYearsType =>
from kosgu in amountKOSGUsYears.KOSGU
select entity() <-
{
Code = kosgu.code;
}
}
OKVEDs =
from okved in pos.commonInfo.OKVEDs
select entity() <-
{
Code = okved.code;
Name = okved.name;
}
Payments = tryParseDecimal(pos.commonInfo.payments);
PublicDiscussionRequired = pos.commonInfo.noPublicDiscussion :> bool?;
}
OutcomeIndicators <-
{
def indicators = src.providedPurchases.finalPositions.outcomeIndicators;
SumContractMaxPrice = tryParseDecimal(indicators.sumContractMaxPrice);
SumPaymentsTotal = tryParseDecimal(indicators.sumPaymentsTotal);
SumPushaseRequest = tryParseDecimal(indicators.sumPushaseRequest);
SumPushaseSingleSupplier4 = tryParseDecimal(indicators.sumPushaseSingleSupplier4);
SumPushaseSingleSupplier5 = tryParseDecimal(indicators.sumPushaseSingleSupplier5);
SumPushaseSmallBusiness = tryParseDecimal(indicators.sumPushaseSmallBusiness);
}
Products =
from product in pos.products
select entity() <-
{
AmountUnit <-
{
Code = product.OKEI.code;
Name = product.OKEI.name;
}
Classifiers = array
[
entity() <-
{
Code = product.OKPD.code;
Name = product.OKPD.name;
}
];
CurrentYearQuantity = tryParseDecimal(product.quantityCurrentYear);
InternationalName = product.internationalName;
MinRequirements = product.minRequirement;
Name = product.name;
SumPrice = tryParseDecimal(product.sumMax);
TotalQuantity = tryParseDecimal(product.quantity);
UnitPrice = tryParseDecimal(product.price);
}
PublishInfo <-
{
Date = date(pos.commonInfo.positionPublishDate);
ModificationInfo = pos.commonInfo.positionModification?.changeReason
+ Environment.NewLine
+ pos.commonInfo.positionModification?.additionalInfo;
Url = src.printForm.url;
}
}
}
public MapPlanGraphCancel(planGrap : PlanGraphType, cancel : ZakupkiV1.zfcs_tenderPlanCancelType) : PlanGraphType
{
planGrap <<-
{
Customer <-
{
Person <-
{
GeneralInfo <-
{
def customer = cancel.customerInfo;
INN = customer.INN;
KPP = customer.KPP;
PhysicalAddress = customer.factAddress;
PostalAddress = customer.postAddress;
RussianFullName = customer.fullName;
RussianShortName = customer.shortName;
}
}
}
MainInfo <-
{
Year = str(cancel.year);
}
PublishInfo <-
{
Url = cancel.printForm.url;
Version = str(cancel.versionNumber);
}
StateInfo <-
{
CancelledReason = cancel.description;
State = PlanGraphTypeStateInfoState.Cancelled;
StatePublishDate = date(cancel.cancelDate);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment