Skip to content

Commit

Permalink
#243 Merge branch 'dev_xmlplugin'
Browse files Browse the repository at this point in the history
  • Loading branch information
maybeec committed Dec 14, 2016
2 parents 1dce3f0 + 45f7cf4 commit 16bf2d4
Show file tree
Hide file tree
Showing 46 changed files with 1,825 additions and 1,912 deletions.
119 changes: 5 additions & 114 deletions cobigen/cobigen-xmlplugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.capgemini</groupId>
<artifactId>cobigen-xmlplugin</artifactId>
<name>CobiGen - XML Plug-In</name>
<version>2.1.0</version>
<version>3.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<parent>
Expand All @@ -18,121 +17,13 @@
<dependency>
<groupId>com.capgemini</groupId>
<artifactId>cobigen-core</artifactId>
<version>1.2.0</version>
<version>3.0.0-SNAPSHOT</version>
</dependency>

<!-- XML Merge for structural merge -->
<dependency>
<groupId>ch.elca.el4j.modules</groupId>
<artifactId>module-core</artifactId>
<version>3.1</version>
<exclusions>
<exclusion>
<groupId>javax.inject</groupId>
<artifactId>inject</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
</exclusion>
<exclusion>
<groupId>net.java.dev.which4j</groupId>
<artifactId>which4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.aspectj</groupId>
<artifactId>aspectjmatcher</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.bcel</groupId>
<artifactId>bcel</artifactId>
</exclusion>
<exclusion>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- Adopt legacy logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.7</version>
</dependency>

<!-- <dependency>
<groupId>ch.elca.el4j.modules</groupId>
<artifactId>module-jmx</artifactId>
<version>3.1</version>
<exclusions>
<exclusion>
<groupId>javax.inject</groupId>
<artifactId>inject</artifactId>
</exclusion>
</exclusions>
</dependency> -->
<dependency>
<groupId>ch.elca.el4j.modules</groupId>
<artifactId>module-xml_merge-common</artifactId>
<version>3.1</version>
<exclusions>
<exclusion>
<groupId>javax.inject</groupId>
<artifactId>inject</artifactId>
</exclusion>
<exclusion>
<groupId>jdom</groupId>
<artifactId>jdom</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- Explicit definition of dependency due to access restrictions of the original XML Merge library dependencies -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>

<!-- Explicit JDom version as result of dependency conflicts -->
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom</artifactId>
<version>1.1.3</version>
<artifactId>lexeme</artifactId>
<groupId>com.github.maybeec</groupId>
<version>1.0.0</version>
</dependency>
</dependencies>

<repositories>
<!-- For XML Merge -->
<!-- Build with Maven2 or 3.1.x due to strange dependencies which should be authorized !!! -->
<repository>
<id>el4jReleaseRepositoryExternal</id>
<name>External release repository of the EL4J project</name>
<url>http://public-el4.elca-services.ch/el4j/maven2repository</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,38 @@

import java.util.List;

import com.capgemini.cobigen.extension.IGeneratorPluginActivator;
import com.capgemini.cobigen.extension.IMerger;
import com.capgemini.cobigen.extension.ITriggerInterpreter;
import com.capgemini.cobigen.xmlplugin.merger.XmlMerger;
import com.capgemini.cobigen.xmlplugin.merger.action.CompleteMergeAction;
import com.capgemini.cobigen.xmlplugin.merger.action.OverrideMergeAction;
import com.capgemini.cobigen.api.extension.GeneratorPluginActivator;
import com.capgemini.cobigen.api.extension.Merger;
import com.capgemini.cobigen.api.extension.TriggerInterpreter;
import com.capgemini.cobigen.impl.PluginRegistry;
import com.capgemini.cobigen.xmlplugin.merger.delegates.MergeType;
import com.capgemini.cobigen.xmlplugin.merger.delegates.XmlMergerDelegate;
import com.google.common.collect.Lists;

