Skip to content

Commit

Permalink
improved effect/modifier support and configurable validation
Browse files Browse the repository at this point in the history
* error for castable non-fictional persons
* configurable new thread id/genre validation level
* configurable triggered news uniqueness flag validation
* more contries
* add database normalizer code
* configurable enable effect validator (expensive and buggy)
* improve (configurable) validation of unsupported attributes
* (configurable) person name validation
  • Loading branch information
nittka committed Dec 3, 2023
1 parent ef4f592 commit b21d509
Show file tree
Hide file tree
Showing 43 changed files with 817 additions and 144 deletions.
20 changes: 20 additions & 0 deletions .launch/package.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.m2e.Maven2LaunchConfigurationType">
<booleanAttribute key="M2_DEBUG_OUTPUT" value="false"/>
<stringAttribute key="M2_GOALS" value="package"/>
<booleanAttribute key="M2_NON_RECURSIVE" value="false"/>
<booleanAttribute key="M2_OFFLINE" value="false"/>
<stringAttribute key="M2_PROFILES" value=""/>
<listAttribute key="M2_PROPERTIES"/>
<stringAttribute key="M2_RUNTIME" value="EMBEDDED"/>
<booleanAttribute key="M2_SKIP_TESTS" value="true"/>
<intAttribute key="M2_THREADS" value="1"/>
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/>
<stringAttribute key="M2_USER_SETTINGS" value=""/>
<booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="false"/>
<stringAttribute key="bad_container_name" value="\org.tvtower.db.parent\package"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk-13.0.1"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:/org.tvtower.db.parent}"/>
</launchConfiguration>
22 changes: 22 additions & 0 deletions .launch/setVersion.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.m2e.Maven2LaunchConfigurationType">
<booleanAttribute key="M2_DEBUG_OUTPUT" value="false"/>
<stringAttribute key="M2_GOALS" value="org.eclipse.tycho:tycho-versions-plugin:2.2.0:set-version"/>
<booleanAttribute key="M2_NON_RECURSIVE" value="false"/>
<booleanAttribute key="M2_OFFLINE" value="false"/>
<stringAttribute key="M2_PROFILES" value=""/>
<listAttribute key="M2_PROPERTIES">
<listEntry value="newVersion=1.3.0-SNAPSHOT"/>
<listEntry value="tycho.mode=maven"/>
</listAttribute>
<stringAttribute key="M2_RUNTIME" value="EMBEDDED"/>
<booleanAttribute key="M2_SKIP_TESTS" value="true"/>
<intAttribute key="M2_THREADS" value="1"/>
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/>
<stringAttribute key="M2_USER_SETTINGS" value=""/>
<booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk-13.0.1"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:/org.tvtower.db.parent}"/>
</launchConfiguration>
2 changes: 2 additions & 0 deletions .launch/setVersion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The set version call does not update the MANIFEST.MF of org.tvtower.db.product.
It is not part of the multi-module build...
2 changes: 1 addition & 1 deletion org.tvtower.db.feature/feature.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<feature id="org.tvtower.db.feature"
label="Database Feature "
version="1.1.0.qualifier">
version="1.2.0.qualifier">
<plugin
id="org.tvtower.db"
download-size="0"
Expand Down
2 changes: 1 addition & 1 deletion org.tvtower.db.feature/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.tvtower.db</groupId>
<artifactId>org.tvtower.db.parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
</parent>
<artifactId>org.tvtower.db.feature</artifactId>
<packaging>eclipse-feature</packaging>
Expand Down
2 changes: 1 addition & 1 deletion org.tvtower.db.ide/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Automatic-Module-Name: org.tvtower.db.ide
Bundle-ManifestVersion: 2
Bundle-Name: org.tvtower.db.ide
Bundle-Version: 1.1.0.qualifier
Bundle-Version: 1.2.0.qualifier
Bundle-SymbolicName: org.tvtower.db.ide; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: org.tvtower.db,
Expand Down
2 changes: 1 addition & 1 deletion org.tvtower.db.ide/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.tvtower.db</groupId>
<artifactId>org.tvtower.db.parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
</parent>
<artifactId>org.tvtower.db.ide</artifactId>
<packaging>eclipse-plugin</packaging>
Expand Down
2 changes: 1 addition & 1 deletion org.tvtower.db.product/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: TVTower DB Editor
Bundle-SymbolicName: org.tvtower.db.product;singleton:=true
Bundle-Version: 1.1.0.qualifier
Bundle-Version: 1.2.0.qualifier
Automatic-Module-Name: org.tvtower.db.product
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
2 changes: 1 addition & 1 deletion org.tvtower.db.repository/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.tvtower.db</groupId>
<artifactId>org.tvtower.db.parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
</parent>
<artifactId>org.tvtower.db.repository</artifactId>
<packaging>eclipse-repository</packaging>
Expand Down
2 changes: 1 addition & 1 deletion org.tvtower.db.target/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.tvtower.db</groupId>
<artifactId>org.tvtower.db.parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
</parent>
<artifactId>org.tvtower.db.target</artifactId>
<packaging>eclipse-target-definition</packaging>
Expand Down
2 changes: 1 addition & 1 deletion org.tvtower.db.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Automatic-Module-Name: org.tvtower.db.tests
Bundle-ManifestVersion: 2
Bundle-Name: org.tvtower.db.tests
Bundle-Version: 1.1.0.qualifier
Bundle-Version: 1.2.0.qualifier
Bundle-SymbolicName: org.tvtower.db.tests; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: org.tvtower.db,
Expand Down
2 changes: 1 addition & 1 deletion org.tvtower.db.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.tvtower.db</groupId>
<artifactId>org.tvtower.db.parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
</parent>
<artifactId>org.tvtower.db.tests</artifactId>
<packaging>eclipse-test-plugin</packaging>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
package org.tvtower.db.tests;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.TreeMap;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.junit.Ignore;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;

