Permalink
Browse files

Move drools-guvnor-models to drools multi-project

  • Loading branch information...
1 parent fba3242 commit 8988787fa86946fa5ca56dd7066f2169ec76f648 @manstis manstis committed Mar 25, 2013
Showing 319 changed files with 38,441 additions and 0 deletions.
@@ -0,0 +1,14 @@
+/target
+/local
+
+# Eclipse, Netbeans and IntelliJ files
+/.*
+/**/.*
+!.gitignore
+/nbproject
+*.ipr
+*.iws
+*.iml
+
+# Repository wide ignore mac DS_Store files
+.DS_Store
@@ -0,0 +1,14 @@
+/target
+/local
+
+# Eclipse, Netbeans and IntelliJ files
+/.*
+/**/.*
+!.gitignore
+/nbproject
+*.ipr
+*.iws
+*.iml
+
+# Repository wide ignore mac DS_Store files
+.DS_Store
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+ <artifactId>drools-guvnor-models</artifactId>
+ <groupId>org.drools</groupId>
+ <version>6.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.drools</groupId>
+ <artifactId>drools-guvnor-models-commons</artifactId>
+
+ <name>Drools Guvnor - Common Model</name>
+ <description>Drools Guvnor - Common Model</description>
+
+ <dependencies>
+
+ <!-- Internal dependencies -->
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-compiler</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.kie.commons</groupId>
+ <artifactId>kie-commons-validation</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <resources>
+ <!-- Include src/main/java in order not to break the Eclipse GWT plug-in -->
+ <resource>
+ <directory>src/main/java</directory>
+ </resource>
+ <!-- Include module descriptors from src/main/resources in order not to break the Intellij GWT plug-in -->
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ </build>
+</project>
@@ -0,0 +1,14 @@
+package org.drools.guvnor.models.commons.backend;
+
+import org.drools.compiler.kie.builder.impl.FormatConverter;
+
+public abstract class BaseConverter implements FormatConverter {
+
+ protected String getDestinationName(String name) {
+ return getDestinationName(name, false);
+ }
+
+ protected String getDestinationName(String name, boolean hasDsl) {
+ return name.substring(0, name.lastIndexOf('.')) + (hasDsl ? ".dslr" : ".drl");
+ }
+}
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2011 JBoss Inc
+ *
+ * Licensed 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
+ *
+ * http://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.
+ */
+package org.drools.guvnor.models.commons.backend;
+
+/**
+ * Interface for utility classes handling upgrades to Models. This may be
+ * required as the Model changes to support different (future) requirements.
+ *
+ * @param <T>
+ * The return model type after upgrade
+ * @param <V>
+ * The source model type
+ */
+public interface IUpgradeHelper<T, V> {
+
+ T upgrade( V model );
+
+}
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2012 JBoss Inc
+ *
+ * Licensed 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
+ *
+ * http://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.
+ */
+package org.drools.guvnor.models.commons.backend.imports;
+
+import org.drools.guvnor.models.commons.shared.imports.Import;
+import org.drools.guvnor.models.commons.shared.imports.Imports;
+
+/**
+ * Utility methods to parse an Imports Config
+ */
+public final class ImportsParser {
+
+ private static final String KEYWORD = "import ";
+
+ private ImportsParser() {
+ }
+
+ public static Imports parseImports( final String content ) {
+ Imports imports = new Imports();
+
+ if ( content == null || content.trim().equals( "" ) ) {
+ return imports;
+ } else {
+ final String[] lines = content.split( "\\n" );
+
+ for ( int i = 0; i < lines.length; i++ ) {
+ String line = lines[ i ].trim();
+ if ( !( line.equals( "" ) || line.startsWith( "#" ) ) ) {
+ if ( line.startsWith( KEYWORD ) ) {
+ line = line.substring( KEYWORD.length() ).trim();
+ if ( line.endsWith( ";" ) ) {
+ line = line.substring( 0, line.length() - 1 );
+ }
+ imports.addImport( new Import( line ) );
+ }
+ }
+ }
+
+ return imports;
+ }
+
+ }
+
+}
@@ -0,0 +1,23 @@
+package org.drools.guvnor.models.commons.backend.imports;
+
+import org.drools.guvnor.models.commons.shared.imports.HasImports;
+import org.drools.guvnor.models.commons.shared.imports.Imports;
+
+/**
+ * Writes import details to a String
+ */
+public class ImportsWriter {
+
+ public static void write( final StringBuilder sb,
+ final HasImports model ) {
+ final Imports imports = model.getImports();
+ if ( imports == null ) {
+ return;
+ }
+ sb.append( imports.toString() );
+ if ( imports.getImports().size() > 0 ) {
+ sb.append( "\n" );
+ }
+ }
+
+}
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2012 JBoss Inc
+ *
+ * Licensed 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
+ *
+ * http://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.
+ */
+package org.drools.guvnor.models.commons.backend.packages;
+
+/**
+ * Utility methods to parse a Package Name
+ */
+public final class PackageNameParser {
+
+ private static final String KEYWORD = "package ";
+
+ private PackageNameParser() {
+ }
+
+ public static String parsePackageName( final String content ) {
+ String packageName = "";
+
+ if ( content == null || content.trim().equals( "" ) ) {
+ return packageName;
+ } else {
+ final String[] lines = content.split( "\\n" );
+
+ for ( int i = 0; i < lines.length; i++ ) {
+ String line = lines[ i ].trim();
+ if ( !( line.equals( "" ) || line.startsWith( "#" ) ) ) {
+ if ( line.startsWith( KEYWORD ) ) {
+ line = line.substring( KEYWORD.length() ).trim();
+ if ( line.endsWith( ";" ) ) {
+ line = line.substring( 0, line.length() - 1 );
+ }
+ return line;
+ }
+ }
+ }
+
+ return packageName;
+ }
+
+ }
+
+}
@@ -0,0 +1,18 @@
+package org.drools.guvnor.models.commons.backend.packages;
+
+import org.drools.guvnor.models.commons.shared.packages.HasPackageName;
+
+/**
+ * Writes Package details to a String
+ */
+public class PackageNameWriter {
+
+ public static void write( final StringBuilder sb,
+ final HasPackageName model ) {
+ final String packageName = model.getPackageName();
+ if ( !( packageName == null || packageName.isEmpty() ) ) {
+ sb.append( "package " ).append( packageName ).append( ";\n\n" );
+ }
+ }
+
+}
Oops, something went wrong.

0 comments on commit 8988787

Please sign in to comment.