/**
*
* @author mbrunnli (06.04.2014)
* Plug-in activator to be registered at CobiGen's {@link PluginRegistry}.
*/
public class XmlPluginActivator implements IGeneratorPluginActivator {
public class XmlPluginActivator implements GeneratorPluginActivator {

/**
* {@inheritDoc}
* @author mbrunnli (06.04.2014)
* defining the default location of the merge schemas
*/
static private String defaultMergeSchemaLocation = "src/main/resources/mergeSchemas";

@Override
public List<IMerger> bindMerger() {
List<IMerger> merger = Lists.newLinkedList();
merger.add(new XmlMerger("xmlmerge", new CompleteMergeAction()));
merger.add(new XmlMerger("xmlmerge_override", new OverrideMergeAction()));
public List<Merger> bindMerger() {
List<Merger> merger = Lists.newLinkedList();

merger.add(new XmlMergerDelegate(defaultMergeSchemaLocation, MergeType.BASEOVERWRITE));
merger.add(new XmlMergerDelegate(defaultMergeSchemaLocation, MergeType.BASEATTACHOROVERWRITE));
merger.add(new XmlMergerDelegate(defaultMergeSchemaLocation, MergeType.PATCHOVERWRITE));
merger.add(new XmlMergerDelegate(defaultMergeSchemaLocation, MergeType.PATCHATTACHOROVERWRITE));
return merger;
}

/**
* {@inheritDoc}
* @author mbrunnli (08.04.2014)
*/
@Override
public List<ITriggerInterpreter> bindTriggerInterpreter() {
return Lists.<ITriggerInterpreter> newArrayList(new XmlTriggerInterpreter("xml"));
public List<TriggerInterpreter> bindTriggerInterpreter() {
return Lists.<TriggerInterpreter> newArrayList(new XmlTriggerInterpreter("xml"));
}

}
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
package com.capgemini.cobigen.xmlplugin;

import com.capgemini.cobigen.extension.IInputReader;
import com.capgemini.cobigen.extension.IMatcher;
import com.capgemini.cobigen.extension.ITriggerInterpreter;
import com.capgemini.cobigen.api.extension.InputReader;
import com.capgemini.cobigen.api.extension.MatcherInterpreter;
import com.capgemini.cobigen.api.extension.TriggerInterpreter;
import com.capgemini.cobigen.xmlplugin.inputreader.XmlInputReader;
import com.capgemini.cobigen.xmlplugin.matcher.XmlMatcher;

/**
* {@link ITriggerInterpreter} implementation of a Xml Interpreter
*
* @author fkreis (18.11.2014)
* {@link TriggerInterpreter} implementation of a Xml Interpreter
*/
public class XmlTriggerInterpreter implements ITriggerInterpreter {
public class XmlTriggerInterpreter implements TriggerInterpreter {

/**
* {@link ITriggerInterpreter} type to be registered
* {@link TriggerInterpreter} type to be registered
*/
public String type;

Expand All @@ -30,30 +28,18 @@ public XmlTriggerInterpreter(String type) {
this.type = type;
}

/**
* {@inheritDoc}
* @author fkreis (18.11.2014)
*/
@Override
public String getType() {
return type;
}

/**
* {@inheritDoc}
* @author fkreis (18.11.2014)
*/
@Override
public IInputReader getInputReader() {
public InputReader getInputReader() {
return new XmlInputReader();
}

/**
* {@inheritDoc}
* @author fkreis (18.11.2014)
*/
@Override
public IMatcher getMatcher() {
public MatcherInterpreter getMatcher() {
return new XmlMatcher();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,22 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import com.capgemini.cobigen.extension.IInputReader;
import com.capgemini.cobigen.api.extension.InputReader;

/**
*
* @author fkreis (10.11.2014)
* {@link InputReader} for XML files.
*/
public class XmlInputReader implements IInputReader {
public class XmlInputReader implements InputReader {

/**
* {@inheritDoc}
* @author fkreis (10.11.2014)
*/
@Override
public boolean isValidInput(Object input) {
if (input instanceof Document) {
return true;
} else {
return false;
}

}

/**
* {@inheritDoc}
* @author fkreis (10.11.2014)
*/
@Override
public Map<String, Object> createModel(Object input) {
if (isValidInput(input)) {
Expand All @@ -49,15 +39,12 @@ public Map<String, Object> createModel(Object input) {
} else {
return null;
}

}

/**
* {@inheritDoc}<br>
* <br>
* {@inheritDoc}.<br>
* Since the {@link XmlInputReader} does not support multiple input objects it always returns
* <code>false</code>.
* @author fkreis (10.11.2014)
*/
@Override
public boolean combinesMultipleInputObjects(Object input) {
Expand All @@ -66,35 +53,38 @@ public boolean combinesMultipleInputObjects(Object input) {

/**
* {@inheritDoc}<br>
* <br>
* Since the {@link XmlInputReader} does not support multiple input objects it always returns an empty
* {@link List}.
* @author fkreis (10.11.2014)
*/
@Override
public List<Object> getInputObjects(Object input, Charset inputCharset) {
List<Object> emptyList = new LinkedList<>();
return emptyList;
return new LinkedList<>();
}

/**
* {@inheritDoc}<br>
* Since the {@link XmlInputReader} does not support multiple input objects it always returns an empty
* {@link List}.
*/
@Override
public List<Object> getInputObjectsRecursively(Object input, Charset inputCharset) {
return new LinkedList<>();
}

/**
* {@inheritDoc} <br>
* <br>
* Since the {@link XmlInputReader} does not provide any template methods it always returns an empty
* {@link Map}.
* @author fkreis (10.11.2014)
*/
@Override
public Map<String, Object> getTemplateMethods(Object input) {
Map<String, Object> emptyMap = new HashMap<>();
return emptyMap;
return new HashMap<>();
}

/**
* @param input
* the element the model should derived from
* @return derived sub model
* @author fkreis (17.11.2014)
*/
private Map<String, Object> deriveSubModel(Element input) {
// prepare result object
Expand Down
Loading

0 comments on commit 16bf2d4

Please sign in to comment.