import com.google.common.io.Files;

@Ignore
public class DbNormalizeForRefacotring {

TreeMap<String, Node> persons = new TreeMap<>();
TreeMap<String, Node> programmes = new TreeMap<>();
TreeMap<String, Node> ads = new TreeMap<>();
TreeMap<String, Node> news = new TreeMap<>();
TreeMap<String, Node> scripts = new TreeMap<>();

@Test
public void iterateFolder() throws IOException {
File parent = new File(".").getAbsoluteFile().getParentFile().getParentFile().getParentFile();
File baseDir = new File(parent,"TVTower/res/database/default");

Iterable<File> iterable = Files.fileTraverser().breadthFirst(baseDir);
for (File file : iterable) {
if(file.isFile() && file.getName().endsWith("xml") && ! file.getParentFile().getName().startsWith("lang")) {
parseFile(file.getAbsolutePath(), "person", persons);
parseFile(file.getAbsolutePath(), "programme", programmes);
parseFile(file.getAbsolutePath(), "ad", ads);
parseFile(file.getAbsolutePath(), "news", news);
parseFile(file.getAbsolutePath(), "scripttemplate", scripts);
}
}

String normName="normalizedOrig.txt";
write(persons, "persons/"+normName);
write(programmes, "progs/"+normName);
write(ads, "ads/"+normName);
write(news, "news/"+normName);
write(scripts, "scripts/"+normName);
}

@Test
public void normalizePersons() throws IOException {
parsePersonFile("persons/db_orig.xml");
write(persons, "persons/normOrig.txt");
persons.clear();

parsePersonFile("persons/db_new.xml");
parsePersonFile("persons/db_new2.xml");
write(persons, "persons/normNew.txt");
}

@Test
public void normalizeProgrammes() throws IOException {
parseProgrammeFile("progs/dborig1.xml");
parseProgrammeFile("progs/dborig2.xml");
write(programmes, "progs/normOrig.txt");
programmes.clear();

parseProgrammeFile("progs/dbnew1.xml");
parseProgrammeFile("progs/dbnew2.xml");
write(programmes, "progs/normNew.txt");
}


private void parsePersonFile(String fileName) {
parseFile(fileName, "person", persons);
}

private void parseProgrammeFile(String fileName) {
parseFile(fileName, "programme", programmes);
}


private void write(TreeMap<String, Node> map, String targetFile) throws IOException {
String target="target/dbcompare/"+targetFile;
File parent=new File(target).getParentFile();
if(!parent.exists()) {
parent.getParentFile().mkdir();
parent.mkdir();
}
FileOutputStream f = new FileOutputStream(target);
for (String id : map.keySet()) {
f.write(toString(map.get(id)).getBytes());
f.write("\n".getBytes());
}
f.flush();
f.close();
}

public void parseFile(String fileName, String baseTag, TreeMap<String, Node> map) {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource(new FileInputStream(new File(fileName)));

Document doc = db.parse(is);
NodeList nodes = doc.getElementsByTagName(baseTag);

// iterate the employees
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
String id = ((Element) node).getAttribute(baseTag=="scripttemplate"?"guid":"id");
if (map.containsKey(id)) {
throw new IllegalStateException("duplicate id '" + id +"' in "+fileName );
} else {
map.put(id, node);
}
}
} catch (Exception e) {
e.printStackTrace();
}

}

