Skip to contentMethod: targetDir(String)
1: /*
2: * JOPA
3: * Copyright (C) 2024 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.owl2java.config;
19:
20: import cz.cvut.kbss.jopa.owl2java.cli.CliParams;
21: import cz.cvut.kbss.jopa.owl2java.cli.Option;
22: import cz.cvut.kbss.jopa.owl2java.cli.PropertiesType;
23: import cz.cvut.kbss.jopa.owl2java.prefix.PrefixCcRemotePrefixResolver;
24: import cz.cvut.kbss.jopa.owl2java.prefix.RemotePrefixResolver;
25:
26: public class TransformationConfiguration {
27:
28: private final String context;
29:
30: private final String packageName;
31:
32: private final String targetDir;
33:
34: private final boolean generateOwlapiIris;
35:
36: private final boolean generateJavadoc;
37:
38: private final boolean preferMultilingualStrings;
39:
40: private final PropertiesType propertiesType;
41:
42: private final boolean generateAnnotationFields;
43:
44: private final boolean generateThing;
45:
46: private final String ontologyPrefixProperty;
47:
48: private final boolean alwaysUseOntologyPrefix;
49:
50: private final String prefixMappingFile;
51:
52: private final CliParams cliParams;
53:
54: private final RemotePrefixResolver remotePrefixResolver;
55:
56: private TransformationConfiguration(TransformationConfigurationBuilder builder) {
57: this.context = builder.context;
58: this.packageName = builder.packageName;
59: this.targetDir = builder.targetDir;
60: this.generateOwlapiIris = builder.owlapiIris;
61: this.generateJavadoc = builder.generateJavadoc;
62: this.preferMultilingualStrings = builder.preferMultilingualStrings;
63: this.propertiesType = builder.propertiesType;
64: this.generateAnnotationFields = builder.generateAnnotationFields;
65: this.generateThing = builder.generateThing;
66: this.ontologyPrefixProperty = builder.ontologyPrefixProperty;
67: this.alwaysUseOntologyPrefix = builder.alwaysUseOntologyPrefix;
68: this.prefixMappingFile = builder.prefixMappingFile;
69: this.remotePrefixResolver = builder.remotePrefixResolver;
70: this.cliParams = CliParams.empty();
71: }
72:
73: private TransformationConfiguration(CliParams cliParams) {
74: this.cliParams = cliParams;
75: this.context = cliParams.is(Option.WHOLE_ONTOLOGY_AS_IC.arg) ? null : cliParams.valueOf(Option.CONTEXT.arg)
76: .toString();
77: this.packageName = cliParams.valueOf(Option.PACKAGE.arg).toString();
78: this.targetDir = cliParams.valueOf(Option.TARGET_DIR.arg).toString();
79: this.generateOwlapiIris = cliParams.is(Option.WITH_IRIS.arg, Defaults.WITH_IRIS);
80: this.generateJavadoc = cliParams.is(Option.GENERATE_JAVADOC_FROM_COMMENT.arg, Defaults.GENERATE_JAVADOC_FROM_COMMENT);
81: this.preferMultilingualStrings = cliParams.is(Option.PREFER_MULTILINGUAL_STRINGS.arg, Defaults.PREFER_MULTILINGUAL_STRINGS);
82: this.propertiesType = PropertiesType.fromParam(cliParams.valueOf(Option.PROPERTIES_TYPE.arg));
83: this.generateAnnotationFields = cliParams.is(Option.GENERATE_ANNOTATION_FIELDS.arg, Defaults.GENERATE_ANNOTATION_FIELDS);
84: this.generateThing = cliParams.is(Option.GENERATE_THING.arg, Defaults.GENERATE_THING);
85: this.ontologyPrefixProperty = cliParams.has(Option.ONTOLOGY_PREFIX_PROPERTY.arg) ? cliParams.valueOf(Option.ONTOLOGY_PREFIX_PROPERTY.arg)
86: .toString() : Defaults.ONTOLOGY_PREFIX_PROPERTY;
87: this.alwaysUseOntologyPrefix = cliParams.is(Option.ALWAYS_USE_ONTOLOGY_PREFIX.arg, Defaults.ALWAYS_USE_ONTOLOGY_PREFIX);
88: this.prefixMappingFile = cliParams.has(Option.PREFIX_MAPPING_FILE.arg) ? cliParams.valueOf(Option.PREFIX_MAPPING_FILE.arg)
89: .toString() : null;
90: this.remotePrefixResolver = new PrefixCcRemotePrefixResolver();
91: }
92:
93: public String getContext() {
94: return context;
95: }
96:
97: public String getPackageName() {
98: return packageName;
99: }
100:
101: public String getTargetDir() {
102: return targetDir;
103: }
104:
105: public boolean areAllAxiomsIntegrityConstraints() {
106: return context == null;
107: }
108:
109: public boolean shouldGenerateOwlapiIris() {
110: return generateOwlapiIris;
111: }
112:
113: public boolean shouldGenerateJavadoc() {
114: return generateJavadoc;
115: }
116:
117: public boolean shouldPreferMultilingualStrings() {
118: return preferMultilingualStrings;
119: }
120:
121: public PropertiesType getPropertiesType() {
122: return propertiesType;
123: }
124:
125: public boolean shouldGenerateAnnotationFields() {
126: return generateAnnotationFields;
127: }
128:
129: public boolean shouldGenerateThing() {
130: return generateThing;
131: }
132:
133: public String getOntologyPrefixProperty() {
134: return ontologyPrefixProperty;
135: }
136:
137: public boolean shouldAlwaysUseOntologyPrefix() {
138: return alwaysUseOntologyPrefix;
139: }
140:
141: public String getPrefixMappingFile() {
142: return prefixMappingFile;
143: }
144:
145: public RemotePrefixResolver getRemotePrefixResolver() {
146: return remotePrefixResolver;
147: }
148:
149: public CliParams getCliParams() {
150: return cliParams;
151: }
152:
153: public static TransformationConfiguration config(CliParams cliParams) {
154: return new TransformationConfiguration(cliParams);
155: }
156:
157: public static TransformationConfigurationBuilder builder() {
158: return new TransformationConfigurationBuilder();
159: }
160:
161: public static class TransformationConfigurationBuilder {
162: private String context;
163: private String packageName = Defaults.PACKAGE;
164: private String targetDir = Defaults.TARGET_DIR;
165: private PropertiesType propertiesType = PropertiesType.valueOf(Defaults.PROPERTIES_TYPE);
166: private boolean owlapiIris = Defaults.WITH_IRIS;
167: private boolean generateJavadoc = Defaults.GENERATE_JAVADOC_FROM_COMMENT;
168: private boolean preferMultilingualStrings = Defaults.PREFER_MULTILINGUAL_STRINGS;
169: private boolean generateAnnotationFields = Defaults.GENERATE_ANNOTATION_FIELDS;
170: private boolean generateThing = Defaults.GENERATE_THING;
171: private String ontologyPrefixProperty = Defaults.ONTOLOGY_PREFIX_PROPERTY;
172: private boolean alwaysUseOntologyPrefix = Defaults.ALWAYS_USE_ONTOLOGY_PREFIX;
173: private String prefixMappingFile = null;
174: private RemotePrefixResolver remotePrefixResolver = new PrefixCcRemotePrefixResolver();
175:
176: public TransformationConfigurationBuilder context(String context) {
177: this.context = context;
178: return this;
179: }
180:
181: public TransformationConfigurationBuilder packageName(String packageName) {
182: this.packageName = packageName;
183: return this;
184: }
185:
186: public TransformationConfigurationBuilder targetDir(String targetDir) {
187: this.targetDir = targetDir;
188: return this;
189: }
190:
191: public TransformationConfigurationBuilder addOwlapiIris(boolean add) {
192: this.owlapiIris = add;
193: return this;
194: }
195:
196: public TransformationConfigurationBuilder generateJavadoc(boolean javadoc) {
197: this.generateJavadoc = javadoc;
198: return this;
199: }
200:
201: public TransformationConfigurationBuilder preferMultilingualStrings(boolean preferMultilingualStrings) {
202: this.preferMultilingualStrings = preferMultilingualStrings;
203: return this;
204: }
205:
206: public TransformationConfigurationBuilder propertiesType(PropertiesType propertiesType) {
207: this.propertiesType = propertiesType;
208: return this;
209: }
210:
211: public TransformationConfigurationBuilder generateAnnotationFields(boolean generateAnnotationFields) {
212: this.generateAnnotationFields = generateAnnotationFields;
213: return this;
214: }
215:
216: public TransformationConfigurationBuilder generateThing(boolean generateThing) {
217: this.generateThing = generateThing;
218: return this;
219: }
220:
221: public TransformationConfigurationBuilder ontologyPrefixProperty(String ontologyPrefixProperty) {
222: if (ontologyPrefixProperty != null && !ontologyPrefixProperty.isBlank()) {
223: this.ontologyPrefixProperty = ontologyPrefixProperty;
224: }
225: return this;
226: }
227:
228: public TransformationConfigurationBuilder alwaysUseOntologyPrefix(boolean alwaysUseOntologyPrefix) {
229: this.alwaysUseOntologyPrefix = alwaysUseOntologyPrefix;
230: return this;
231: }
232:
233: public TransformationConfigurationBuilder prefixMappingFile(String prefixMappingFile) {
234: this.prefixMappingFile = prefixMappingFile;
235: return this;
236: }
237:
238: public TransformationConfigurationBuilder remotePrefixResolver(RemotePrefixResolver resolver) {
239: this.remotePrefixResolver = resolver;
240: return this;
241: }
242:
243: public TransformationConfiguration build() {
244: return new TransformationConfiguration(this);
245: }
246: }
247: }