-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Implement and use resourcemanager
- Loading branch information
Showing
16 changed files
with
558 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>ccims-eclipse-plugin-resourcemanager</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.ManifestBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.SchemaBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.pde.PluginNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 | ||
org.eclipse.jdt.core.compiler.compliance=11 | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning | ||
org.eclipse.jdt.core.compiler.release=enabled | ||
org.eclipse.jdt.core.compiler.source=11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: Ccims-eclipse-plugin-resourcemanager | ||
Bundle-SymbolicName: ccims-eclipse-plugin-resourcemanager | ||
Bundle-Version: 1.0.0.qualifier | ||
Automatic-Module-Name: ccims.eclipse.plugin.resourcemanager | ||
Bundle-RequiredExecutionEnvironment: JavaSE-11 | ||
Require-Bundle: ccims-eclipse-plugin-data;bundle-version="1.0.0", | ||
com.google.gson;bundle-version="2.8.2", | ||
ccims-eclipse-plugin-apiBindings;bundle-version="1.0.0" | ||
Import-Package: org.osgi.framework | ||
Export-Package: de.unistuttgart.iste.rss.ccims.eclipseplugin.resourcemanager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source.. = src/ | ||
output.. = bin/ | ||
bin.includes = META-INF/,\ | ||
. |
69 changes: 69 additions & 0 deletions
69
...nager/src/de/unistuttgart/iste/rss/ccims/eclipseplugin/resourcemanager/CcimsResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package de.unistuttgart.iste.rss.ccims.eclipseplugin.resourcemanager; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.UnsupportedEncodingException; | ||
import java.net.URISyntaxException; | ||
import java.util.Map; | ||
|
||
import org.eclipse.emf.common.util.URI; | ||
import org.eclipse.emf.ecore.resource.impl.ResourceImpl; | ||
|
||
import de.unistuttgart.iste.rss.ccims.eclipseplugin.apibindings.Query; | ||
import de.unistuttgart.iste.rss.ccims.eclipseplugin.datamodel.CrossComponentIssueManagementSystem; | ||
import de.unistuttgart.iste.rss.ccims.eclipseplugin.resourcemanager.apiadapter.ApiQueryManager; | ||
|
||
public class CcimsResource extends ResourceImpl { | ||
|
||
private ApiQueryManager apiQueryManager; | ||
private DataMapper dataMapper; | ||
|
||
public CcimsResource(URI uri) { | ||
super(uri); | ||
try { | ||
java.net.URI apiUri = convertUri(uri); | ||
apiQueryManager = new ApiQueryManager(apiUri); | ||
dataMapper = new DataMapper(apiUri.toString()); | ||
} catch (URISyntaxException | UnsupportedEncodingException e) { | ||
throw new IllegalStateException("Could not generate api request uri", e); | ||
} | ||
} | ||
|
||
/** | ||
* This implementation directly loads the EObjects from the API without | ||
* deserialization. Therefore this does call neither | ||
* {@link ResourceImpl#load(Map)} nor {@link #load(InputStream, Map)}. | ||
* <p> | ||
* As all currently defined options only relate to the format of the file on | ||
* disk, the options parameter is not used here. | ||
* | ||
* @param options Options for loading. Not used. | ||
*/ | ||
@Override | ||
public void load(Map<?, ?> options) throws IOException { | ||
try { | ||
Query apiQuery = apiQueryManager.query(); | ||
CrossComponentIssueManagementSystem ccims = dataMapper.mapToEObject(apiQuery); | ||
this.getContents().add(ccims); | ||
} catch (IOException | InterruptedException e) { | ||
throw new IOException("Failed to load data from api", e); | ||
} | ||
} | ||
|
||
@Override | ||
public void save(Map<?, ?> options) throws IOException { | ||
// TODO: implememnt | ||
} | ||
|
||
/** | ||
* Converts eclispe ecore uri with ccims schema to java.net uri with http schema. | ||
* @param uri The eclipse ecore uri with a ccims based schema | ||
* @return The java.net uri with a http based schema | ||
* @throws URISyntaxException When the resulting uri is not legal | ||
*/ | ||
private java.net.URI convertUri(URI uri) throws URISyntaxException{ | ||
return new java.net.URI(uri.scheme().replace("ccims", "http"), uri.userInfo(), uri.host(), uri.port() == null ? -1 : Integer.parseInt(uri.port()), uri.path(), uri.query(), | ||
uri.fragment()); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...rc/de/unistuttgart/iste/rss/ccims/eclipseplugin/resourcemanager/CcimsResourceFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package de.unistuttgart.iste.rss.ccims.eclipseplugin.resourcemanager; | ||
|
||
import org.eclipse.emf.common.util.URI; | ||
import org.eclipse.emf.ecore.resource.Resource; | ||
import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; | ||
|
||
public class CcimsResourceFactory implements Resource.Factory { | ||
|
||
@Override | ||
public Resource createResource(URI uri) { | ||
return new CcimsResource(uri); | ||
} | ||
|
||
} |
163 changes: 163 additions & 0 deletions
163
...emanager/src/de/unistuttgart/iste/rss/ccims/eclipseplugin/resourcemanager/DataMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
package de.unistuttgart.iste.rss.ccims.eclipseplugin.resourcemanager; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import com.shopify.graphql.support.ID; | ||
|
||
import de.unistuttgart.iste.rss.ccims.eclipseplugin.apibindings.Component; | ||
import de.unistuttgart.iste.rss.ccims.eclipseplugin.apibindings.ComponentInterface; | ||
import de.unistuttgart.iste.rss.ccims.eclipseplugin.apibindings.Issue; | ||
import de.unistuttgart.iste.rss.ccims.eclipseplugin.apibindings.Label; | ||
import de.unistuttgart.iste.rss.ccims.eclipseplugin.apibindings.Project; | ||
import de.unistuttgart.iste.rss.ccims.eclipseplugin.apibindings.Query; | ||
import de.unistuttgart.iste.rss.ccims.eclipseplugin.apibindings.User; | ||
import de.unistuttgart.iste.rss.ccims.eclipseplugin.datamodel.CcimsDatamodelFactory; | ||
import de.unistuttgart.iste.rss.ccims.eclipseplugin.datamodel.CrossComponentIssue; | ||
import de.unistuttgart.iste.rss.ccims.eclipseplugin.datamodel.CrossComponentIssueManagementSystem; | ||
import de.unistuttgart.iste.rss.ccims.eclipseplugin.datamodel.Developer; | ||
import de.unistuttgart.iste.rss.ccims.eclipseplugin.datamodel.Interface; | ||
|
||
public class DataMapper { | ||
|
||
private Map<ID, de.unistuttgart.iste.rss.ccims.eclipseplugin.datamodel.Component> componentMap; | ||
private Map<ID, Interface> interfaceMap; | ||
private Map<ID, Developer> developerMap; | ||
private Map<ID, de.unistuttgart.iste.rss.ccims.eclipseplugin.datamodel.Label> labelMap; | ||
private Map<ID, CrossComponentIssue> issueMap; | ||
|
||
private CcimsDatamodelFactory fac; | ||
|
||
private String apiLocationUri; | ||
|
||
public DataMapper(String apiLocationUri) { | ||
this.apiLocationUri = apiLocationUri; | ||
fac = CcimsDatamodelFactory.eINSTANCE; | ||
componentMap = new HashMap<>(); | ||
interfaceMap = new HashMap<>(); | ||
developerMap = new HashMap<>(); | ||
labelMap = new HashMap<>(); | ||
issueMap = new HashMap<>(); | ||
} | ||
|
||
public CrossComponentIssueManagementSystem mapToEObject(Query apiQuery) { | ||
CrossComponentIssueManagementSystem result = fac.createCrossComponentIssueManagementSystem(); | ||
result.setLocationUri(apiLocationUri); | ||
|
||
//components and provided interfaces | ||
for (Project project: apiQuery.getProjects().getNodes()) { | ||
for(Component component : project.getComponents().getNodes()) { | ||
var ecoreComponent = getEcoreComponent(component); | ||
result.getComponents().add(ecoreComponent); | ||
|
||
for(ComponentInterface compInterface : component.getInterfaces().getNodes()) { | ||
var ecoreInterface = getEcoreInterface(compInterface); | ||
ecoreComponent.getProvidedInterfaces().add(ecoreInterface); | ||
} | ||
} | ||
} | ||
|
||
//consumed interfaces | ||
for (Project project: apiQuery.getProjects().getNodes()) { | ||
for (Component component : project.getComponents().getNodes()) { | ||
for (ComponentInterface compInteface : component.getConsumedInterfaces().getNodes()) { | ||
componentMap.get(component.getId()).getConsumedInterfaces().add(interfaceMap.get(compInteface.getId())); | ||
} | ||
} | ||
} | ||
|
||
//developers | ||
for (Project project: apiQuery.getProjects().getNodes()) { | ||
for (User user: project.getUsers().getNodes()) { | ||
result.getDevelopers().add(getEcoreDeveloper(user)); | ||
} | ||
} | ||
|
||
//issues | ||
for (Project project: apiQuery.getProjects().getNodes()) { | ||
for (Issue issue: project.getIssues().getNodes()) { | ||
result.getManagedCroCoIssues().add(getEcoreIssue(issue)); | ||
} | ||
} | ||
|
||
//issue link | ||
for (Project project: apiQuery.getProjects().getNodes()) { | ||
for (Issue issue: project.getIssues().getNodes()) { | ||
for(Issue linkedIssue : issue.getLinkedIssues().getNodes()) { | ||
issueMap.get(issue.getId()).getLinkedIssues().add(issueMap.get(linkedIssue.getId())); | ||
} | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
|
||
private de.unistuttgart.iste.rss.ccims.eclipseplugin.datamodel.Component getEcoreComponent(Component component) { | ||
ID id = component.getId(); | ||
if(componentMap.containsKey(id)) { | ||
return componentMap.get(id); | ||
} | ||
|
||
var result = fac.createComponent(); | ||
result.setName(component.getName()); | ||
componentMap.put(id, result); | ||
return result; | ||
} | ||
|
||
private Interface getEcoreInterface(ComponentInterface compInterface) { | ||
ID id = compInterface.getId(); | ||
if(interfaceMap.containsKey(id)) { | ||
return interfaceMap.get(id); | ||
} | ||
|
||
var result = fac.createInterface(); | ||
result.setName(compInterface.getName()); | ||
interfaceMap.put(id, result); | ||
return result; | ||
} | ||
|
||
private Developer getEcoreDeveloper(User user) { | ||
ID id = user.getId(); | ||
if(developerMap.containsKey(id)) { | ||
return developerMap.get(id); | ||
} | ||
var result = fac.createDeveloper(); | ||
result.setName(user.getUsername()); | ||
developerMap.put(id, result); | ||
return result; | ||
} | ||
|
||
private CrossComponentIssue getEcoreIssue(Issue issue) { | ||
ID id = issue.getId(); | ||
if(issueMap.containsKey(id)) { | ||
return issueMap.get(id); | ||
} | ||
var result = fac.createCrossComponentIssue(); | ||
result.setTitle(issue.getTitle()); | ||
result.setTextBody(issue.getBody()); | ||
result.setIsOpen(issue.getIsOpen()); | ||
|
||
for(User user: issue.getAssignees().getNodes()) { | ||
result.getAssignees().add(developerMap.get(user.getId())); | ||
} | ||
|
||
for(Label label: issue.getLabels().getNodes()) { | ||
result.getLabels().add(getEcoreLabel(label)); | ||
} | ||
|
||
issueMap.put(id, result); | ||
return result; | ||
} | ||
|
||
private de.unistuttgart.iste.rss.ccims.eclipseplugin.datamodel.Label getEcoreLabel(Label label) { | ||
ID id = label.getId(); | ||
if(labelMap.containsKey(id)) { | ||
return labelMap.get(id); | ||
} | ||
var result = fac.createLabel(); | ||
result.setName(label.getName()); | ||
|
||
labelMap.put(id, result); | ||
return result; | ||
} | ||
} |
Oops, something went wrong.