private String toString(Node n) {
StringBuilder b = new StringBuilder(n.getNodeName());
b.append(" - ");
String nodeValue = n.getNodeValue();
if (nodeValue != null && nodeValue.length() > 0) {
b.append(nodeValue);
b.append(" - ");
}

TreeMap<String, String> attMap = new TreeMap<>();
NamedNodeMap attributes = n.getAttributes();
if (attributes != null) {
for (int i = 0; i < attributes.getLength(); i++) {
Node att = attributes.item(i);
String value = att.getNodeValue();
if (value != null && value.length() > 0) {
attMap.put(att.getNodeName(), value);
}
}
if (!attMap.isEmpty()) {
b.append("attributes: ");
b.append(attMap);
}
}
NodeList children = n.getChildNodes();
if (children != null) {
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child != null) {
String childText = toString(child);
if (childText != null && childText.length() > 0) {
b.append("; child: " + childText);
}
}
}
}

// System.out.println(attMap);
return b.toString();
}
}
2 changes: 1 addition & 1 deletion org.tvtower.db.ui.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Automatic-Module-Name: org.tvtower.db.ui.tests
Bundle-ManifestVersion: 2
Bundle-Name: org.tvtower.db.ui.tests
Bundle-Version: 1.1.0.qualifier
Bundle-Version: 1.2.0.qualifier
Bundle-SymbolicName: org.tvtower.db.ui.tests; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: org.tvtower.db.ui,
Expand Down
2 changes: 1 addition & 1 deletion org.tvtower.db.ui.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.tvtower.db</groupId>
<artifactId>org.tvtower.db.parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
</parent>
<artifactId>org.tvtower.db.ui.tests</artifactId>
<packaging>eclipse-test-plugin</packaging>
Expand Down
2 changes: 1 addition & 1 deletion org.tvtower.db.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Automatic-Module-Name: org.tvtower.db.ui
Bundle-ManifestVersion: 2
Bundle-Name: org.tvtower.db.ui
Bundle-Version: 1.1.0.qualifier
Bundle-Version: 1.2.0.qualifier
Bundle-SymbolicName: org.tvtower.db.ui; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: org.tvtower.db,
Expand Down
2 changes: 1 addition & 1 deletion org.tvtower.db.ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.tvtower.db</groupId>
<artifactId>org.tvtower.db.parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
</parent>
<artifactId>org.tvtower.db.ui</artifactId>
<packaging>eclipse-plugin</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.eclipse.xtext.ui.editor.hover.IEObjectHoverProvider;
import org.eclipse.xtext.ui.editor.outline.actions.OutlineWithEditorLinker;
import org.eclipse.xtext.ui.editor.toggleComments.DefaultSingleLineCommentHelper;
import org.eclipse.xtext.ui.validation.AbstractValidatorConfigurationBlock;
import org.tvtower.db.ui.hover.DatabaseEObjectHover;
import org.tvtower.db.ui.hover.DatabaseHoverProvider;
import org.tvtower.db.ui.outline.DatabaseOutlineWithEditorLinker;
Expand Down Expand Up @@ -37,10 +38,14 @@ public Class<? extends IEObjectHover> bindIEObjectHover() {
return DatabaseEObjectHover.class;
}

public Class<? extends AbstractValidatorConfigurationBlock> bindAbstractValidatorConfigurationBlock() {
return DatabaseValidatorConfigurationBlock.class;
}

@Override
public void configure(Binder binder) {
super.configure(binder);
//cause comment rule not to be found, so that no comment toggling is done
// cause comment rule not to be found, so that no comment toggling is done
binder.bind(String.class).annotatedWith(Names.named(DefaultSingleLineCommentHelper.SL_COMMENT))
.toInstance("thereIsNoSLComment");
}
Expand Down
Loading

0 comments on commit b21d509

Please sign in to comment.