Skip to content

Commit

Permalink
JENA-1108 : jena-cmds module
Browse files Browse the repository at this point in the history
  • Loading branch information
afs committed Jan 5, 2016
1 parent eb9eec0 commit 498b226
Show file tree
Hide file tree
Showing 140 changed files with 484 additions and 415 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package org.apache.jena.sparql;

import arq.TS_Cmd ;
import junit.framework.JUnit4TestAdapter ;
import junit.framework.TestSuite ;
import org.apache.jena.atlas.legacy.BaseTest2 ;
Expand Down Expand Up @@ -60,7 +59,6 @@ static public TestSuite suite()
ts.addTest(new JUnit4TestAdapter(TC_Common.class)) ;
ts.addTest(new JUnit4TestAdapter(TC_Riot.class)) ;

ts.addTest(new JUnit4TestAdapter(TS_Cmd.class)) ;
ts.addTest(new JUnit4TestAdapter(TS_Web.class)) ;

// Main ARQ internal test suite.
Expand Down
117 changes: 117 additions & 0 deletions jena-cmds/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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.
-->

<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.jena</groupId>
<artifactId>jena-parent</artifactId>
<version>16-SNAPSHOT</version>
<relativePath>../jena-parent</relativePath>
</parent>

<name>Apache Jena - Command line tools</name>
<artifactId>jena-cmds</artifactId>
<version>3.1.0-SNAPSHOT</version>

<description>Command line tools</description>

<packaging>jar</packaging>

<url>http://jena.apache.org/</url>

<repositories>
<repository>
<id>apache.snapshots</id>
<name>Apache Snapshot Repository</name>
<url>http://repository.apache.org/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>

<organization>
<name>Apache Jena</name>
<url>http://jena.apache.org/</url>
</organization>

<licenses>
<license>
<name>Apache 2.0 License</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>

<properties>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ssZ</maven.build.timestamp.format>
<build.time.xsd>${maven.build.timestamp}</build.time.xsd>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>apache-jena-libs</artifactId>
<version>3.1.0-SNAPSHOT</version>
<type>pom</type>
</dependency>

<!-- Command Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${ver.slf4j}</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${ver.slf4j}</version>
</dependency>

<!-- Testing -->

<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-arq</artifactId>
<version>3.1.0-SNAPSHOT</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-core</artifactId>
<version>3.1.0-SNAPSHOT</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-base</artifactId>
<version>3.1.0-SNAPSHOT</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>

</dependencies>

</project>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,9 @@

package jena;



