Skip to content

Commit

Permalink
GH-2 Moved commands to its own module
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerd Wuetherich committed Jun 19, 2019
1 parent 688037b commit 2a8b7bf
Show file tree
Hide file tree
Showing 14 changed files with 847 additions and 19 deletions.
3 changes: 2 additions & 1 deletion slizaa-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<module>slizaa-server-graphql</module>
<module>slizaa-server-main</module>
<module>slizaa-server-spec</module>
</modules>
<module>slizaa-server-command</module>
</modules>

</project>
661 changes: 661 additions & 0 deletions slizaa-server/slizaa-server-command/LICENSE.txt

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions slizaa-server/slizaa-server-command/pom.xml
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>
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
Expand All @@ -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;
Expand Down
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 {
}
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
Expand All @@ -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;
Expand Down
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
Expand All @@ -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;
Expand Down
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
Expand All @@ -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;
Expand Down
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
Expand All @@ -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;
Expand All @@ -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")
Expand All @@ -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();
}
}
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
Expand All @@ -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;
Expand Down
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
Expand All @@ -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;
Expand Down
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 {

}
5 changes: 5 additions & 0 deletions slizaa-server/slizaa-server-main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
<artifactId>slizaa-server-service-slizaa</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.codekontor.slizaa</groupId>
<artifactId>slizaa-server-command</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.codekontor.slizaa</groupId>
<artifactId>slizaa-server-graphql</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package io.codekontor.slizaa.server;

import io.codekontor.slizaa.server.command.EnableSlizaaServerCommandModule;
import io.codekontor.slizaa.server.graphql.EnableGraphqlModule;
import io.codekontor.slizaa.server.service.backend.EnableBackendServiceModule;
import io.codekontor.slizaa.server.service.configuration.EnableConfigurationModule;
Expand All @@ -37,6 +38,7 @@
@EnableGraphqlModule
@EnableConfigurationModule
@EnableSvgServiceModule
@EnableSlizaaServerCommandModule
public class SlizaaServer {

/**
Expand Down

0 comments on commit 2a8b7bf

Please sign in to comment.