diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..153c933 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +HELP.md +/target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +/build/ + +### VS Code ### +.vscode/ diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000..72308aa --- /dev/null +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,114 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.URL; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.util.Properties; + +public class MavenWrapperDownloader { + + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = + "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if(mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if(mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: : " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..01e6799 Binary files /dev/null and b/.mvn/wrapper/maven-wrapper.jar differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..cd0d451 --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip diff --git a/.project b/.project index 5e84c49..b42448a 100644 --- a/.project +++ b/.project @@ -10,6 +10,11 @@ + + org.springframework.ide.eclipse.boot.validation.springbootbuilder + + + org.eclipse.m2e.core.maven2Builder diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index b8947ec..9c81ef9 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,5 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.methodParameters=generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning diff --git a/HELP.md b/HELP.md index 8b6a26a..72c5741 100644 --- a/HELP.md +++ b/HELP.md @@ -1,10 +1,15 @@ # Getting Started +### Reference Documentation +For further reference, please consider the following sections: + +* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) + ### Guides -The following guides illustrates how to use certain features concretely: +The following guides illustrate how to use some features concretely: +* [Accessing Data with JPA](https://spring.io/guides/gs/accessing-data-jpa/) * [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/) * [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/) * [Building REST services with Spring](https://spring.io/guides/tutorials/bookmarks/) -* [Accessing Data with JPA](https://spring.io/guides/gs/accessing-data-jpa/) diff --git a/mvnw b/mvnw index 5551fde..8b9da3b 100644 --- a/mvnw +++ b/mvnw @@ -8,7 +8,7 @@ # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/mvnw.cmd b/mvnw.cmd index e5cfb0a..fef5a8f 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -7,7 +7,7 @@ @REM "License"); you may not use this file except in compliance @REM with the License. You may obtain a copy of the License at @REM -@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM https://www.apache.org/licenses/LICENSE-2.0 @REM @REM Unless required by applicable law or agreed to in writing, @REM software distributed under the License is distributed on an diff --git a/pom.xml b/pom.xml index e896745..befe652 100644 --- a/pom.xml +++ b/pom.xml @@ -5,14 +5,14 @@ org.springframework.boot spring-boot-starter-parent - 1.5.9.RELEASE + 2.1.5.RELEASE - com.swarm - graphql + com.spqr.test + spqrTest 0.0.1-SNAPSHOT - SwarmGraphQL - Demo project for Spring Boot + spqrTest + Swarm Debugging Server using graphql-spqr 1.8 @@ -38,31 +38,17 @@ spring-boot-starter-test test - - com.graphql-java - graphql-spring-boot-starter - 3.10.0 - - - - com.graphql-java - graphql-java-tools - 4.3.0 + io.leangen.graphql + graphql-spqr-spring-boot-starter + 0.0.3 com.graphql-java graphiql-spring-boot-starter 3.10.0 - - org.projectlombok - lombok - true - - - diff --git a/src/main/java/com/swarm/graphql/MainConfig.java b/src/main/java/com/swarm/graphql/MainConfig.java index 009fe3b..4912311 100644 --- a/src/main/java/com/swarm/graphql/MainConfig.java +++ b/src/main/java/com/swarm/graphql/MainConfig.java @@ -7,117 +7,25 @@ import org.springframework.context.annotation.Configuration; import com.swarm.graphql.model.*; -import com.swarm.graphql.query.Query; -import com.swarm.graphql.query.QueryBreakpoint; -import com.swarm.graphql.query.QueryDeveloper; -import com.swarm.graphql.query.QueryEvent; -import com.swarm.graphql.query.QueryInvocation; -import com.swarm.graphql.query.QueryMethod; -import com.swarm.graphql.query.QueryNamespace; -import com.swarm.graphql.query.QueryProduct; -import com.swarm.graphql.query.QuerySession; -import com.swarm.graphql.query.QueryTask; -import com.swarm.graphql.query.QueryType; -import com.swarm.graphql.repository.*; -import com.swarm.graphql.resolver.*; +import com.swarm.graphql.repository.ArtefactRepository; +import com.swarm.graphql.repository.BreakpointRepository; +import com.swarm.graphql.repository.DeveloperRepository; +import com.swarm.graphql.repository.EventRepository; +import com.swarm.graphql.repository.InvocationRepository; +import com.swarm.graphql.repository.MethodRepository; +import com.swarm.graphql.repository.NamespaceRepository; +import com.swarm.graphql.repository.ProductRepository; +import com.swarm.graphql.repository.SessionRepository; +import com.swarm.graphql.repository.TaskRepository; +import com.swarm.graphql.repository.TypeRepository; @Configuration public class MainConfig { - @Bean - public SessionResolver developerResolver(DeveloperRepository developerRepository, TaskRepository taskRepository) { - return new SessionResolver(developerRepository, taskRepository); - } - - @Bean - public TaskResolver taskResolver(ProductRepository productRepository) { - return new TaskResolver(productRepository); - } - - @Bean - public TypeResolver typeResolver(NamespaceRepository namespaceRepository, SessionRepository sessionRepository) { - return new TypeResolver(namespaceRepository, sessionRepository); - } - - @Bean - public BreakpointResolver breakpointResolver(TypeRepository typeRepository) { - return new BreakpointResolver(typeRepository); - } - - @Bean - public MethodResolver methodResolver(TypeRepository typeRepository) { - return new MethodResolver(typeRepository); - } - - @Bean - public InvocationResolver invocationResolver(SessionRepository sessionRepository, MethodRepository methodRepository) { - return new InvocationResolver(sessionRepository, methodRepository); - } - - @Bean - public EventResolver eventResolver(SessionRepository sessionRepository, MethodRepository methodRepository) { - return new EventResolver(sessionRepository, methodRepository); - } - - @Bean - public Query query() { - return new Query(); - } - - @Bean - public QueryBreakpoint queryBreakPoint(BreakpointRepository breakpointRepository, ProductRepository productRepository) { - return new QueryBreakpoint(breakpointRepository, productRepository); - } - - @Bean - public QueryDeveloper queryDeveloper(DeveloperRepository developerRepository) { - return new QueryDeveloper(developerRepository); - } - - @Bean - public QueryTask queryTask(TaskRepository taskRepository, TypeRepository typeRepository, BreakpointRepository breakpointRepository) { - return new QueryTask(taskRepository, typeRepository, breakpointRepository); - } - - @Bean - - public QueryProduct queryProduct(ProductRepository productRepository,InvocationRepository invocationRepository,TypeRepository typeRepository) { - return new QueryProduct(productRepository, invocationRepository, typeRepository); - } - - @Bean - public QueryNamespace queryNamespace(NamespaceRepository namespaceRepository) { - return new QueryNamespace(namespaceRepository); - } - - @Bean - public QuerySession querySession(SessionRepository sessionRepository, TypeRepository typeRepository, MethodRepository methodRepository, InvocationRepository invocationRepository) { - return new QuerySession(sessionRepository, typeRepository, methodRepository, invocationRepository); - } - - @Bean - public QueryInvocation queryInvocation(InvocationRepository invocationRepository) { - return new QueryInvocation(invocationRepository); - } - - @Bean - public QueryType queryType(TypeRepository typeRepository) { - return new QueryType(typeRepository); - } - - @Bean - public QueryMethod queryMethod(MethodRepository methodRepository, SessionRepository sessionRepository) { - return new QueryMethod(methodRepository, sessionRepository); - } - - @Bean - public QueryEvent queryEvent(EventRepository eventRepository) { - return new QueryEvent(eventRepository); - } - @Bean public CommandLineRunner test( DeveloperRepository developerRepository, + ArtefactRepository artefactRepository, SessionRepository sessionRepository, TaskRepository taskRepository, ProductRepository productRepository, @@ -129,8 +37,24 @@ public CommandLineRunner test( EventRepository eventRepository) { return (args) -> { - Developer developer1 = new Developer("developer1.name", "developer1.color"); - Developer developer2 = new Developer("developer2.name", "developer2.color"); + Developer developer1 = new Developer("Jean-Guy", "developer1.color"); + Developer developer2 = new Developer("Robert", "developer2.color"); + + Artefact artefact1 = new Artefact("public class HelloWorld {\r\n" + + "\r\n" + + " public static void main(String[] args) {\r\n" + + " // Prints \"Hello, World\" to the terminal window.\r\n" + + " System.out.println(\"Hello, World\");\r\n" + + " }\r\n" + + "\r\n" + + "}", 1L); + Artefact artefact2 = new Artefact("class ForLoopExample2 {\r\n" + + " public static void main(String args[]){\r\n" + + " for(int i=1; i>=1; i++){\r\n" + + " System.out.println(\"The value of i is: \"+i);\r\n" + + " }\r\n" + + " }\r\n" + + "}", 4L); Product product1 = new Product("product1.name"); Product product2 = new Product("product2.name"); @@ -146,8 +70,8 @@ public CommandLineRunner test( Namespace namespace1 = new Namespace("namespace1.name","namespace1.fullPath"); Namespace namespace2 = new Namespace("namespace2.name","namespace2.fullPath"); - Type type1 = new Type(namespace1, session1, "type1.fullName","type1.fullPath", "type1.name","type1.source"); - Type type2 = new Type(namespace2, session2, "type2.fullName","type2.fullPath", "type2.name","type2.source"); + Type type1 = new Type(namespace1, session1, "type1.fullName","type1.fullPath", "type1.name",artefact1); + Type type2 = new Type(namespace2, session2, "type2.fullName","type2.fullPath", "type2.name",artefact2); Breakpoint breakpoint1 = new Breakpoint(type1,"breakpoint1.start","breakpoint1.end",59); Breakpoint breakpoint2 = new Breakpoint(type2,"breakpoint2.start","breakpoint2.end",374); @@ -161,6 +85,8 @@ public CommandLineRunner test( developerRepository.save(developer1); developerRepository.save(developer2); + artefactRepository.save(artefact1); + artefactRepository.save(artefact2); productRepository.save(product1); productRepository.save(product2); taskRepository.save(task1); @@ -179,5 +105,7 @@ public CommandLineRunner test( eventRepository.save(event1); }; } + + } diff --git a/src/main/java/com/swarm/graphql/SwarmGraphQlApplication.java b/src/main/java/com/swarm/graphql/SwarmGraphQlApplication.java index 7bcd53d..f3d63cb 100644 --- a/src/main/java/com/swarm/graphql/SwarmGraphQlApplication.java +++ b/src/main/java/com/swarm/graphql/SwarmGraphQlApplication.java @@ -9,4 +9,5 @@ public class SwarmGraphQlApplication { public static void main(String[] args) { SpringApplication.run(SwarmGraphQlApplication.class, args); } + } diff --git a/src/main/java/com/swarm/graphql/model/Artefact.java b/src/main/java/com/swarm/graphql/model/Artefact.java new file mode 100644 index 0000000..1024dd4 --- /dev/null +++ b/src/main/java/com/swarm/graphql/model/Artefact.java @@ -0,0 +1,79 @@ +package com.swarm.graphql.model; + +import java.util.Calendar; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + + +@Entity +public class Artefact { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + String sourceCode; + + @Column(nullable=false) + Long version; + + @Column(name="CREATION_TS", columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable=false, updatable=false) + private Calendar timestamp; + + public Artefact() {} + + public Artefact(String sourceCode, Long version) { + this.sourceCode = sourceCode; + this.version = version; + } + + @Override + public int hashCode() { + return id.hashCode(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Artefact artefact = (Artefact) o; + + return id.equals(artefact.id); + } + + @Override + public String toString() { + return id + ": " + sourceCode; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getSourceCode() + { + return sourceCode; + } + + public void setSourceCode(String sourceCode) { + this.sourceCode = sourceCode; + } + + public Long getVersion() { + return version; + } + + public void setVersion(Long version) { + this.version = version; + } + +} diff --git a/src/main/java/com/swarm/graphql/model/Breakpoint.java b/src/main/java/com/swarm/graphql/model/Breakpoint.java index 4b5a388..e325a64 100644 --- a/src/main/java/com/swarm/graphql/model/Breakpoint.java +++ b/src/main/java/com/swarm/graphql/model/Breakpoint.java @@ -2,11 +2,17 @@ import java.util.Calendar; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + @Entity public class Breakpoint { - + @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; @@ -26,8 +32,7 @@ public class Breakpoint { @Column(name="CREATION_TS", columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable=false, updatable=false) private Calendar timestamp; - public Breakpoint() { - } + public Breakpoint() {} public Breakpoint(Type type, String charStart, String charEnd, Integer lineNumber) { this.type = type; @@ -36,6 +41,26 @@ public Breakpoint(Type type, String charStart, String charEnd, Integer lineNumbe this.lineNumber = lineNumber; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Breakpoint breakpoint = (Breakpoint) o; + + return id.equals(breakpoint.id); + } + + @Override + public int hashCode() { + return id.hashCode(); + } + + @Override + public String toString() { + return id + ": " + lineNumber; + } + public Long getId() { return id; } @@ -75,25 +100,4 @@ public Integer getLineNumber() { public void setLineNumber(Integer lineNumber) { this.lineNumber = lineNumber; } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Breakpoint breakpoint = (Breakpoint) o; - - return id.equals(breakpoint.id); - } - - @Override - public int hashCode() { - return id.hashCode(); - } - - @Override - public String toString() { - return id + ": " + lineNumber; - } - } diff --git a/src/main/java/com/swarm/graphql/model/Developer.java b/src/main/java/com/swarm/graphql/model/Developer.java index 38572be..a4d2fe2 100644 --- a/src/main/java/com/swarm/graphql/model/Developer.java +++ b/src/main/java/com/swarm/graphql/model/Developer.java @@ -2,14 +2,20 @@ import java.util.Calendar; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Transient; + @Entity public class Developer { @Id - @GeneratedValue(strategy=GenerationType.AUTO) - private Long id; + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; @Column(nullable = false) String name; @@ -22,38 +28,37 @@ public class Developer { @Transient boolean logged; - public Developer() { - } - public Developer(String name, String color) { this.name = name; this.color = color; } + public Developer() {} + public Long getId() { - return id; - } - + return id; + } + public void setId(Long id) { - this.id = id; - } - + this.id = id; + } + public String getName() { return name; } - + public void setName(String name) { this.name = name; } - + public String getColor() { return color; } - + public void setColor(String color) { this.color = color; } - + public boolean isLogged() { return logged; } diff --git a/src/main/java/com/swarm/graphql/model/Event.java b/src/main/java/com/swarm/graphql/model/Event.java index 99be098..2fa8ada 100644 --- a/src/main/java/com/swarm/graphql/model/Event.java +++ b/src/main/java/com/swarm/graphql/model/Event.java @@ -2,11 +2,17 @@ import java.util.Calendar; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + @Entity public class Event { - + @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; @@ -30,8 +36,7 @@ public class Event { @Column(name="CREATION_TS", columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable=false, updatable=false) private Calendar timestamp; - public Event() { - } + public Event () {} public Event(Method method, Session session, String charStart, String charEnd, Integer lineNumber, String detail, String kind) { this.method = method; @@ -126,5 +131,5 @@ public int hashCode() { public String toString() { return id + ": " + detail; } - + } diff --git a/src/main/java/com/swarm/graphql/model/Invocation.java b/src/main/java/com/swarm/graphql/model/Invocation.java index 379b551..9feb327 100644 --- a/src/main/java/com/swarm/graphql/model/Invocation.java +++ b/src/main/java/com/swarm/graphql/model/Invocation.java @@ -2,11 +2,18 @@ import java.util.Calendar; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.Transient; + @Entity public class Invocation { - + @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; @@ -26,8 +33,7 @@ public class Invocation { @Transient private boolean isVirtual; - public Invocation() { - } + public Invocation () {} public Invocation(Method invoking, Method invoked, Session session, boolean isVirtual) { this.invoking = invoking; @@ -95,5 +101,5 @@ public int hashCode() { public String toString() { return invoking.getId() + ": " + invoking.getKey() + " -> " + invoked.getId() + ": " + invoked.getKey(); } - + } diff --git a/src/main/java/com/swarm/graphql/model/Method.java b/src/main/java/com/swarm/graphql/model/Method.java index a55a32a..37751a3 100644 --- a/src/main/java/com/swarm/graphql/model/Method.java +++ b/src/main/java/com/swarm/graphql/model/Method.java @@ -2,11 +2,17 @@ import java.util.Calendar; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + @Entity public class Method { - + @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; @@ -26,8 +32,7 @@ public class Method { @Column(name="CREATION_TS", columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable=false, updatable=false) private Calendar timestamp; - public Method() { - } + public Method () {} public Method(Type type, String key, String name, String signature) { this.type = type; @@ -95,5 +100,5 @@ public int hashCode() { public String toString() { return type.getFullName() +"." + this.name; } - + } diff --git a/src/main/java/com/swarm/graphql/model/Namespace.java b/src/main/java/com/swarm/graphql/model/Namespace.java index a5cea5d..ca4c16e 100644 --- a/src/main/java/com/swarm/graphql/model/Namespace.java +++ b/src/main/java/com/swarm/graphql/model/Namespace.java @@ -2,39 +2,63 @@ import java.util.Calendar; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + @Entity public class Namespace { @Id @GeneratedValue(strategy=GenerationType.AUTO) - private Long id; - + private Long id; + @Column(nullable = false) String name; - + @Column(nullable = false) String fullPath; @Column(name="CREATION_TS", columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable=false, updatable=false) private Calendar timestamp; - public Namespace() { - } + public Namespace() {} public Namespace(String name, String fullPath) { this.name = name; this.fullPath = fullPath; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Namespace namespace = (Namespace) o; + + return id.equals(namespace.id); + } + + @Override + public int hashCode() { + return id.hashCode(); + } + + @Override + public String toString() { + return id + ": " + name; + } + public Long getId() { return id; } public void setId(Long id) { this.id = id; - } + } public String getName() { return name; @@ -51,25 +75,5 @@ public String getFullPath() { public void setFullPath(String fullPath) { this.fullPath = fullPath; } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Namespace namespace = (Namespace) o; - - return id.equals(namespace.id); - } - - @Override - public int hashCode() { - return id.hashCode(); - } - - @Override - public String toString() { - return id + ": " + name; - } } diff --git a/src/main/java/com/swarm/graphql/model/Product.java b/src/main/java/com/swarm/graphql/model/Product.java index b812bbc..8666348 100644 --- a/src/main/java/com/swarm/graphql/model/Product.java +++ b/src/main/java/com/swarm/graphql/model/Product.java @@ -2,40 +2,45 @@ import java.util.Calendar; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +import com.swarm.graphql.model.Product; @Entity public class Product { @Id - @GeneratedValue(strategy=GenerationType.AUTO) - private Long id; + @GeneratedValue(strategy=GenerationType.AUTO) + private Long id; @Column(nullable = false) String name; @Column(name="CREATION_TS", columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable=false, updatable=false) private Calendar timestamp; - - public Product() { - } - + public Product(String name) { this.name = name; } + public Product() {} + public Long getId() { return id; } - + public void setId(Long id) { this.id = id; } - + public String getName() { return name; } - + public void setName(String name) { this.name = name; } @@ -59,5 +64,4 @@ public int hashCode() { public String toString() { return id + ": " + name; } - } diff --git a/src/main/java/com/swarm/graphql/model/Session.java b/src/main/java/com/swarm/graphql/model/Session.java index 42cc508..2bee53f 100644 --- a/src/main/java/com/swarm/graphql/model/Session.java +++ b/src/main/java/com/swarm/graphql/model/Session.java @@ -3,11 +3,19 @@ import java.util.Calendar; import java.util.Date; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + @Entity public class Session { - + @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; @@ -35,8 +43,7 @@ public class Session { @Temporal(TemporalType.TIMESTAMP) private Date finished; - public Session() { - } + public Session () {} public Session(Developer developer, Task task, String description, String label, String purpose, String project, Date started, Date finished) { this.developer = developer; @@ -140,5 +147,5 @@ public int hashCode() { public String toString() { return id + ": " + description; } - + } diff --git a/src/main/java/com/swarm/graphql/model/Task.java b/src/main/java/com/swarm/graphql/model/Task.java index fae1b22..31d9ff9 100644 --- a/src/main/java/com/swarm/graphql/model/Task.java +++ b/src/main/java/com/swarm/graphql/model/Task.java @@ -2,7 +2,13 @@ import java.util.Calendar; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + @Entity public class Task { @@ -23,8 +29,7 @@ public class Task { @Column(name="CREATION_TS", columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable=false, updatable=false) private Calendar timestamp; - public Task() { - } + public Task () {} public Task(Product product, String title, String url, String color) { this.product = product; @@ -32,7 +37,7 @@ public Task(Product product, String title, String url, String color) { this.url = url; this.color = color; } - + public Long getId() { return id; } @@ -41,6 +46,14 @@ public void setId(Long id) { this.id = id; } + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + public String getTitle() { return title; } @@ -56,7 +69,7 @@ public String getUrl() { public void setUrl(String url) { this.url = url; } - + public String getColor() { return color; } @@ -65,14 +78,6 @@ public void setColor(String color) { this.color = color; } - public Product getProduct() { - return product; - } - - public void setProduct(Product product) { - this.product = product; - } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/com/swarm/graphql/model/Type.java b/src/main/java/com/swarm/graphql/model/Type.java index 20b2173..b638e46 100644 --- a/src/main/java/com/swarm/graphql/model/Type.java +++ b/src/main/java/com/swarm/graphql/model/Type.java @@ -2,11 +2,17 @@ import java.util.Calendar; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + @Entity public class Type { - + @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; @@ -26,22 +32,21 @@ public class Type { @Column(nullable = false) String name; - @Column(length = 1000000) - String source; - + @ManyToOne + private Artefact artefact; + @Column(name="CREATION_TS", columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable=false, updatable=false) private Calendar timestamp; - public Type() { - } + public Type () {} - public Type(Namespace namespace, Session session, String fullName, String fullPath, String name, String source) { + public Type(Namespace namespace, Session session, String fullName, String fullPath, String name, Artefact artefact) { this.namespace = namespace; this.session = session; this.fullName = fullName; this.fullPath = fullPath; this.name = name; - this.source = source; + this.artefact = artefact; } public Long getId() { @@ -92,12 +97,12 @@ public void setName(String name) { this.name = name; } - public String getSource() { - return source; + public Artefact getArtefact() { + return artefact; } - public void setSource(String source) { - this.source = source; + public void setArtefact(Artefact artefact) { + this.artefact = artefact; } @Override @@ -119,5 +124,5 @@ public int hashCode() { public String toString() { return id + ": " + fullName; } - + } diff --git a/src/main/java/com/swarm/graphql/query/Query.java b/src/main/java/com/swarm/graphql/query/Query.java deleted file mode 100644 index a676b29..0000000 --- a/src/main/java/com/swarm/graphql/query/Query.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.swarm.graphql.query; - -import com.coxautodev.graphql.tools.GraphQLQueryResolver; - -public class Query implements GraphQLQueryResolver { - - public String hello() { - return "hello"; - } -} diff --git a/src/main/java/com/swarm/graphql/query/QueryDeveloper.java b/src/main/java/com/swarm/graphql/query/QueryDeveloper.java deleted file mode 100644 index 2e7daaa..0000000 --- a/src/main/java/com/swarm/graphql/query/QueryDeveloper.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.swarm.graphql.query; - -import com.coxautodev.graphql.tools.GraphQLQueryResolver; -import com.swarm.graphql.repository.DeveloperRepository; -import com.swarm.graphql.repository.SessionRepository; - -public class QueryDeveloper implements GraphQLQueryResolver{ - - private DeveloperRepository developerRepository; - - public QueryDeveloper(DeveloperRepository developerRepository) { - this.developerRepository = developerRepository; - } - -} diff --git a/src/main/java/com/swarm/graphql/query/QueryEvent.java b/src/main/java/com/swarm/graphql/query/QueryEvent.java deleted file mode 100644 index 0c346f3..0000000 --- a/src/main/java/com/swarm/graphql/query/QueryEvent.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.swarm.graphql.query; - -import com.coxautodev.graphql.tools.GraphQLQueryResolver; -import com.swarm.graphql.repository.EventRepository; - -public class QueryEvent implements GraphQLQueryResolver{ - - private EventRepository eventRepository; - - public QueryEvent(EventRepository eventRepository) { - this.eventRepository = eventRepository; - } - - -} diff --git a/src/main/java/com/swarm/graphql/query/QueryInvocation.java b/src/main/java/com/swarm/graphql/query/QueryInvocation.java deleted file mode 100644 index f12dc5d..0000000 --- a/src/main/java/com/swarm/graphql/query/QueryInvocation.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.swarm.graphql.query; - -import com.coxautodev.graphql.tools.GraphQLQueryResolver; -import com.swarm.graphql.model.*; -import com.swarm.graphql.repository.InvocationRepository; - -public class QueryInvocation implements GraphQLQueryResolver{ - - private InvocationRepository invocationRepository; - - public QueryInvocation(InvocationRepository invocationRepository) { - this.invocationRepository = invocationRepository; - } - - public Iterable invocationsByMethods(Long sessionId, Long invokingId, Long invokedId){ - return invocationRepository.findByMethods(sessionId, invokingId, invokedId); - } - -} diff --git a/src/main/java/com/swarm/graphql/query/QueryMethod.java b/src/main/java/com/swarm/graphql/query/QueryMethod.java deleted file mode 100644 index d418420..0000000 --- a/src/main/java/com/swarm/graphql/query/QueryMethod.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.swarm.graphql.query; - -import com.coxautodev.graphql.tools.GraphQLQueryResolver; -import com.swarm.graphql.model.Method; -import com.swarm.graphql.model.Session; -import com.swarm.graphql.repository.*; - -public class QueryMethod implements GraphQLQueryResolver { - - private MethodRepository methodRepository; - private SessionRepository sessionRepository; - - public QueryMethod(MethodRepository methodRepository, SessionRepository sessionRepository) { - this.methodRepository = methodRepository; - this.sessionRepository = sessionRepository; - } - - public Iterable methodsByTypeId(Long typeId){ - return methodRepository.findByTypeId(typeId); - } - - public Iterable startingMethodsBySessionId(Long sessionId){ - Session session = sessionRepository.findOne(sessionId); - return methodRepository.getStartingMethods(session); - } - - public Iterable endingMethodsBySessionId(Long sessionId){ - Session session = sessionRepository.findOne(sessionId); - return methodRepository.getEndingMethods(session); - } - -} diff --git a/src/main/java/com/swarm/graphql/query/QueryNamespace.java b/src/main/java/com/swarm/graphql/query/QueryNamespace.java deleted file mode 100644 index 182e7db..0000000 --- a/src/main/java/com/swarm/graphql/query/QueryNamespace.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.swarm.graphql.query; - -import com.coxautodev.graphql.tools.GraphQLQueryResolver; -import com.swarm.graphql.model.Namespace; -import com.swarm.graphql.repository.NamespaceRepository; - -public class QueryNamespace implements GraphQLQueryResolver{ - - private NamespaceRepository namespaceRepository; - - public QueryNamespace(NamespaceRepository namespaceRepository) { - this.namespaceRepository = namespaceRepository; - } - - public Namespace namespaceByFullPath(String fullPath){ - return namespaceRepository.findByFullPath(fullPath); - } - -} diff --git a/src/main/java/com/swarm/graphql/query/QueryType.java b/src/main/java/com/swarm/graphql/query/QueryType.java deleted file mode 100644 index 7c51156..0000000 --- a/src/main/java/com/swarm/graphql/query/QueryType.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.swarm.graphql.query; - -import com.coxautodev.graphql.tools.GraphQLQueryResolver; -import com.swarm.graphql.model.*; -import com.swarm.graphql.repository.TypeRepository; - -public class QueryType implements GraphQLQueryResolver{ - - private TypeRepository typeRepository; - - public QueryType(TypeRepository typeRepository) { - this.typeRepository = typeRepository; - } - - public Iterable typesBySessionId(Long sessionId){ - return typeRepository.findBySessionId(sessionId); - } - -} diff --git a/src/main/java/com/swarm/graphql/repository/ArtefactRepository.java b/src/main/java/com/swarm/graphql/repository/ArtefactRepository.java new file mode 100644 index 0000000..eaa4b3b --- /dev/null +++ b/src/main/java/com/swarm/graphql/repository/ArtefactRepository.java @@ -0,0 +1,9 @@ +package com.swarm.graphql.repository; + +import org.springframework.data.repository.CrudRepository; + +import com.swarm.graphql.model.Artefact; + +public interface ArtefactRepository extends CrudRepository { + +} diff --git a/src/main/java/com/swarm/graphql/repository/BreakpointRepository.java b/src/main/java/com/swarm/graphql/repository/BreakpointRepository.java index 09bcaa4..be9fcbe 100644 --- a/src/main/java/com/swarm/graphql/repository/BreakpointRepository.java +++ b/src/main/java/com/swarm/graphql/repository/BreakpointRepository.java @@ -1,27 +1,27 @@ package com.swarm.graphql.repository; import java.util.List; +import java.util.Optional; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.query.Param; -import com.swarm.graphql.model.Breakpoint; import com.swarm.graphql.model.*; public interface BreakpointRepository extends CrudRepository { - + @Query("Select b from Breakpoint b Where b.type = :type order by b.lineNumber") List findByType(@Param("type") Type type); @Query("Select b from Breakpoint b Where b.type.session.task = :task and b.type.fullName = :fullName order by b.lineNumber") - List findByTaskAndType(@Param("task") Task task, @Param("fullName") String fullName); + List findByTaskAndType(@Param("task") Optional task, @Param("fullName") String fullName); @Query("Select b from Breakpoint b Where b.type.fullName = :fullName order by b.lineNumber") List findByTypeFullName(@Param("fullName") String fullName); @Query("Select count(b) from Breakpoint b Where b.type.session.task = :task and b.type.fullName = :fullName") - int countByTaskAndType(@Param("task") Task task, @Param("fullName") String fullName); + int countByTaskAndType(@Param("task") Optional task, @Param("fullName") String fullName); int countByType(Type type); @@ -29,6 +29,5 @@ public interface BreakpointRepository extends CrudRepository { List findByTaskId(@Param("taskId") Long taskId); @Query("Select b from Breakpoint b Where b.type.session.task.product = :product order by b.lineNumber") - List findByProduct(@Param("product") Product product); - + List findByProduct(@Param("product") Optional product); } diff --git a/src/main/java/com/swarm/graphql/repository/DeveloperRepository.java b/src/main/java/com/swarm/graphql/repository/DeveloperRepository.java index 29bf2db..de9a6e3 100644 --- a/src/main/java/com/swarm/graphql/repository/DeveloperRepository.java +++ b/src/main/java/com/swarm/graphql/repository/DeveloperRepository.java @@ -8,10 +8,8 @@ import com.swarm.graphql.model.Developer; public interface DeveloperRepository extends CrudRepository { - - Developer findById(@Param("id") Long id); + Developer findByNameAllIgnoringCase(@Param("name") String name); Page findByName(@Param("name") String name, Pageable pageable); - } diff --git a/src/main/java/com/swarm/graphql/repository/InvocationRepository.java b/src/main/java/com/swarm/graphql/repository/InvocationRepository.java index a166e5b..bf05c52 100644 --- a/src/main/java/com/swarm/graphql/repository/InvocationRepository.java +++ b/src/main/java/com/swarm/graphql/repository/InvocationRepository.java @@ -1,32 +1,36 @@ package com.swarm.graphql.repository; import java.util.List; +import java.util.Optional; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.query.Param; import com.swarm.graphql.model.Invocation; -import com.swarm.graphql.model.*; +import com.swarm.graphql.model.Method; +import com.swarm.graphql.model.Product; +import com.swarm.graphql.model.Session; +import com.swarm.graphql.model.Task; public interface InvocationRepository extends CrudRepository { - + @Query("Select i from Invocation i Where i.session.id = :sessionId and i.invoking.id = :invokingId and i.invoked.id = :invokedId") List findByMethods(@Param("sessionId") Long sessionId, @Param("invokingId") Long invokingId, @Param("invokedId") Long invokedId); @Query("Select count(i) from Invocation i where i.session = :session and (i.invoking = :method or i.invoked = :method)") - int countInvocations(@Param("session") Session session, @Param("method") Method method); + int countInvocations(@Param("session") Optional session, @Param("method") Method method); @Query("from Invocation as i where i.session = :session order by i.id") - List findBySession(@Param("session") Session session); + List findBySession(@Param("session") Optional session); - int countBySession(Session session); + int countBySession(Optional session); @Query("from Invocation as i where i.session.task = :task order by i.id") List findBySession(@Param("task") Task task); @Query("from Invocation as i Where i.session.task.product = :product") - List findByProduct(@Param("product") Product product); - + List findByProduct(@Param("product") Optional product); + } diff --git a/src/main/java/com/swarm/graphql/repository/MethodRepository.java b/src/main/java/com/swarm/graphql/repository/MethodRepository.java index 5479d0e..f36c538 100644 --- a/src/main/java/com/swarm/graphql/repository/MethodRepository.java +++ b/src/main/java/com/swarm/graphql/repository/MethodRepository.java @@ -1,29 +1,32 @@ package com.swarm.graphql.repository; import java.util.List; +import java.util.Optional; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.query.Param; -import com.swarm.graphql.model.*; +import com.swarm.graphql.model.Method; +import com.swarm.graphql.model.Session; +import com.swarm.graphql.model.Type; public interface MethodRepository extends CrudRepository { - + @Query("Select m From Method m Where m.type.id = :typeId") List findByTypeId(@Param("typeId") Long typeId); List findByType(@Param("type") Type type); @Query("Select count(m) From Method m Where m.type.session = :session") - int countBySession(@Param("session") Session session); + int countBySession(@Param("session") Optional session); @Query("select m from Method m, Type t, Session s where m.type = t and t.session = s and s = :session " + "and m not in (select i.invoked from Invocation i group by i.invoked) order by m.id") - List getStartingMethods(@Param("session") Session session); + List getStartingMethods(@Param("session") Optional session); @Query("select m from Method m, Type t, Session s where m.type = t and t.session = s and s = :session " + "and m not in (select i.invoking from Invocation i group by i.invoking) order by m.id") - List getEndingMethods(@Param("session") Session session); - + List getEndingMethods(@Param("session") Optional session); + } diff --git a/src/main/java/com/swarm/graphql/repository/NamespaceRepository.java b/src/main/java/com/swarm/graphql/repository/NamespaceRepository.java index f9c2aad..44b5d48 100644 --- a/src/main/java/com/swarm/graphql/repository/NamespaceRepository.java +++ b/src/main/java/com/swarm/graphql/repository/NamespaceRepository.java @@ -6,7 +6,7 @@ import com.swarm.graphql.model.Namespace; public interface NamespaceRepository extends CrudRepository { - + Namespace findByFullPath(@Param("fullPath") String fullPath); } diff --git a/src/main/java/com/swarm/graphql/repository/SessionRepository.java b/src/main/java/com/swarm/graphql/repository/SessionRepository.java index 5933c8b..43a9a1f 100644 --- a/src/main/java/com/swarm/graphql/repository/SessionRepository.java +++ b/src/main/java/com/swarm/graphql/repository/SessionRepository.java @@ -1,6 +1,7 @@ package com.swarm.graphql.repository; import java.util.List; +import java.util.Optional; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; @@ -9,11 +10,11 @@ import com.swarm.graphql.model.Session; public interface SessionRepository extends CrudRepository { - + @Query("Select s from Session s Where task.id = :taskId and developer.id = :developerId ") List findByTaskAndDeveloper(@Param("taskId") Long taskId, @Param("developerId") Long developerId); @Query("Select s from Session s Where task.id = :taskId") - List findByTask(@Param("taskId") Long taskId); - + List> findByTask(@Param("taskId") Long taskId); + } diff --git a/src/main/java/com/swarm/graphql/repository/TypeRepository.java b/src/main/java/com/swarm/graphql/repository/TypeRepository.java index e912577..56fe554 100644 --- a/src/main/java/com/swarm/graphql/repository/TypeRepository.java +++ b/src/main/java/com/swarm/graphql/repository/TypeRepository.java @@ -1,23 +1,28 @@ package com.swarm.graphql.repository; import java.util.List; +import java.util.Optional; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.query.Param; -import com.swarm.graphql.model.*; +import com.swarm.graphql.model.Product; +import com.swarm.graphql.model.Session; +import com.swarm.graphql.model.Task; +import com.swarm.graphql.model.Type; + public interface TypeRepository extends CrudRepository { - + @Query("Select t from Type t Where t.session.id = :sessionId") List findBySessionId(@Param("sessionId") Long sessionId); - List findBySession(@Param("session") Session session); + List findBySession(@Param("session") Optional session); @Query("Select t from Type t Where t.session.task = :task order by t.fullName") - List findByTask(@Param("task") Task task); + List findByTask(@Param("task") Optional task); @Query("Select t.fullName from Type t Where t.session.task.product = :product group by fullName order by t.fullName") - List findFullNamesByProduct(@Param("product") Product product); - + List findFullNamesByProduct(@Param("product") Optional product); + } diff --git a/src/main/java/com/swarm/graphql/resolver/BreakpointResolver.java b/src/main/java/com/swarm/graphql/resolver/BreakpointResolver.java deleted file mode 100644 index 1cea797..0000000 --- a/src/main/java/com/swarm/graphql/resolver/BreakpointResolver.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.swarm.graphql.resolver; - -import com.coxautodev.graphql.tools.GraphQLResolver; -import com.swarm.graphql.model.*; -import com.swarm.graphql.repository.*; - -public class BreakpointResolver implements GraphQLResolver { - private TypeRepository typeRepository; - - public BreakpointResolver(TypeRepository typeRepository) { - this.typeRepository = typeRepository; - } - - public Type getType(Breakpoint breakpoint) { - return typeRepository.findOne(breakpoint.getType().getId()); - } - -} diff --git a/src/main/java/com/swarm/graphql/resolver/EventResolver.java b/src/main/java/com/swarm/graphql/resolver/EventResolver.java deleted file mode 100644 index edbc32c..0000000 --- a/src/main/java/com/swarm/graphql/resolver/EventResolver.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.swarm.graphql.resolver; - -import com.coxautodev.graphql.tools.GraphQLResolver; -import com.swarm.graphql.model.*; -import com.swarm.graphql.repository.*; - -public class EventResolver implements GraphQLResolver { - private SessionRepository sessionRepository; - private MethodRepository methodRepository; - - public EventResolver(SessionRepository sessionRepository, MethodRepository methodRepository) { - this.sessionRepository = sessionRepository; - this.methodRepository = methodRepository; - } - - public Session getSession(Event event) { - return sessionRepository.findOne(event.getSession().getId()); - } - - public Method getMethod(Event event) { - return methodRepository.findOne(event.getMethod().getId()); - } - -} diff --git a/src/main/java/com/swarm/graphql/resolver/InvocationResolver.java b/src/main/java/com/swarm/graphql/resolver/InvocationResolver.java deleted file mode 100644 index 60b5ea6..0000000 --- a/src/main/java/com/swarm/graphql/resolver/InvocationResolver.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.swarm.graphql.resolver; - -import com.coxautodev.graphql.tools.GraphQLResolver; -import com.swarm.graphql.model.*; -import com.swarm.graphql.repository.*; - -public class InvocationResolver implements GraphQLResolver { - private SessionRepository sessionRepository; - private MethodRepository methodRepository; - - public InvocationResolver(SessionRepository sessionRepository, MethodRepository methodRepository) { - this.sessionRepository = sessionRepository; - this.methodRepository = methodRepository; - } - - public Session getSession(Invocation invocation) { - return sessionRepository.findOne(invocation.getSession().getId()); - } - - public Method getMethodInvoked(Invocation invocation) { - return methodRepository.findOne(invocation.getInvoked().getId()); - } - - public Method getMethodInvoking(Invocation invocation) { - return methodRepository.findOne(invocation.getInvoking().getId()); - } - -} diff --git a/src/main/java/com/swarm/graphql/resolver/MethodResolver.java b/src/main/java/com/swarm/graphql/resolver/MethodResolver.java deleted file mode 100644 index 274516e..0000000 --- a/src/main/java/com/swarm/graphql/resolver/MethodResolver.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.swarm.graphql.resolver; - -import com.coxautodev.graphql.tools.GraphQLResolver; -import com.swarm.graphql.model.*; -import com.swarm.graphql.repository.*; - -public class MethodResolver implements GraphQLResolver { - private TypeRepository typeRepository; - - public MethodResolver(TypeRepository typeRepository) { - this.typeRepository = typeRepository; - } - - public Type getType(Method method) { - return typeRepository.findOne(method.getType().getId()); - } - -} diff --git a/src/main/java/com/swarm/graphql/resolver/SessionResolver.java b/src/main/java/com/swarm/graphql/resolver/SessionResolver.java deleted file mode 100644 index 34dfcfd..0000000 --- a/src/main/java/com/swarm/graphql/resolver/SessionResolver.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.swarm.graphql.resolver; - - -import com.coxautodev.graphql.tools.GraphQLResolver; -import com.swarm.graphql.model.*; -import com.swarm.graphql.repository.*; - -public class SessionResolver implements GraphQLResolver { - private DeveloperRepository developerRepository; - private TaskRepository taskRepository; - - public SessionResolver(DeveloperRepository developerRepository, TaskRepository taskRepository) { - this.developerRepository = developerRepository; - this.taskRepository = taskRepository; - } - - public Developer getDeveloper(Session session) { - return developerRepository.findOne(session.getDeveloper().getId()); - } - - public Task getTask(Session session) { - return taskRepository.findOne(session.getTask().getId()); - } -} diff --git a/src/main/java/com/swarm/graphql/resolver/TaskResolver.java b/src/main/java/com/swarm/graphql/resolver/TaskResolver.java deleted file mode 100644 index 0614e67..0000000 --- a/src/main/java/com/swarm/graphql/resolver/TaskResolver.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.swarm.graphql.resolver; - -import com.coxautodev.graphql.tools.GraphQLResolver; -import com.swarm.graphql.model.Product; -import com.swarm.graphql.model.Task; -import com.swarm.graphql.repository.ProductRepository; - -public class TaskResolver implements GraphQLResolver { - private ProductRepository productRepository; - - public TaskResolver(ProductRepository productRepository) { - this.productRepository = productRepository; - } - - public Product getProduct(Task task) { - return productRepository.findOne(task.getProduct().getId()); - } - -} diff --git a/src/main/java/com/swarm/graphql/resolver/TypeResolver.java b/src/main/java/com/swarm/graphql/resolver/TypeResolver.java deleted file mode 100644 index 3845a8a..0000000 --- a/src/main/java/com/swarm/graphql/resolver/TypeResolver.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.swarm.graphql.resolver; - -import com.coxautodev.graphql.tools.GraphQLResolver; -import com.swarm.graphql.model.*; -import com.swarm.graphql.repository.*; - -public class TypeResolver implements GraphQLResolver { - private NamespaceRepository namespaceRepository; - private SessionRepository sessionRepository; - - public TypeResolver(NamespaceRepository namespaceRepository, SessionRepository sessionRepository) { - this.namespaceRepository = namespaceRepository; - this.sessionRepository = sessionRepository; - } - - public Namespace getNamespace(Type type) { - return namespaceRepository.findOne(type.getNamespace().getId()); - } - - public Session getSession(Type type) { - return sessionRepository.findOne(type.getNamespace().getId()); - } - -} diff --git a/src/main/java/com/swarm/graphql/service/ArtefactService.java b/src/main/java/com/swarm/graphql/service/ArtefactService.java new file mode 100644 index 0000000..be98bac --- /dev/null +++ b/src/main/java/com/swarm/graphql/service/ArtefactService.java @@ -0,0 +1,33 @@ +package com.swarm.graphql.service; + +import java.util.Optional; + +import org.springframework.stereotype.Service; + +import com.swarm.graphql.model.Artefact; +import com.swarm.graphql.repository.ArtefactRepository; + +import io.leangen.graphql.annotations.GraphQLQuery; +import io.leangen.graphql.spqr.spring.annotation.GraphQLApi; + +@GraphQLApi +@Service +public class ArtefactService { + + private ArtefactRepository artefactRepository; + + public ArtefactService(ArtefactRepository artefactRepository) { + this.artefactRepository = artefactRepository; + } + + @GraphQLQuery + public Iterable allArtefacts() { + return artefactRepository.findAll(); + } + + @GraphQLQuery + public Optional ArtefactById(Long artefactId) { + return artefactRepository.findById(artefactId); + } + +} diff --git a/src/main/java/com/swarm/graphql/query/QueryBreakpoint.java b/src/main/java/com/swarm/graphql/service/BreakpointService.java similarity index 71% rename from src/main/java/com/swarm/graphql/query/QueryBreakpoint.java rename to src/main/java/com/swarm/graphql/service/BreakpointService.java index 6a37753..ec177ee 100644 --- a/src/main/java/com/swarm/graphql/query/QueryBreakpoint.java +++ b/src/main/java/com/swarm/graphql/service/BreakpointService.java @@ -1,34 +1,43 @@ -package com.swarm.graphql.query; +package com.swarm.graphql.service; import java.util.List; +import java.util.Optional; + +import org.springframework.stereotype.Service; -import com.coxautodev.graphql.tools.GraphQLQueryResolver; import com.swarm.graphql.model.Breakpoint; import com.swarm.graphql.model.Product; import com.swarm.graphql.repository.BreakpointRepository; import com.swarm.graphql.repository.ProductRepository; -public class QueryBreakpoint implements GraphQLQueryResolver{ +import io.leangen.graphql.annotations.GraphQLQuery; +import io.leangen.graphql.spqr.spring.annotation.GraphQLApi; +@Service +@GraphQLApi +public class BreakpointService { + private BreakpointRepository breakpointRepository; private ProductRepository productRepository; - public QueryBreakpoint(BreakpointRepository breakpointRepository, ProductRepository productRepository) { - this.breakpointRepository = breakpointRepository; - this.productRepository = productRepository; + public BreakpointService(BreakpointRepository breakpointRepo, ProductRepository productRepo) { + this.breakpointRepository = breakpointRepo; + this.productRepository = productRepo; } - + @GraphQLQuery public Iterable allBreakpoints() { return breakpointRepository.findAll(); } + @GraphQLQuery public Iterable breakpointsByTaskId(Long taskId){ return breakpointRepository.findByTaskId(taskId); } + @GraphQLQuery(name = "getTable") public String getTable(Long productId) { - Product product = productRepository.findOne(productId); + Optional product = productRepository.findById(productId); List breakpoints = breakpointRepository.findByProduct(product); StringBuffer buffer = new StringBuffer("{"); diff --git a/src/main/java/com/swarm/graphql/service/DeveloperService.java b/src/main/java/com/swarm/graphql/service/DeveloperService.java new file mode 100644 index 0000000..0a2566c --- /dev/null +++ b/src/main/java/com/swarm/graphql/service/DeveloperService.java @@ -0,0 +1,26 @@ +package com.swarm.graphql.service; + +import org.springframework.stereotype.Service; + +import com.swarm.graphql.model.Developer; +import com.swarm.graphql.repository.DeveloperRepository; + +import io.leangen.graphql.annotations.GraphQLQuery; +import io.leangen.graphql.spqr.spring.annotation.GraphQLApi; + +@GraphQLApi +@Service +public class DeveloperService { + + private DeveloperRepository developerRepo; + + public DeveloperService(DeveloperRepository developerRepo) { + this.developerRepo = developerRepo; + } + + @GraphQLQuery + public Iterable allDevelopers() { + return developerRepo.findAll(); + } + +} diff --git a/src/main/java/com/swarm/graphql/service/EventService.java b/src/main/java/com/swarm/graphql/service/EventService.java new file mode 100644 index 0000000..b5f5bb6 --- /dev/null +++ b/src/main/java/com/swarm/graphql/service/EventService.java @@ -0,0 +1,19 @@ +package com.swarm.graphql.service; + +import org.springframework.stereotype.Service; + +import com.swarm.graphql.repository.EventRepository; + +import io.leangen.graphql.spqr.spring.annotation.GraphQLApi; + +@GraphQLApi +@Service +public class EventService { + + private EventRepository eventRepository; + + public EventService(EventRepository eventRepository) { + this.eventRepository = eventRepository; + } + +} diff --git a/src/main/java/com/swarm/graphql/service/InvocationService.java b/src/main/java/com/swarm/graphql/service/InvocationService.java new file mode 100644 index 0000000..f15dd63 --- /dev/null +++ b/src/main/java/com/swarm/graphql/service/InvocationService.java @@ -0,0 +1,26 @@ +package com.swarm.graphql.service; + +import org.springframework.stereotype.Service; + +import com.swarm.graphql.model.Invocation; +import com.swarm.graphql.repository.InvocationRepository; + +import io.leangen.graphql.annotations.GraphQLQuery; +import io.leangen.graphql.spqr.spring.annotation.GraphQLApi; + +@GraphQLApi +@Service +public class InvocationService { + + private InvocationRepository invocationRepository; + + public InvocationService(InvocationRepository invocationRepository) { + this.invocationRepository = invocationRepository; + } + + @GraphQLQuery + public Iterable invocationsByMethods(Long sessionId, Long invokingId, Long invokedId){ + return invocationRepository.findByMethods(sessionId, invokingId, invokedId); + } + +} diff --git a/src/main/java/com/swarm/graphql/service/MethodService.java b/src/main/java/com/swarm/graphql/service/MethodService.java new file mode 100644 index 0000000..a61d4b2 --- /dev/null +++ b/src/main/java/com/swarm/graphql/service/MethodService.java @@ -0,0 +1,44 @@ +package com.swarm.graphql.service; + +import java.util.Optional; + +import org.springframework.stereotype.Service; + +import com.swarm.graphql.model.Method; +import com.swarm.graphql.model.Session; +import com.swarm.graphql.repository.MethodRepository; +import com.swarm.graphql.repository.SessionRepository; + +import io.leangen.graphql.annotations.GraphQLQuery; +import io.leangen.graphql.spqr.spring.annotation.GraphQLApi; + +@GraphQLApi +@Service +public class MethodService { + + private MethodRepository methodRepository; + private SessionRepository sessionRepository; + + public MethodService(MethodRepository methodRepository, SessionRepository sessionRepository) { + this.methodRepository = methodRepository; + this.sessionRepository = sessionRepository; + } + + @GraphQLQuery + public Iterable methodsByTypeId(Long typeId){ + return methodRepository.findByTypeId(typeId); + } + + @GraphQLQuery + public Iterable startingMethodsBySessionId(Long sessionId){ + Optional session = sessionRepository.findById(sessionId); + return methodRepository.getStartingMethods(session); + } + + @GraphQLQuery + public Iterable endingMethodsBySessionId(Long sessionId){ + Optional session = sessionRepository.findById(sessionId); + return methodRepository.getEndingMethods(session); + } + +} diff --git a/src/main/java/com/swarm/graphql/service/NamespaceService.java b/src/main/java/com/swarm/graphql/service/NamespaceService.java new file mode 100644 index 0000000..9c15c9a --- /dev/null +++ b/src/main/java/com/swarm/graphql/service/NamespaceService.java @@ -0,0 +1,26 @@ +package com.swarm.graphql.service; + +import org.springframework.stereotype.Service; + +import com.swarm.graphql.model.Namespace; +import com.swarm.graphql.repository.NamespaceRepository; + +import io.leangen.graphql.annotations.GraphQLQuery; +import io.leangen.graphql.spqr.spring.annotation.GraphQLApi; + +@GraphQLApi +@Service +public class NamespaceService { + + private NamespaceRepository namespaceRepo; + + public NamespaceService(NamespaceRepository namespaceRepo) { + this.namespaceRepo = namespaceRepo; + } + + @GraphQLQuery + public Namespace namespaceByFullPath(String fullPath){ + return namespaceRepo.findByFullPath(fullPath); + } + +} diff --git a/src/main/java/com/swarm/graphql/query/QueryProduct.java b/src/main/java/com/swarm/graphql/service/ProductService.java similarity index 88% rename from src/main/java/com/swarm/graphql/query/QueryProduct.java rename to src/main/java/com/swarm/graphql/service/ProductService.java index 8302725..46702fa 100644 --- a/src/main/java/com/swarm/graphql/query/QueryProduct.java +++ b/src/main/java/com/swarm/graphql/service/ProductService.java @@ -1,34 +1,40 @@ -package com.swarm.graphql.query; +package com.swarm.graphql.service; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; + +import org.springframework.stereotype.Service; -import com.coxautodev.graphql.tools.GraphQLQueryResolver; import com.swarm.graphql.model.Invocation; import com.swarm.graphql.model.Product; import com.swarm.graphql.repository.InvocationRepository; import com.swarm.graphql.repository.ProductRepository; import com.swarm.graphql.repository.TypeRepository; -public class QueryProduct implements GraphQLQueryResolver{ +import io.leangen.graphql.annotations.GraphQLQuery; +import io.leangen.graphql.spqr.spring.annotation.GraphQLApi; + +@GraphQLApi +@Service +public class ProductService { private ProductRepository productRepository; private InvocationRepository invocationRepository; private TypeRepository typeRepository; - - public QueryProduct(ProductRepository productRepository,InvocationRepository invocationRepository,TypeRepository typeRepository) { - + public ProductService(ProductRepository productRepository, InvocationRepository invocationRepository, TypeRepository typeRepository) { this.productRepository = productRepository; this.invocationRepository = invocationRepository; this.typeRepository = typeRepository; } + @GraphQLQuery(name = "getProductPaths") public String getProductPaths(Long productId) { StringBuffer graph = new StringBuffer("["); - Product product = productRepository.findOne(productId); + Optional product = productRepository.findById(productId); if(product != null) { List invocations = invocationRepository.findByProduct(product); diff --git a/src/main/java/com/swarm/graphql/query/QuerySession.java b/src/main/java/com/swarm/graphql/service/SessionService.java similarity index 87% rename from src/main/java/com/swarm/graphql/query/QuerySession.java rename to src/main/java/com/swarm/graphql/service/SessionService.java index c345808..950324f 100644 --- a/src/main/java/com/swarm/graphql/query/QuerySession.java +++ b/src/main/java/com/swarm/graphql/service/SessionService.java @@ -1,11 +1,13 @@ -package com.swarm.graphql.query; +package com.swarm.graphql.service; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; + +import org.springframework.stereotype.Service; -import com.coxautodev.graphql.tools.GraphQLQueryResolver; import com.swarm.graphql.model.Invocation; import com.swarm.graphql.model.Method; import com.swarm.graphql.model.Session; @@ -15,7 +17,12 @@ import com.swarm.graphql.repository.SessionRepository; import com.swarm.graphql.repository.TypeRepository; -public class QuerySession implements GraphQLQueryResolver{ +import io.leangen.graphql.annotations.GraphQLQuery; +import io.leangen.graphql.spqr.spring.annotation.GraphQLApi; + +@GraphQLApi +@Service +public class SessionService { private SessionRepository sessionRepository; private TypeRepository typeRepository; @@ -23,24 +30,26 @@ public class QuerySession implements GraphQLQueryResolver{ private InvocationRepository invocationRepository; private StringBuffer graph; - public QuerySession(SessionRepository sessionRepository, TypeRepository typeRepository, MethodRepository methodRepository, InvocationRepository invocationRepository) { + public SessionService(SessionRepository sessionRepository, TypeRepository typeRepository, MethodRepository methodRepository, InvocationRepository invocationRepository) { this.sessionRepository = sessionRepository; this.typeRepository = typeRepository; this.methodRepository = methodRepository; this.invocationRepository = invocationRepository; } - public Iterable sessionsByTaskIdAndDeveloperId(Long taskId, Long developerId){ + @GraphQLQuery + public Iterable sessionsByTaskIdAndDeveloperId(Long taskId, Long developerId){ return sessionRepository.findByTaskAndDeveloper(taskId, developerId); } + @GraphQLQuery(name = "getGraphData") public String getGraphData(Long sessionId, boolean addType) { - Session session = sessionRepository.findOne(sessionId); + Optional session = sessionRepository.findById(sessionId); return getGraphData(session, addType, true); } - public String getGraphData(Session session, boolean addType, boolean closed) { + public String getGraphData(Optional session, boolean addType, boolean closed) { graph = new StringBuffer(); if(closed) { graph.append("["); @@ -56,9 +65,9 @@ public String getGraphData(Session session, boolean addType, boolean closed) { output = graph.toString() + (closed ? "]" : ""); } return output; -} + } - private void graphAddSession(Session session, boolean addType, boolean closed){ + private void graphAddSession(Optional session, boolean addType, boolean closed){ List types = typeRepository.findBySession(session); for (Type type : types) { int hash = type.getFullName().hashCode(); @@ -69,9 +78,8 @@ private void graphAddSession(Session session, boolean addType, boolean closed){ graphAddSessionAddMethod(type,addType,newType,session,r,g,b); } } - - private void graphAddSessionAddMethod(Type type, boolean addType, boolean newType, Session session, int r, int g, int b) { + private void graphAddSessionAddMethod(Type type, boolean addType, boolean newType, Optional session, int r, int g, int b) { List methods = methodRepository.findByType(type); for(Method method : methods) { int invocations = invocationRepository.countInvocations(session, method); @@ -96,7 +104,7 @@ private void graphAddSessionAddType(Type type) { graph.append("\"data\": { \"id\": \"T" + type.getId() + "\", \"label\": \"" + type.getFullName() + "\", \"shape\": \"roundrectangle\", \"color\": \"#888\"}},"); } - private void graphAddInvocation(Session session) { + private void graphAddInvocation(Optional session) { List invocations = invocationRepository.findBySession(session); if(invocations.size() > 0) { Map labels = new HashMap(); @@ -111,7 +119,6 @@ private void graphAddInvocation(Session session) { } } - private Map graphAddInvocationAddString(Invocation invocation, Map labels) { String key = invocation.getInvoking().getId() + "->" + invocation.getInvoked().getId(); if(labels.containsKey(key)) { @@ -128,9 +135,10 @@ private Map graphAddInvocationAddString(Invocation invocation, M return labels; } + @GraphQLQuery(name = "getStackData") public String getStackData(Long sessionId) { StringBuffer graph = new StringBuffer(); - Session session = sessionRepository.findOne(sessionId); + Optional session = sessionRepository.findById(sessionId); List startingMethods = methodRepository.getStartingMethods(session); List endingMethods = methodRepository.getEndingMethods(session); @@ -192,10 +200,10 @@ private String addNode(int path, Method method, boolean isVirtual) { return buffer.toString(); } - + @GraphQLQuery(name = "getInterPathEdges") public String getInterPathEdges(Long sessionId) { StringBuffer graph = new StringBuffer(); - Session session = sessionRepository.findOne(sessionId); + Optional session = sessionRepository.findById(sessionId); List startingMethods = methodRepository.getStartingMethods(session); List endingMethods = methodRepository.getEndingMethods(session); @@ -247,7 +255,7 @@ public String getInterPathEdges(Long sessionId) { } } - List> getInvocationPaths(List startingMethods, List endingMethods, Session session) { + List> getInvocationPaths(List startingMethods, List endingMethods, Optional session) { List> paths = new ArrayList>(); List uniqueInvocations = new ArrayList(); @@ -308,23 +316,25 @@ List> getInvocationPaths(List startingMethods, List session = sessionRepository.findById(sessionId); int invocations = invocationRepository.countBySession(session); int methods = methodRepository.countBySession(session); return invocations + methods; } + @GraphQLQuery(name = "getGraphDataByTaskId") public String getGraphDataByTaskId(Long taskId) { String graph = "["; - List sessions = sessionRepository.findByTask(taskId); - for (Session session : sessions) { + List> sessions = sessionRepository.findByTask(taskId); + for (Optional session : sessions) { graph += getGraphData(session, false, false); } return graph + "]"; } - + } diff --git a/src/main/java/com/swarm/graphql/query/QueryTask.java b/src/main/java/com/swarm/graphql/service/TaskService.java similarity index 88% rename from src/main/java/com/swarm/graphql/query/QueryTask.java rename to src/main/java/com/swarm/graphql/service/TaskService.java index a3b0ae9..5082fe7 100644 --- a/src/main/java/com/swarm/graphql/query/QueryTask.java +++ b/src/main/java/com/swarm/graphql/service/TaskService.java @@ -1,13 +1,13 @@ -package com.swarm.graphql.query; +package com.swarm.graphql.service; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Map.Entry; -import com.coxautodev.graphql.tools.GraphQLQueryResolver; +import org.springframework.stereotype.Service; + import com.swarm.graphql.model.Breakpoint; import com.swarm.graphql.model.Task; import com.swarm.graphql.model.Type; @@ -15,28 +15,38 @@ import com.swarm.graphql.repository.TaskRepository; import com.swarm.graphql.repository.TypeRepository; -public class QueryTask implements GraphQLQueryResolver{ - +import io.leangen.graphql.annotations.GraphQLQuery; +import io.leangen.graphql.spqr.spring.annotation.GraphQLApi; + +import java.util.Map.Entry; +import java.util.Optional; + +@Service +@GraphQLApi +public class TaskService { + private TaskRepository taskRepository; private TypeRepository typeRepository; private BreakpointRepository breakpointRepository; - public QueryTask(TaskRepository taskRepository, TypeRepository typeRepository, BreakpointRepository breakpointRepository) { + public TaskService(TaskRepository taskRepository, TypeRepository typeRepository, BreakpointRepository breakpointRepository) { this.taskRepository = taskRepository; this.typeRepository = typeRepository; this.breakpointRepository = breakpointRepository; } + @GraphQLQuery public Iterable allTasks() { return taskRepository.findAll(); } + @GraphQLQuery(name = "getBreakpointGraphData") public String getBreakpointGraphData(Long taskId) { return getBreakpointGraphData(taskId, true); } public String getBreakpointGraphData(Long taskId, boolean closed) { - Task task = taskRepository.findOne(taskId); + Optional task = taskRepository.findById(taskId); if (task == null) { return "[]"; } @@ -138,5 +148,4 @@ private List sortNodes(Map typeNodes) { return nodes; } - } diff --git a/src/main/java/com/swarm/graphql/service/TypeService.java b/src/main/java/com/swarm/graphql/service/TypeService.java new file mode 100644 index 0000000..c1ba9fc --- /dev/null +++ b/src/main/java/com/swarm/graphql/service/TypeService.java @@ -0,0 +1,26 @@ +package com.swarm.graphql.service; + +import org.springframework.stereotype.Service; + +import com.swarm.graphql.model.Type; +import com.swarm.graphql.repository.TypeRepository; + +import io.leangen.graphql.annotations.GraphQLQuery; +import io.leangen.graphql.spqr.spring.annotation.GraphQLApi; + +@GraphQLApi +@Service +public class TypeService { + + private TypeRepository typeRepository; + + public TypeService(TypeRepository typeRepository) { + this.typeRepository = typeRepository; + } + + @GraphQLQuery + public Iterable typesBySessionId(Long sessionId){ + return typeRepository.findBySessionId(sessionId); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 36600a2..29e8c10 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,2 +1,5 @@ +server.port=8080 +graphql.spqr.gui.enabled=true +graphql.spqr.relay.connection-check-relaxed=true spring.h2.console.enabled=true -spring.h2.console.path=/h2-console +spring.h2.console.path=/h2-console \ No newline at end of file diff --git a/src/main/resources/graphql/breakpoint.graphqls b/src/main/resources/graphql/breakpoint.graphqls deleted file mode 100644 index a191779..0000000 --- a/src/main/resources/graphql/breakpoint.graphqls +++ /dev/null @@ -1,13 +0,0 @@ -type Breakpoint { - id: ID! - type: Type! - charStart: String! - charEnd: String! - lineNumber: Int! -} - -extend type Query { - allBreakpoints: [Breakpoint] - breakpointsByTaskId(taskId: ID!): [Breakpoint] - getTable(productId: ID!): String -} \ No newline at end of file diff --git a/src/main/resources/graphql/developer.graphqls b/src/main/resources/graphql/developer.graphqls deleted file mode 100644 index 11873e5..0000000 --- a/src/main/resources/graphql/developer.graphqls +++ /dev/null @@ -1,5 +0,0 @@ -type Developer { - id: ID! - name: String! - color: String -} \ No newline at end of file diff --git a/src/main/resources/graphql/event.graphqls b/src/main/resources/graphql/event.graphqls deleted file mode 100644 index 0019c9e..0000000 --- a/src/main/resources/graphql/event.graphqls +++ /dev/null @@ -1,10 +0,0 @@ -type Event { - id: ID! - method: Method! - session: Session! - charStart: String - charEnd: String - lineNumber: Int - detail: String - kind: String -} \ No newline at end of file diff --git a/src/main/resources/graphql/invocation.graphqls b/src/main/resources/graphql/invocation.graphqls deleted file mode 100644 index 35a183a..0000000 --- a/src/main/resources/graphql/invocation.graphqls +++ /dev/null @@ -1,10 +0,0 @@ -type Invocation { - id: ID! - invoking: Method! - invoked: Method! - session: Session! -} - -extend type Query { - invocationsByMethods(sessionId: ID!, invokingId: ID!, invokedId: ID!): [Invocation] -} \ No newline at end of file diff --git a/src/main/resources/graphql/method.graphqls b/src/main/resources/graphql/method.graphqls deleted file mode 100644 index 585ef9a..0000000 --- a/src/main/resources/graphql/method.graphqls +++ /dev/null @@ -1,14 +0,0 @@ -type Method { - id: ID! - type: Type! - key: String! - name: String! - signature: String! -} - -extend type Query { - methodsByTypeId(typeId: ID!): [Method] - startingMethodsBySessionId(sessionId: ID!): [Method] - endingMethodsBySessionId(sessionId: ID!): [Method] -} - diff --git a/src/main/resources/graphql/namespace.graphqls b/src/main/resources/graphql/namespace.graphqls deleted file mode 100644 index 5f330ce..0000000 --- a/src/main/resources/graphql/namespace.graphqls +++ /dev/null @@ -1,9 +0,0 @@ -type Namespace { - id: ID! - name: String! - fullPath: String! -} - -extend type Query { - namespaceByFullPath(fullPath: String!): Namespace -} \ No newline at end of file diff --git a/src/main/resources/graphql/product.graphqls b/src/main/resources/graphql/product.graphqls deleted file mode 100644 index a4839fe..0000000 --- a/src/main/resources/graphql/product.graphqls +++ /dev/null @@ -1,8 +0,0 @@ -type Product { - id: ID! - name: String! -} - -extend type Query { - getProductPaths(productId: ID!): String -} \ No newline at end of file diff --git a/src/main/resources/graphql/session.graphqls b/src/main/resources/graphql/session.graphqls deleted file mode 100644 index bfe58a1..0000000 --- a/src/main/resources/graphql/session.graphqls +++ /dev/null @@ -1,21 +0,0 @@ -scalar Date - -type Session { - id: ID! - developer: Developer! - task: Task! - description: String - label: String - purpose: String - project: String - started: Date - finished: Date -} - -extend type Query { - sessionsByTaskIdAndDeveloperId(taskId: ID!, developerId: ID!): [Session] - getGraphData(sessionId: ID!, addType: Boolean!): String - getStackData(sessionId: ID!): String - getInterPathEdges(sessionId: ID!): String - countElements(sessionId: ID!): Int -} diff --git a/src/main/resources/graphql/swarmdbg.graphqls b/src/main/resources/graphql/swarmdbg.graphqls deleted file mode 100644 index 86d2e1e..0000000 --- a/src/main/resources/graphql/swarmdbg.graphqls +++ /dev/null @@ -1,3 +0,0 @@ -type Query{ - hello: String -} \ No newline at end of file diff --git a/src/main/resources/graphql/task.graphqls b/src/main/resources/graphql/task.graphqls deleted file mode 100644 index 610ae8b..0000000 --- a/src/main/resources/graphql/task.graphqls +++ /dev/null @@ -1,13 +0,0 @@ -type Task { - id: ID! - product: Product! - title: String - url: String - color: String -} - -extend type Query { - allTasks: [Task] - getGraphDataByTaskId(taskId: ID!): String - getBreakpointGraphData(taskId: ID!): String -} \ No newline at end of file diff --git a/src/main/resources/graphql/type.graphqls b/src/main/resources/graphql/type.graphqls deleted file mode 100644 index e8f9048..0000000 --- a/src/main/resources/graphql/type.graphqls +++ /dev/null @@ -1,14 +0,0 @@ -type Type { - id: ID! - namespace: Namespace! - session: Session! - fullName: String! - fullPath: String! - name: String! - source: String! -} - -extend type Query { - typesBySessionId(sessionId: ID!): [Type] -} - diff --git a/src/test/java/com/swarm/graphql/ScalarDateTest.java b/src/test/java/com/swarm/graphql/ScalarDateTest.java index 47f393d..c04ff6b 100644 --- a/src/test/java/com/swarm/graphql/ScalarDateTest.java +++ b/src/test/java/com/swarm/graphql/ScalarDateTest.java @@ -1,4 +1,4 @@ -package com.swarm.graphql; +/*package com.swarm.graphql; import static org.assertj.core.api.Assertions.*; @@ -26,3 +26,4 @@ public void parseValue() { } } +*/ \ No newline at end of file diff --git a/src/test/java/com/swarm/graphql/SwarmGraphQlApplicationTest.java b/src/test/java/com/swarm/graphql/SwarmGraphQlApplicationTest.java index 803187c..e8a0ed7 100644 --- a/src/test/java/com/swarm/graphql/SwarmGraphQlApplicationTest.java +++ b/src/test/java/com/swarm/graphql/SwarmGraphQlApplicationTest.java @@ -1,4 +1,4 @@ -package com.swarm.graphql; +/*package com.swarm.graphql; import org.junit.Test; import org.junit.runner.RunWith; @@ -14,3 +14,4 @@ public class SwarmGraphQlApplicationTest { public void contextLoads() { } } +*/ \ No newline at end of file diff --git a/src/test/java/com/swarm/graphql/query/AllTests.java b/src/test/java/com/swarm/graphql/query/AllTests.java index 9e14b2c..722f8fc 100644 --- a/src/test/java/com/swarm/graphql/query/AllTests.java +++ b/src/test/java/com/swarm/graphql/query/AllTests.java @@ -1,4 +1,4 @@ -package com.swarm.graphql.query; +/*package com.swarm.graphql.query; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -16,4 +16,4 @@ QueryTest.class, QueryTypeTest.class }) public class AllTests { -} +}*/ diff --git a/src/test/java/com/swarm/graphql/query/QueryBreakpointTest.java b/src/test/java/com/swarm/graphql/query/QueryBreakpointTest.java index 03c3afc..ce7a9f4 100644 --- a/src/test/java/com/swarm/graphql/query/QueryBreakpointTest.java +++ b/src/test/java/com/swarm/graphql/query/QueryBreakpointTest.java @@ -1,4 +1,4 @@ -package com.swarm.graphql.query; +/*package com.swarm.graphql.query; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -24,7 +24,7 @@ public final void lancement() { new SwarmGraphQlApplication().main(new String[0]); } */ - @Test + /*@Test public final void testAllBreakpoints() throws IOException, JSONException { System.out.println("testAllBreakpoints"); @@ -48,3 +48,4 @@ public final void testAllBreakpoints() throws IOException, JSONException { } } +*/ \ No newline at end of file diff --git a/src/test/java/com/swarm/graphql/query/QueryInvocationTest.java b/src/test/java/com/swarm/graphql/query/QueryInvocationTest.java index 10c0348..6c0d778 100644 --- a/src/test/java/com/swarm/graphql/query/QueryInvocationTest.java +++ b/src/test/java/com/swarm/graphql/query/QueryInvocationTest.java @@ -1,4 +1,4 @@ -package com.swarm.graphql.query; +/*package com.swarm.graphql.query; import static org.junit.Assert.*; @@ -23,7 +23,7 @@ public final void lancement() { SwarmGraphQlApplication.main(new String[0]); } */ - @Test + /*@Test public final void testInvocationsByMethods() throws IOException, JSONException { System.out.println("testInvocationsByMethods"); JSONObject json = JsonReader.readJsonFromUrl("http://localhost:8080/graphql?query=%7BinvocationsByMethods(sessionId:1,invokingId:1,invokedId:2)%7Bid%7D%7D"); @@ -36,4 +36,4 @@ public final void testInvocationsByMethods() throws IOException, JSONException { assertEquals(expectedIdResult,id); } -} +}*/ diff --git a/src/test/java/com/swarm/graphql/query/QueryMethodTest.java b/src/test/java/com/swarm/graphql/query/QueryMethodTest.java index 2c20927..50ec4ba 100644 --- a/src/test/java/com/swarm/graphql/query/QueryMethodTest.java +++ b/src/test/java/com/swarm/graphql/query/QueryMethodTest.java @@ -1,4 +1,4 @@ -package com.swarm.graphql.query; +/*package com.swarm.graphql.query; import static org.junit.Assert.*; @@ -21,7 +21,7 @@ public final void lancement() { SwarmGraphQlApplication.main(new String[0]); } */ - @Test + /*@Test public final void testMethodsByTypeId() throws IOException, JSONException { System.out.println("testMethodsByTypeId"); JSONObject json = JsonReader.readJsonFromUrl("http://localhost:8080/graphql?query=%7BmethodsByTypeId(typeId:1)%7Bid%7D%7D"); @@ -63,4 +63,4 @@ public final void testEndingMethodsBySessionId() throws IOException, JSONExcepti -} +}*/ diff --git a/src/test/java/com/swarm/graphql/query/QueryNamespaceTest.java b/src/test/java/com/swarm/graphql/query/QueryNamespaceTest.java index b0aaeed..6820521 100644 --- a/src/test/java/com/swarm/graphql/query/QueryNamespaceTest.java +++ b/src/test/java/com/swarm/graphql/query/QueryNamespaceTest.java @@ -1,4 +1,4 @@ -package com.swarm.graphql.query; +/*package com.swarm.graphql.query; import static org.junit.Assert.*; @@ -23,7 +23,7 @@ public final void lancement() { SwarmGraphQlApplication.main(new String[0]); } */ - @Test + /*@Test public final void testNamespaceByFullPath() throws IOException, JSONException { System.out.println("testNamespaceByFullPath"); JSONObject json = JsonReader.readJsonFromUrl("http://localhost:8080/graphql?query=%7BnamespaceByFullPath(fullPath:%22namespace1.fullPath%22)%7Bid%7D%7D"); @@ -36,4 +36,4 @@ public final void testNamespaceByFullPath() throws IOException, JSONException { assertEquals(expectedIdResult,id); } -} +}*/ diff --git a/src/test/java/com/swarm/graphql/query/QuerySessionTest.java b/src/test/java/com/swarm/graphql/query/QuerySessionTest.java index 9b72171..5fc93cf 100644 --- a/src/test/java/com/swarm/graphql/query/QuerySessionTest.java +++ b/src/test/java/com/swarm/graphql/query/QuerySessionTest.java @@ -1,4 +1,4 @@ -package com.swarm.graphql.query; +/*package com.swarm.graphql.query; import static org.junit.Assert.*; @@ -21,7 +21,7 @@ public final void lancement() { SwarmGraphQlApplication.main(new String[0]); } */ - @Test + /*@Test public final void testSessionsByTaskIdAndDeveloperId() throws IOException, JSONException { System.out.println("testSessionsByTaskIdAndDeveloperId"); @@ -95,4 +95,4 @@ public final void testGetInterPathEdges() throws IOException, JSONException { assertEquals(expectedIdResult,result); } -} +}*/ diff --git a/src/test/java/com/swarm/graphql/query/QueryTaskTest.java b/src/test/java/com/swarm/graphql/query/QueryTaskTest.java index f92781d..6133f60 100644 --- a/src/test/java/com/swarm/graphql/query/QueryTaskTest.java +++ b/src/test/java/com/swarm/graphql/query/QueryTaskTest.java @@ -1,4 +1,4 @@ -package com.swarm.graphql.query; +/*package com.swarm.graphql.query; import static org.junit.Assert.*; @@ -14,7 +14,7 @@ public class QueryTaskTest { - @Test + /*@Test public final void allTaskTest() throws IOException, JSONException { System.out.println("allTaskTest"); @@ -38,4 +38,4 @@ public final void getBreakpointGraphDataTest() throws IOException, JSONException assertEquals(corect,data.toString()); } -} +}*/ diff --git a/src/test/java/com/swarm/graphql/query/QueryTest.java b/src/test/java/com/swarm/graphql/query/QueryTest.java index 73174c4..4f9348f 100644 --- a/src/test/java/com/swarm/graphql/query/QueryTest.java +++ b/src/test/java/com/swarm/graphql/query/QueryTest.java @@ -1,4 +1,4 @@ -package com.swarm.graphql.query; +/*package com.swarm.graphql.query; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -26,4 +26,4 @@ public final void testHello() throws Exception { } -} +}*/ diff --git a/src/test/java/com/swarm/graphql/query/QueryTypeTest.java b/src/test/java/com/swarm/graphql/query/QueryTypeTest.java index ee741d3..c57843d 100644 --- a/src/test/java/com/swarm/graphql/query/QueryTypeTest.java +++ b/src/test/java/com/swarm/graphql/query/QueryTypeTest.java @@ -1,4 +1,4 @@ -package com.swarm.graphql.query; +/*package com.swarm.graphql.query; import static org.junit.Assert.*; @@ -30,3 +30,4 @@ public final void typesBySessionIdtest() throws IOException, JSONException { } } +*/ \ No newline at end of file diff --git a/src/test/java/com/swarm/graphql/query/TestRunner.java b/src/test/java/com/swarm/graphql/query/TestRunner.java index 06d36ba..87f31a0 100644 --- a/src/test/java/com/swarm/graphql/query/TestRunner.java +++ b/src/test/java/com/swarm/graphql/query/TestRunner.java @@ -1,4 +1,4 @@ -package com.swarm.graphql.query; +/*package com.swarm.graphql.query; import org.junit.runner.JUnitCore; import org.junit.runner.Result; import org.junit.runner.notification.Failure; @@ -21,3 +21,4 @@ public static void main(String[] args) throws InterruptedException { } } +*/ \ No newline at end of file diff --git a/target/classes/application.properties b/target/classes/application.properties index 36600a2..29e8c10 100644 --- a/target/classes/application.properties +++ b/target/classes/application.properties @@ -1,2 +1,5 @@ +server.port=8080 +graphql.spqr.gui.enabled=true +graphql.spqr.relay.connection-check-relaxed=true spring.h2.console.enabled=true -spring.h2.console.path=/h2-console +spring.h2.console.path=/h2-console \ No newline at end of file diff --git a/target/classes/com/swarm/graphql/MainConfig.class b/target/classes/com/swarm/graphql/MainConfig.class index edd5f04..bd8ec0f 100644 Binary files a/target/classes/com/swarm/graphql/MainConfig.class and b/target/classes/com/swarm/graphql/MainConfig.class differ diff --git a/target/classes/com/swarm/graphql/ScalarDate$1.class b/target/classes/com/swarm/graphql/ScalarDate$1.class index da38b65..fc66fba 100644 Binary files a/target/classes/com/swarm/graphql/ScalarDate$1.class and b/target/classes/com/swarm/graphql/ScalarDate$1.class differ diff --git a/target/classes/com/swarm/graphql/SwarmGraphQlApplication.class b/target/classes/com/swarm/graphql/SwarmGraphQlApplication.class index e732648..9657316 100644 Binary files a/target/classes/com/swarm/graphql/SwarmGraphQlApplication.class and b/target/classes/com/swarm/graphql/SwarmGraphQlApplication.class differ diff --git a/target/classes/com/swarm/graphql/model/Breakpoint.class b/target/classes/com/swarm/graphql/model/Breakpoint.class index 8d6b301..7816b1d 100644 Binary files a/target/classes/com/swarm/graphql/model/Breakpoint.class and b/target/classes/com/swarm/graphql/model/Breakpoint.class differ diff --git a/target/classes/com/swarm/graphql/model/Developer.class b/target/classes/com/swarm/graphql/model/Developer.class index 1071e9f..fd04eb5 100644 Binary files a/target/classes/com/swarm/graphql/model/Developer.class and b/target/classes/com/swarm/graphql/model/Developer.class differ diff --git a/target/classes/com/swarm/graphql/model/Event.class b/target/classes/com/swarm/graphql/model/Event.class index e777a39..b699b5a 100644 Binary files a/target/classes/com/swarm/graphql/model/Event.class and b/target/classes/com/swarm/graphql/model/Event.class differ diff --git a/target/classes/com/swarm/graphql/model/Invocation.class b/target/classes/com/swarm/graphql/model/Invocation.class index 442ad25..9b74ad1 100644 Binary files a/target/classes/com/swarm/graphql/model/Invocation.class and b/target/classes/com/swarm/graphql/model/Invocation.class differ diff --git a/target/classes/com/swarm/graphql/model/Method.class b/target/classes/com/swarm/graphql/model/Method.class index e27c6cb..6adc56a 100644 Binary files a/target/classes/com/swarm/graphql/model/Method.class and b/target/classes/com/swarm/graphql/model/Method.class differ diff --git a/target/classes/com/swarm/graphql/model/Namespace.class b/target/classes/com/swarm/graphql/model/Namespace.class index 053f779..ead9870 100644 Binary files a/target/classes/com/swarm/graphql/model/Namespace.class and b/target/classes/com/swarm/graphql/model/Namespace.class differ diff --git a/target/classes/com/swarm/graphql/model/Product.class b/target/classes/com/swarm/graphql/model/Product.class index e2e7bd9..2d03b69 100644 Binary files a/target/classes/com/swarm/graphql/model/Product.class and b/target/classes/com/swarm/graphql/model/Product.class differ diff --git a/target/classes/com/swarm/graphql/model/Session.class b/target/classes/com/swarm/graphql/model/Session.class index 6b5d3ba..df514a8 100644 Binary files a/target/classes/com/swarm/graphql/model/Session.class and b/target/classes/com/swarm/graphql/model/Session.class differ diff --git a/target/classes/com/swarm/graphql/model/Task.class b/target/classes/com/swarm/graphql/model/Task.class index 56c981b..be402bf 100644 Binary files a/target/classes/com/swarm/graphql/model/Task.class and b/target/classes/com/swarm/graphql/model/Task.class differ diff --git a/target/classes/com/swarm/graphql/model/Type.class b/target/classes/com/swarm/graphql/model/Type.class index d245d89..28663d7 100644 Binary files a/target/classes/com/swarm/graphql/model/Type.class and b/target/classes/com/swarm/graphql/model/Type.class differ diff --git a/target/classes/com/swarm/graphql/repository/BreakpointRepository.class b/target/classes/com/swarm/graphql/repository/BreakpointRepository.class index 6d58b32..dad268a 100644 Binary files a/target/classes/com/swarm/graphql/repository/BreakpointRepository.class and b/target/classes/com/swarm/graphql/repository/BreakpointRepository.class differ diff --git a/target/classes/com/swarm/graphql/repository/DeveloperRepository.class b/target/classes/com/swarm/graphql/repository/DeveloperRepository.class index 7911b65..38e8d07 100644 Binary files a/target/classes/com/swarm/graphql/repository/DeveloperRepository.class and b/target/classes/com/swarm/graphql/repository/DeveloperRepository.class differ diff --git a/target/classes/com/swarm/graphql/repository/InvocationRepository.class b/target/classes/com/swarm/graphql/repository/InvocationRepository.class index 138d4d1..0d006dc 100644 Binary files a/target/classes/com/swarm/graphql/repository/InvocationRepository.class and b/target/classes/com/swarm/graphql/repository/InvocationRepository.class differ diff --git a/target/classes/com/swarm/graphql/repository/MethodRepository.class b/target/classes/com/swarm/graphql/repository/MethodRepository.class index 10b457e..277a2a8 100644 Binary files a/target/classes/com/swarm/graphql/repository/MethodRepository.class and b/target/classes/com/swarm/graphql/repository/MethodRepository.class differ diff --git a/target/classes/com/swarm/graphql/repository/NamespaceRepository.class b/target/classes/com/swarm/graphql/repository/NamespaceRepository.class index 8558fa0..7b0267d 100644 Binary files a/target/classes/com/swarm/graphql/repository/NamespaceRepository.class and b/target/classes/com/swarm/graphql/repository/NamespaceRepository.class differ diff --git a/target/classes/com/swarm/graphql/repository/SessionRepository.class b/target/classes/com/swarm/graphql/repository/SessionRepository.class index 8ff04db..2318fd9 100644 Binary files a/target/classes/com/swarm/graphql/repository/SessionRepository.class and b/target/classes/com/swarm/graphql/repository/SessionRepository.class differ diff --git a/target/classes/com/swarm/graphql/repository/TypeRepository.class b/target/classes/com/swarm/graphql/repository/TypeRepository.class index ab2eaa7..8a42c8d 100644 Binary files a/target/classes/com/swarm/graphql/repository/TypeRepository.class and b/target/classes/com/swarm/graphql/repository/TypeRepository.class differ diff --git a/target/test-classes/outils/JsonReader.class b/target/test-classes/outils/JsonReader.class index e18dd0f..797dd07 100644 Binary files a/target/test-classes/outils/JsonReader.class and b/target/test-classes/outils/JsonReader.class differ