Skip to content

Commit c92d74c

Browse files
committed
implement TSchema supplier
Signed-off-by: dbulahov <[email protected]>
1 parent a178268 commit c92d74c

File tree

7 files changed

+219
-0
lines changed

7 files changed

+219
-0
lines changed

csdl/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
<packaging>pom</packaging>
2222
<modules>
2323
<module>model</module>
24+
<module>provider</module>
2425
</modules>
2526
</project>

csdl/provider/pom.xml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/*********************************************************************
4+
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
5+
*
6+
* This program and the accompanying materials are made
7+
* available under the terms of the Eclipse Public License 2.0
8+
* which is available at https://www.eclipse.org/legal/epl-2.0/
9+
*
10+
* SPDX-License-Identifier: EPL-2.0
11+
**********************************************************************/
12+
-->
13+
<project xmlns="http://maven.apache.org/POM/4.0.0"
14+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
15+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
16+
<modelVersion>4.0.0</modelVersion>
17+
<parent>
18+
<groupId>org.eclipse.daanse</groupId>
19+
<artifactId>org.eclipse.daanse.xmla.csdl</artifactId>
20+
<version>${revision}</version>
21+
</parent>
22+
<artifactId>org.eclipse.daanse.xmla.csdl.model.provider</artifactId>
23+
<name>CSDL model provider</name>
24+
<description>CSDL model provider</description>
25+
26+
<properties>
27+
<bnd.version>7.2.0-SNAPSHOT</bnd.version>
28+
<gecko.emf.version>6.2.0</gecko.emf.version>
29+
<emf.common.version>2.30.0</emf.common.version>
30+
<emf.ecore.version>2.36.0</emf.ecore.version>
31+
<emf.ecore.xmi.version>2.37.0</emf.ecore.xmi.version>
32+
</properties>
33+
34+
<dependencies>
35+
<dependency>
36+
<groupId>org.geckoprojects.emf</groupId>
37+
<artifactId>org.gecko.emf.osgi.api</artifactId>
38+
<version>${gecko.emf.version}</version>
39+
<scope>compile</scope>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.eclipse.daanse</groupId>
43+
<artifactId>org.eclipse.daanse.xmla.csdl.model.v2.edm</artifactId>
44+
<version>${revision}</version>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.eclipse.daanse</groupId>
48+
<artifactId>org.eclipse.daanse.xmla.csdl.model.v2.an</artifactId>
49+
<version>${revision}</version>
50+
</dependency>
51+
</dependencies>
52+
</project>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* SmartCity Jena - initial
12+
* Stefan Bischof (bipolis.org) - initial
13+
*/
14+
package org.eclipse.daanse.xmla.csdl.model.provider;
15+
16+
public class Constants {
17+
18+
public static final String RESOURCE_URL = "resource.url";
19+
public static final String PID_EMF_TSCHEMA_PROVIDER = "org.eclipse.daanse.rolap.mapping.model.provider.EmfTschemaProvider";
20+
21+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2026 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* SmartCity Jena - initial
12+
* Stefan Bischof (bipolis.org) - initial
13+
*/
14+
package org.eclipse.daanse.xmla.csdl.model.provider;
15+
16+
import org.osgi.service.metatype.annotations.AttributeDefinition;
17+
import org.osgi.service.metatype.annotations.ObjectClassDefinition;
18+
19+
@ObjectClassDefinition()
20+
public @interface EmfTschemaProviderConfig {
21+
22+
@AttributeDefinition(name = Constants.RESOURCE_URL)
23+
String resource_url();
24+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* SmartCity Jena - initial
12+
* Stefan Bischof (bipolis.org) - initial
13+
*/
14+
package org.eclipse.daanse.xmla.csdl.model.provider;
15+
16+
import java.util.function.Supplier;
17+
18+
import org.eclipse.daanse.xmla.csdl.model.v2.edm.TSchema;
19+
20+
/**
21+
* Supplier interface for providing an OlapCheckSuite. Implementations can load
22+
* suites from various sources (XMI files, JSON, etc.) and are aggregated by the
23+
* OlapCheckSuiteRegistry.
24+
*/
25+
public interface OlapTSchemaSupplier extends Supplier<TSchema> {
26+
27+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright (c) 2026 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
*
12+
*/
13+
package org.eclipse.daanse.xmla.csdl.model.provider.impl;
14+
15+
import java.io.IOException;
16+
import java.util.Map;
17+
18+
import org.eclipse.daanse.xmla.csdl.model.provider.Constants;
19+
import org.eclipse.daanse.xmla.csdl.model.provider.EmfTschemaProviderConfig;
20+
import org.eclipse.daanse.xmla.csdl.model.provider.OlapTSchemaSupplier;
21+
import org.eclipse.daanse.xmla.csdl.model.v2.edm.EdmPackage;
22+
import org.eclipse.daanse.xmla.csdl.model.v2.edm.TSchema;
23+
import org.eclipse.emf.common.util.EList;
24+
import org.eclipse.emf.common.util.URI;
25+
import org.eclipse.emf.ecore.EObject;
26+
import org.eclipse.emf.ecore.resource.Resource;
27+
import org.eclipse.emf.ecore.resource.ResourceSet;
28+
import org.eclipse.emf.ecore.util.EcoreUtil;
29+
import org.gecko.emf.osgi.constants.EMFNamespaces;
30+
import org.osgi.service.component.annotations.Activate;
31+
import org.osgi.service.component.annotations.Component;
32+
import org.osgi.service.component.annotations.Deactivate;
33+
import org.osgi.service.component.annotations.Reference;
34+
import org.osgi.service.component.annotations.ServiceScope;
35+
import org.osgi.service.metatype.annotations.Designate;
36+
37+
@Component(service = OlapTSchemaSupplier.class, scope = ServiceScope.SINGLETON, configurationPid = Constants.PID_EMF_TSCHEMA_PROVIDER)
38+
@Designate(factory = true, ocd = EmfTschemaProviderConfig.class)
39+
public class EmfTschemaProvider implements OlapTSchemaSupplier {
40+
41+
@Reference(target = "(" + EMFNamespaces.EMF_MODEL_NAME + "=" + EdmPackage.eNAME + ")")
42+
private ResourceSet resourceSet;
43+
44+
private TSchema tSchema;
45+
46+
@Activate
47+
public void activate(EmfTschemaProviderConfig config) throws IOException {
48+
49+
String url = config.resource_url();
50+
51+
URI uri = URI.createFileURI(url);
52+
Resource resource = resourceSet.getResource(uri, true);
53+
resource.load(Map.of());
54+
EcoreUtil.resolveAll(resource);
55+
EList<EObject> contents = resource.getContents();
56+
57+
for (EObject eObject : contents) {
58+
if (eObject instanceof TSchema rcm) {
59+
tSchema = rcm;
60+
}
61+
}
62+
63+
}
64+
65+
@Deactivate
66+
public void deactivate() {
67+
cleanAllResources();
68+
}
69+
70+
@Override
71+
public TSchema get() {
72+
return tSchema;
73+
}
74+
75+
private void cleanAllResources() {
76+
resourceSet.getResources().forEach(Resource::unload);
77+
}
78+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
*
12+
*/
13+
@org.osgi.annotation.bundle.Export
14+
@org.osgi.annotation.versioning.Version("0.0.1")
15+
package org.eclipse.daanse.xmla.csdl.model.provider;
16+

0 commit comments

Comments
 (0)