Skip to content

Package: ICQueryGenerator

ICQueryGenerator

nameinstructionbranchcomplexitylinemethod
ICQueryGenerator()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /**
2: * Copyright (C) 2016 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.model;
16:
17:
18: class ICQueryGenerator /*implements IntegrityConstraintVisitor*/ {
19: //
20: //        final OWL2QueryFactory<OWLObject> f;
21: //        final OWL2Ontology<OWLObject> ont;
22: //        OWL2Query<OWLObject> query;
23: //
24: //        public ICQueryGenerator(
25: //                        final OWL2QueryFactory<OWLObject> f,
26: //                        final OWL2Ontology<OWLObject> ont) {
27: //                this.f = f;
28: //                this.ont = ont;
29: //                this.query = f.createQuery(ont);
30: //        }
31: //
32: //        
33: //        public void visit(DataRangeConstraint cpc) {
34: //                Variable<OWLObject> x = f.variable("x");
35: //                Variable<OWLObject> y = f.variable("y");
36: //
37: //                final OWL2Query<OWLObject> not = f.createQuery(ont);
38: //                not.addDistVar(y);
39: //
40: //                query = query.Type(f.wrap(cpc.getOWLClass()), x).PropertyValue(
41: //                                f.wrap(cpc.getProperty()), x, y).Not(
42: //                                not.Type(f.wrap(cpc.getRange()), y));
43: //                query.addDistVar(x);
44: //                query.addDistVar(y);
45: //        }
46: //
47: //        
48: //        public void visit(DataDomainConstraint cpc) {
49: //                Variable<OWLObject> x = f.variable("x");
50: //                Variable<OWLObject> y = f.variable("y");
51: //
52: //                final OWL2Query<OWLObject> not = f.createQuery(ont);
53: //                not.addDistVar(y);
54: //
55: //                query = query.Not(not.Type(f.wrap(cpc.getDomain()), x))
56: //                                .PropertyValue(f.wrap(cpc.getProperty()), x, y);
57: //                query.addDistVar(x);
58: //                query.addDistVar(y);
59: //        }
60: //
61: //        
62: //        public void visit(ObjectRangeConstraint cpc) {
63: //                Variable<OWLObject> x = f.variable("x");class ICEvaluator {
64: ////                        public boolean isSatisfied(IntegrityConstraint check) {
65: //                        //
66: ////                                                OWL2Ontology<OWLObject> ont = new OWLAPIv3OWL2Ontology(m, workingOnt, r);
67: ////                                                OWLAPIv3QueryFactory fact = new OWLAPIv3QueryFactory(m, workingOnt);
68: //                        //
69: ////                                                ICQueryGenerator v = new ICQueryGenerator(fact, ont);
70: ////                                                check.//
71: //        public OWL2Query<OWLObject> getQuery() {
72: //        return query;
73: //}accept(v);
74: //                        //
75: ////                                                return OWL2QueryEngine.exec(v.getQuery()).isEmpty();
76: ////                                        }
77: //                        //
78: ////                                }
79: //                Variable<OWLObject> y = f.variable("y");
80: //
81: //                final OWL2Query<OWLObject> not = f.createQuery(ont);
82: //                not.addDistVar(y);
83: //
84: //                query = query.Type(f.wrap(cpc.getOWLClass()), x).PropertyValue(
85: //                                f.wrap(cpc.getProperty()), x, y).Not(
86: //                                not.Type(f.wrap(cpc.getRange()), y));
87: //                query.addDistVar(x);
88: //                query.addDistVar(y);
89: //        }
90: //
91: //        
92: //        public void visit(ObjectDomainConstraint cpc) {
93: //                Variable<OWLObject> x = f.variable("x");
94: //                Variable<OWLObject> y = f.variable("y");
95: //
96: //                final OWL2Query<OWLObject> not = f.createQuery(ont);
97: //                not.addDistVar(y);
98: ////
99: //        public OWL2Query<OWLObject> getQuery() {
100: //        return query;
101: //}
102: //                query = query.Not(not.Type(f.wrap(cpc.getDomain()), x))
103: //                                .PropertyValue(f.wrap(cpc.getProperty()), x, y);
104: //                query.addDistVar(x);
105: //                query.addDistVar(y);
106: //        }
107: //
108: //        
109: //        public void visit(ObjectParticipationConstraint cpc) {
110: //                Variable<OWLObject> x = f.variable("x");
111: //                query.addDistVar(x);
112: ////
113: //        public OWL2Query<OWLObject> getQuery() {
114: //        return query;
115: //}
116: //                query = query.Type(f.wrap(cpc.getSubject()), x);
117: //
118: //                if (cpc.getMin() > 0) {
119: //                        query = min("y", cpc.getMin(), query, x, f.wrap(cpc
120: //                                        .getPredicate()), f.wrap(cpc.getObject()));
121: //                }
122: //
123: //                if (cpc.getMax() > -1) {
124: //                        OWL2Query<OWLObject> notMax = f.createQuery(ont);
125: //                        notMax = min("z", cpc.getMax(), notMax, x, f.wrap(cpc
126: //                                        .getPredicate()), f.wrap(cpc.getObject()));
127: //                        query = query.Not(notMax);
128: //                }
129: //        }
130: //
131: //        private OWL2Query<OWLObject> min(String varPrefix, int n,
132: //                        OWL2Query<OWLObject> query, final Variable<OWLObject> varx,
133: //                        final Term<OWLObject> pred, final Term<OWLObject> obj) {
134: //                final List<Variable<OWLObject>> vars = new ArrayList<Variable<OWLObject>>();
135: //                for (int i = 1; i <= n; i++) {
136: //                        vars.add(f.variable(varPrefix + i));
137: //                }
138: //
139: //                for (int i = 1; i <= n; i++) {
140: //                        Variable<OWLObject> zi//
141: //        public OWL2Query<OWLObject> getQuery() {
142: //        return query;
143: //} = vars.get(i - 1);
144: //                        query = query.PropertyValue(pred, varx, zi);
145: //                        query = query.Type(obj, zi);
146: //                        query.addDistVar(zi);
147: //
148: //                        for (int j = i; i <= n; i++) {
149: //                                final Variable<OWLObject> yj = vars.get(j - 1);
150: //                                final OWL2Query<OWLObject> not = f.createQuery(ont).SameAs(
151: //                                                zi, yj);
152: //                                not.addDistVar(zi);
153: //                                not.addDistVar(yj);
154: //
155: //                                query = query.Not(not);
156: //                        }
157: //                }
158: //                return query;
159: //        }
160: //
161: //        
162: //        public void visit(DataParticipationConstraint cpc) {
163: //                Variable<OWLObject> x = f.variable("x");
164: //                query.addDistVar(x);
165: //
166: //                query = query.Type(f.wrap(cpc.getSubject()), x);
167: //
168: //                if (cpc.getMin() > 0) {
169: //                        query = min("y", cpc.getMin(), query, x, f.wrap(cpc
170: //                                        .getPredicate()), f.wrap(cpc.getObject()));
171: //                }
172: //
173: //                if (cpc.getMax() > -1) {
174: //                        OWL2Query<OWLObject> notMax = f.createQuery(ont);
175: //                        notMax = min("z", cpc.getMax(), notMax, x, f.wrap(cpc
176: //                                        .getPredicate()), f.wrap(cpc.getObject()));
177: //                        query = query.Not(notMax);
178: //                }
179: //        }
180: //
181: //        public OWL2Query<OWLObject> getQuery() {
182: //                return query;
183: //        }
184: }