public class query
{
public class query {
// Call-through to arq command line application
public static void main(String... args)
{
// Do this by reflection so it is not assumed that ARQ is available
// at compile time.

InvokingUtil.invokeCmd("arq.query", args) ;
public static void main(String... args) {
arq.query.main(args);
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@

package jena;


public class rset
{
// Call-through to arq command line application
public static void main(String... args)
{
InvokingUtil.invokeCmd("arq.rset", args) ;
public class rset {
public static void main(String... args) {
arq.rset.main(args);
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@

package jena;


public class sparql
{
// Call-through to arq command line application
public static void main(String[] args)
{
InvokingUtil.invokeCmd("arq.sparql",args) ;
public class sparql {
public static void main(String[] args) {
arq.sparql.main(args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@

package jena;



public class turtle
{
public static void main(String... args)
{
InvokingUtil.invokeCmd("riotcmd.turtle",args) ;
public class turtle {
public static void main(String... args) {
riotcmd.turtle.main(args);
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
132 changes: 132 additions & 0 deletions jena-cmds/src/main/java/tdb/CmdNodeTableBuilder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 tdb;

import java.util.Arrays ;
import java.util.List ;
import java.util.Objects ;

import jena.cmd.ArgDecl;
import jena.cmd.CmdException;
import jena.cmd.CmdGeneral;
import org.apache.jena.atlas.lib.FileOps ;
import org.apache.jena.atlas.logging.LogCtl ;
import org.apache.jena.riot.Lang ;
import org.apache.jena.riot.RDFLanguages ;
import org.apache.jena.system.JenaSystem ;
import org.apache.jena.tdb.base.file.Location ;
import org.apache.jena.tdb.setup.DatasetBuilderStd ;
import org.apache.jena.tdb.store.bulkloader2.ProcNodeTableBuilder ;
import tdb.cmdline.CmdTDB ;

/** Build node table - write triples/quads as text file */
public class CmdNodeTableBuilder extends CmdGeneral
{
static { LogCtl.setLog4j() ; }
static { JenaSystem.init(); }


private static ArgDecl argLocation = new ArgDecl(ArgDecl.HasValue, "loc", "location") ;
private static ArgDecl argTriplesOut = new ArgDecl(ArgDecl.HasValue, "triples") ;
private static ArgDecl argQuadsOut = new ArgDecl(ArgDecl.HasValue, "quads") ;
private static ArgDecl argNoStats = new ArgDecl(ArgDecl.NoValue, "nostats") ;

private String locationString ;
private String dataFileTriples ;
private String dataFileQuads ;
private List<String> datafiles ;
private Location location ;
private boolean collectStats = true ;

public static void main(String...argv)
{
System.err.println("CmdNodeTableBuilder");
CmdTDB.init() ;
DatasetBuilderStd.setOptimizerWarningFlag(false) ;
new CmdNodeTableBuilder(argv).mainRun() ;
}

public CmdNodeTableBuilder(String...argv)
{
super(argv) ;
super.add(argLocation, "--loc", "Location") ;
super.add(argTriplesOut, "--triples", "Output file for triples") ;
super.add(argQuadsOut, "--quads", "Output file for quads") ;
super.add(argNoStats, "--nostats", "Don't collect stats") ;
}

@Override
protected void processModulesAndArgs()
{
if ( !super.contains(argLocation) ) throw new CmdException("Required: --loc DIR") ;
// if ( !super.contains(argTriplesOut) ) throw new CmdException("Required: --triples FILE") ;
// if ( !super.contains(argQuadsOut) ) throw new CmdException("Required: --quads FILE") ;

locationString = super.getValue(argLocation) ;
location = Location.create(locationString) ;

dataFileTriples = super.getValue(argTriplesOut) ;
if ( dataFileTriples == null )
dataFileTriples = location.getPath("triples", "tmp") ;

dataFileQuads = super.getValue(argQuadsOut) ;
if ( dataFileQuads == null )
dataFileQuads = location.getPath("quads", "tmp") ;

if ( Objects.equals(dataFileTriples, dataFileQuads) )
cmdError("Triples and Quads work files are the same") ;

if ( super.contains(argNoStats) )
collectStats = false ;

//datafiles = getPositionalOrStdin() ;
datafiles = getPositional() ;
if ( datafiles.isEmpty() )
datafiles = Arrays.asList("-") ;

// ---- Checking.
for( String filename : datafiles)
{
Lang lang = RDFLanguages.filenameToLang(filename, RDFLanguages.NQUADS) ;
if ( lang == null )
// Does not happen due to default above.
cmdError("File suffix not recognized: " +filename) ;
if ( ! filename.equals("-") && ! FileOps.exists(filename) )
cmdError("File does not exist: "+filename) ;
}
}

@Override
protected void exec()
{
ProcNodeTableBuilder.execInner(location, dataFileTriples, dataFileQuads, datafiles, collectStats);
}

@Override
protected String getSummary()
{
return getCommandName()+" --loc=DIR [--triples=tmpFile1] [--quads=tmpFile2] FILE ..." ;
}

@Override
protected String getCommandName()
{
return this.getClass().getName() ;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package tdb.cmdline;

import arq.cmdline.CmdARQ ;
import org.apache.jena.Jena ;
import org.apache.jena.atlas.lib.Lib ;
import org.apache.jena.atlas.logging.LogCtl ;
Expand All @@ -30,7 +31,6 @@
import org.apache.jena.tdb.setup.DatasetBuilderStd ;
import org.apache.jena.tdb.store.DatasetGraphTDB ;
import org.apache.jena.tdb.sys.TDBInternal ;
import arq.cmdline.CmdARQ ;

public abstract class CmdTDB extends CmdARQ
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,21 @@
* limitations under the License.
*/

package arq;
package jena.cmd;

import org.apache.jena.atlas.logging.LogCtl ;
import org.junit.runner.RunWith ;
import org.junit.runners.Suite ;
import org.junit.runners.Suite.SuiteClasses ;

@RunWith(Suite.class)
@SuiteClasses( {
TestCmdLine.class
, Test_schemagen.class
, Test_rdfcat.class
})

public class TS_Cmd
{}
{
static { LogCtl.setLog4j(); }
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
* limitations under the License.
*/

package arq;
package jena.cmd;
import java.util.Iterator ;

import jena.cmd.ArgDecl;
import jena.cmd.CmdLineArgs;

import org.apache.jena.atlas.junit.BaseTest ;
import org.junit.Test ;
import static org.junit.Assert.* ;

public class TestCmdLine extends BaseTest
public class TestCmdLine
{
@Test public void test_Simple1()
{
Expand Down
Loading

0 comments on commit 498b226

Please sign in to comment.