-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-2 Moved commands to its own module
- Loading branch information
Gerd Wuetherich
committed
Jun 19, 2019
1 parent
688037b
commit 2a8b7bf
Showing
14 changed files
with
847 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
slizaa-server-command - Slizaa Static Software Analysis Tools | ||
Copyright © 2019 Code-Kontor GmbH and others ([email protected]) | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<parent> | ||
<groupId>io.codekontor.slizaa</groupId> | ||
<artifactId>slizaa-server-parent</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<relativePath>../../slizaa-poms/slizaa-server-parent/pom.xml</relativePath> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>slizaa-server-command</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.codekontor.slizaa</groupId> | ||
<artifactId>slizaa-server-service-slizaa</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.codekontor.slizaa</groupId> | ||
<artifactId>slizaa-server-spec</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.codekontor.slizaa</groupId> | ||
<artifactId>slizaa-server-service-configuration</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.shell</groupId> | ||
<artifactId>spring-shell-starter</artifactId> | ||
<version>2.0.0.RELEASE</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/** | ||
* slizaa-server-main - Slizaa Static Software Analysis Tools | ||
* slizaa-server-command - Slizaa Static Software Analysis Tools | ||
* Copyright © 2019 Code-Kontor GmbH and others ([email protected]) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
|
@@ -15,7 +15,7 @@ | |
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package io.codekontor.slizaa.server; | ||
package io.codekontor.slizaa.server.command; | ||
|
||
import io.codekontor.slizaa.server.descr.ContentDefinition; | ||
import io.codekontor.slizaa.server.descr.GraphDatabase; | ||
|
31 changes: 31 additions & 0 deletions
31
...nd/src/main/java/io/codekontor/slizaa/server/command/EnableSlizaaServerCommandModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* slizaa-server-command - Slizaa Static Software Analysis Tools | ||
* Copyright © 2019 Code-Kontor GmbH and others ([email protected]) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package io.codekontor.slizaa.server.command; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.TYPE}) | ||
@Documented | ||
@Import(SlizaaServerCommandModuleConfiguration.class) | ||
@Configuration | ||
public @interface EnableSlizaaServerCommandModule { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/** | ||
* slizaa-server-main - Slizaa Static Software Analysis Tools | ||
* slizaa-server-command - Slizaa Static Software Analysis Tools | ||
* Copyright © 2019 Code-Kontor GmbH and others ([email protected]) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
|
@@ -15,7 +15,7 @@ | |
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package io.codekontor.slizaa.server; | ||
package io.codekontor.slizaa.server.command; | ||
|
||
import com.google.common.base.Preconditions; | ||
import io.codekontor.slizaa.server.service.extensions.IExtensionIdentifier; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/** | ||
* slizaa-server-main - Slizaa Static Software Analysis Tools | ||
* slizaa-server-command - Slizaa Static Software Analysis Tools | ||
* Copyright © 2019 Code-Kontor GmbH and others ([email protected]) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
|
@@ -15,7 +15,7 @@ | |
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package io.codekontor.slizaa.server; | ||
package io.codekontor.slizaa.server.command; | ||
|
||
import io.codekontor.slizaa.server.service.extensions.IExtension; | ||
import io.codekontor.slizaa.server.service.extensions.IExtensionIdentifier; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/** | ||
* slizaa-server-main - Slizaa Static Software Analysis Tools | ||
* slizaa-server-command - Slizaa Static Software Analysis Tools | ||
* Copyright © 2019 Code-Kontor GmbH and others ([email protected]) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
|
@@ -15,7 +15,7 @@ | |
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package io.codekontor.slizaa.server; | ||
package io.codekontor.slizaa.server.command; | ||
|
||
import io.codekontor.slizaa.server.service.slizaa.IGraphDatabase; | ||
import io.codekontor.slizaa.server.service.slizaa.IHierarchicalGraph; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/** | ||
* slizaa-server-main - Slizaa Static Software Analysis Tools | ||
* slizaa-server-command - Slizaa Static Software Analysis Tools | ||
* Copyright © 2019 Code-Kontor GmbH and others ([email protected]) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
|
@@ -15,8 +15,10 @@ | |
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package io.codekontor.slizaa.server; | ||
package io.codekontor.slizaa.server.command; | ||
|
||
import io.codekontor.slizaa.scanner.spi.contentdefinition.IContentDefinitionProvider; | ||
import io.codekontor.slizaa.scanner.spi.contentdefinition.filebased.IFileBasedContentDefinition; | ||
import io.codekontor.slizaa.server.service.slizaa.IGraphDatabase; | ||
import io.codekontor.slizaa.server.service.slizaa.IHierarchicalGraph; | ||
import org.springframework.shell.standard.ShellCommandGroup; | ||
|
@@ -25,7 +27,7 @@ | |
import org.springframework.shell.standard.ShellOption; | ||
|
||
@ShellComponent | ||
@ShellCommandGroup("Slizaa Graph Databases Commands") | ||
@ShellCommandGroup("Slizaa Graph Databases Commands - Content Definition") | ||
public class SlizaaGraphDatabaseContentDefinitionCommands extends AbstractGraphDatabaseCommandComponent { | ||
|
||
@ShellMethod(value = "List available content definition provider factories.", key = {"listContentDefinitionProviderFactories"}, group = "Slizaa Graph Databases Commands - Content Definition") | ||
|
@@ -48,13 +50,44 @@ public String setContentDefinitionProvider(@ShellOption({"-d", "--databaseId"}) | |
return cannotExecuteCommand(String.format("The specified database '%s' does not exist.\n", databaseIdentifier)); | ||
} | ||
|
||
// TODO: | ||
// slizaaService().getContentDefinitionProviderFactories(); | ||
|
||
// | ||
graphDatabase.setContentDefinitionProvider(contentDefinitionProviderFactoryId, contentDefinition); | ||
|
||
// return the result | ||
return dumpGraphDatabases(); | ||
} | ||
|
||
@ShellMethod(value = "List the content definitions for the specified database.", key = "showResolvedContentDefinitions") | ||
public String showResolvedContentDefinitions(@ShellOption({"-d", "--databaseId"}) String databaseIdentifier, @ShellOption(defaultValue = "false", value = {"-f", "--showFiles"}) boolean showFiles) { | ||
|
||
// check the backend configuration | ||
String checkBackendConfigured = checkBackendConfigured(); | ||
if (checkBackendConfigured != null) { | ||
return checkBackendConfigured; | ||
} | ||
|
||
// check that the requested database exists | ||
IGraphDatabase graphDatabase = slizaaService().getGraphDatabase(databaseIdentifier); | ||
if (graphDatabase == null) { | ||
return cannotExecuteCommand(String.format("The specified database '%s' does not exist.\n", databaseIdentifier)); | ||
} | ||
|
||
// | ||
IContentDefinitionProvider<?> contentDefinitionProvider = graphDatabase.getContentDefinition(); | ||
|
||
StringBuffer result = new StringBuffer("Content Definitions:\n"); | ||
contentDefinitionProvider.getContentDefinitions().forEach(contentDefinition -> { | ||
result.append(String.format(" - %s_%s\n", contentDefinition.getName(), contentDefinition.getVersion())); | ||
if (contentDefinition instanceof IFileBasedContentDefinition) { | ||
IFileBasedContentDefinition fileBasedContentDefinition = (IFileBasedContentDefinition) contentDefinition; | ||
fileBasedContentDefinition.getBinaryRootPaths().forEach(file -> result.append(String.format(" - %s\n", file.getPath()))); | ||
if (showFiles) { | ||
fileBasedContentDefinition.getBinaryFiles().stream().sorted((f1, f2) -> f1.getPath().compareTo(f2.getPath())).forEach(file -> result.append(String.format(" - %s\n", file.getPath()))); | ||
} | ||
} | ||
}); | ||
|
||
// return the result | ||
return result.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/** | ||
* slizaa-server-main - Slizaa Static Software Analysis Tools | ||
* slizaa-server-command - Slizaa Static Software Analysis Tools | ||
* Copyright © 2019 Code-Kontor GmbH and others ([email protected]) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
|
@@ -15,7 +15,7 @@ | |
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package io.codekontor.slizaa.server; | ||
package io.codekontor.slizaa.server.command; | ||
|
||
import io.codekontor.slizaa.server.service.slizaa.IGraphDatabase; | ||
import io.codekontor.slizaa.server.service.slizaa.IHierarchicalGraph; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/** | ||
* slizaa-server-main - Slizaa Static Software Analysis Tools | ||
* slizaa-server-command - Slizaa Static Software Analysis Tools | ||
* Copyright © 2019 Code-Kontor GmbH and others ([email protected]) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
|
@@ -15,7 +15,7 @@ | |
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package io.codekontor.slizaa.server; | ||
package io.codekontor.slizaa.server.command; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.SpringApplication; | ||
|
32 changes: 32 additions & 0 deletions
32
...main/java/io/codekontor/slizaa/server/command/SlizaaServerCommandModuleConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* slizaa-server-command - Slizaa Static Software Analysis Tools | ||
* Copyright © 2019 Code-Kontor GmbH and others ([email protected]) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package io.codekontor.slizaa.server.command; | ||
|
||
import io.codekontor.slizaa.hierarchicalgraph.graphdb.mapping.service.IMappingService; | ||
import io.codekontor.slizaa.server.service.slizaa.internal.SlizaaServiceDatabaseProperties; | ||
import io.codekontor.slizaa.server.service.slizaa.internal.SlizaaServiceImpl; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@ComponentScan(basePackageClasses = {AbstractGraphDatabaseCommandComponent.class}) | ||
public class SlizaaServerCommandModuleConfiguration { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters