예제 #1
0
        public Deals(
            CommonDomainObjects commonDomainObjects,
            Roles roles,
            RoleIndividuals roleIndividuals,
            LegalEntities legalEntities,
            Parties parties,
            Validation validation
            ) : base(
                "Deals",
                commonDomainObjects,
                roles,
                roleIndividuals,
                legalEntities,
                parties,
                validation)
        {
            DealType = this.DeclareClass <DealType>();
            DealType.SubClassOf(commonDomainObjects.Named);
            Deal = this.DeclareClass <Deal>();
            Deal.SubClassOf(commonDomainObjects.Named);
            Type        = Deal.DeclareObjectProperty <Deal, DealType>(deal => deal.Type);
            Parties     = Deal.DeclareObjectProperty <Deal, PartyInRole>(deal => deal.Parties);
            Classifiers = Deal.DeclareObjectProperty <Deal, Classifier>(deal => deal.Classifiers);
            Confers     = Deal.DeclareObjectProperty <Deal, Commitment>(deal => deal.Confers);
            Borrowers   = Deal.DeclareObjectProperty <Deal, PartyInRole>(
                "Borrowers",
                deal => deal.Parties.Where(dealParty => dealParty.Role.Id == DealRoleIdentifier.Borrower));
            Sponsors = Deal.DeclareObjectProperty <Deal, Sponsor>(
                "Sponsors",
                deal => deal.Parties.Where(dealParty => dealParty.Role.Id == DealRoleIdentifier.Sponsor).Cast <Sponsor>());
            this.Exclusivity = Deal.DeclareObjectProperty <Deal, ExclusivityClassifier>(
                "Exclusivity",
                deal => deal.Classifiers.OfType <ExclusivityClassifier>().FirstOrDefault());

            Deal.SubClassOf(
                new DataSomeValuesFrom(
                    commonDomainObjects.Name,
                    new DataComplementOf(new DataOneOf(string.Empty))))
            .Annotate(
                validation.Restriction,
                0);
            Deal.SubClassOf(this.Exclusivity.ExactCardinality(1))
            .Annotate(
                validation.Restriction,
                0);

            LenderParty   = this.DeclareClass("LenderParty");
            AdvisorParty  = this.DeclareClass("AdvisorParty");
            BorrowerParty = this.DeclareClass("BorrowerParty");
            SponsorParty  = this.DeclareClass("SponsorParty");

            LenderParty.SubClassOf(parties.PartyInRole);
            AdvisorParty.SubClassOf(parties.PartyInRole);
            BorrowerParty.SubClassOf(parties.PartyInRole);
            SponsorParty.SubClassOf(parties.PartyInRole);

            LenderParty.Define(parties.Role.HasValue(roleIndividuals.Lender));
            AdvisorParty.Define(parties.Role.HasValue(roleIndividuals.Advisor));
            BorrowerParty.Define(parties.Role.HasValue(roleIndividuals.Borrower));
            SponsorParty.Define(parties.Role.HasValue(roleIndividuals.Sponsor));;

            Sponsor = this.DeclareClass <Sponsor>();
            Sponsor.SubClassOf(SponsorParty);
            Equity = Sponsor.DeclareDataProperty <Sponsor, decimal?>(sponsor => sponsor.Equity);
            Sponsor
            .SubClassOf(Equity.ExactCardinality(1))
            .Annotate(
                validation.Restriction,
                0);

            Bank             = legalEntities.LegalEntity.DeclareNamedIndividual("Bank");
            BankParty        = this.DeclareClass("BankParty");
            BankLenderParty  = this.DeclareClass("BankLenderParty");
            BankAdvisorParty = this.DeclareClass("BankAdvisorParty");
            BankParty.Define(parties.Organisation.HasValue(Bank));
            BankLenderParty.Define(LenderParty.Intersect(BankParty));
            BankAdvisorParty.Define(AdvisorParty.Intersect(BankParty));

            BankParty.SubClassOf(parties.PartyInRole);

            KeyCounterpartyRole = this.DeclareClass("KeyCounterpartyRole");
            KeyCounterparty     = this.DeclareClass("KeyCounterparty");
            KeyCounterparty.SubClassOf(parties.PartyInRole);
            KeyCounterparty.Define(new ObjectSomeValuesFrom(parties.Role, KeyCounterpartyRole));

            Debt = this.DeclareClass("Debt");
            Debt.SubClassOf(Deal);
            Debt.SubClassOf(Parties.ExactCardinality(1, BankLenderParty));
            Debt.SubClassOf(Borrowers.MinCardinality(1))
            .Annotate(
                validation.Restriction,
                0);

            new DisjointClasses(
                this,
                Deal,
                DealType,
                parties.PartyInRole,
                commonDomainObjects.Classifier);

            var ExclusivityClassifier = this.DeclareClass <ExclusivityClassifier>();

            ExclusivityClassifier.SubClassOf(commonDomainObjects.Classifier);
            Deal.SubClassOf(Classifiers.ExactCardinality(1, ExclusivityClassifier))
            .Annotate(
                validation.Restriction,
                0)
            .Annotate(
                validation.SubPropertyName,
                "Exclusivity");

            var NotExclusive = ExclusivityClassifier.DeclareNamedIndividual("NotExclusive");

            NotExclusive.Value(commonDomainObjects.Id, ExclusivityClassifierIdentifier.No);
            var Exclusive = ExclusivityClassifier.Intersect(new ObjectOneOf(NotExclusive).Complement());

            var ExclusiveDeal = this.DeclareClass("ExclusiveDeal");

            ExclusiveDeal.SubClassOf(Deal);
            var intermediate = this.DeclareClass("Intermediate");

            intermediate.Define(new ObjectSomeValuesFrom(Classifiers, Exclusive));
            ExclusiveDeal.Define(new ObjectIntersectionOf(intermediate));

            var Exclusivity = this.DeclareClass <Exclusivity>();
            var Date        = Exclusivity.DeclareDataProperty <Exclusivity, DateTime?>(exclusivity => exclusivity.Date);

            Date.Range(ReservedVocabulary.DateTime)
            .Annotate(
                validation.RangeValidated,
                null);
        }