Skip to content

Commit 09a8f2f

Browse files
committed
moving contextualization to flush-time
1 parent 8684715 commit 09a8f2f

File tree

2 files changed

+4
-31
lines changed

2 files changed

+4
-31
lines changed

generator/templates/OpenMINDS.java.j2

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,10 @@ import java.util.stream.Stream;
1616
*/
1717
public class OpenMINDS {
1818

19-
private final OpenMINDSContext context;
19+
private OpenMINDS(){}
2020

21-
private OpenMINDS(OpenMINDSContext context){
22-
this.context = context;
23-
}
24-
25-
private static void persist(String targetDirectory, Stream<Instance> instances){
26-
File dir = new File(targetDirectory);
27-
if(!dir.exists()){
28-
dir.mkdirs();
29-
}
30-
instances.forEach(i -> {
31-
File f = new File(targetDirectory+File.separator+i.getLocalId().id()+".jsonld");
32-
try {
33-
ParsingUtils.OBJECT_MAPPER.writerWithDefaultPrettyPrinter().writeValue(f, i);
34-
} catch (IOException e) {
35-
throw new RuntimeException(e);
36-
}
37-
});
38-
}
39-
40-
{% for version in relevant_versions %}public static OpenMINDS.{{version[0]|upper}}{{version[1:]}} {{version}}(){
41-
return {{version}}(OpenMINDSContext.defaultContext());
42-
}
43-
44-
public static OpenMINDS.{{version[0]|upper}}{{version[1:]}} {{version}}(String idPrefix){
45-
return {{version}}(new OpenMINDSContext(idPrefix, true));
46-
}
47-
48-
private static OpenMINDS.{{version[0]|upper}}{{version[1:]}} {{version}}(OpenMINDSContext context) {
49-
return new OpenMINDS(context).new {{version[0]|upper}}{{version[1:]}}();
21+
{% for version in relevant_versions %}public static OpenMINDS.{{version[0]|upper}}{{version[1:]}} {{version}}() {
22+
return new OpenMINDS().new {{version[0]|upper}}{{version[1:]}}();
5023
}
5124

5225
public final class {{version[0]|upper}}{{version[1:]}} {

generator/templates/schema_class.java.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class {{ class_name }} extends Instance {% if implemented_interfaces %}im
4444

4545
public {{ class_name }} build(OpenMINDSContext context) {
4646
if ({{ class_name }}.this.id == null) {
47-
{{ class_name }}.this.id = InstanceId.withPrefix(UUID.randomUUID().toString(), openMINDSContext.idPrefix());
47+
{{ class_name }}.this.id = InstanceId.withPrefix(UUID.randomUUID().toString(), context.idPrefix());
4848
}
4949
{{ class_name }}.this.type = SEMANTIC_NAME;
5050
return {{ class_name }}.this;

0 commit comments

Comments
 (0)