Skip to content

Commit

Permalink
Update templates. Added correct counting
Browse files Browse the repository at this point in the history
  • Loading branch information
Miel Vander Sande committed Dec 28, 2015
2 parents ecb54eb + 5d72031 commit 5c8969e
Show file tree
Hide file tree
Showing 37 changed files with 785 additions and 434 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.linkeddatafragments.datasource;

import org.linkeddatafragments.fragments.LinkedDataFragment;
import org.linkeddatafragments.fragments.ILinkedDataFragment;
import org.linkeddatafragments.fragments.LinkedDataFragmentRequest;

/**
Expand All @@ -15,7 +15,7 @@ abstract public class AbstractRequestProcessor
public void close() {}

@Override
final public LinkedDataFragment createRequestedFragment(
final public ILinkedDataFragment createRequestedFragment(
final LinkedDataFragmentRequest request )
throws IllegalArgumentException
{
Expand All @@ -36,7 +36,7 @@ public Worker( final LinkedDataFragmentRequest request )
this.request = request;
}

abstract public LinkedDataFragment createRequestedFragment()
abstract public ILinkedDataFragment createRequestedFragment()
throws IllegalArgumentException;

} // end of class Worker
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,58 @@
package org.linkeddatafragments.datasource;

import org.linkeddatafragments.fragments.LinkedDataFragment;
import com.hp.hpl.jena.rdf.model.Model;

import org.linkeddatafragments.fragments.ILinkedDataFragment;
import org.linkeddatafragments.fragments.LinkedDataFragmentRequest;
import org.linkeddatafragments.fragments.tpf.TriplePatternFragment;
import org.linkeddatafragments.fragments.tpf.ITriplePatternElement;
import org.linkeddatafragments.fragments.tpf.ITriplePatternFragment;
import org.linkeddatafragments.fragments.tpf.TriplePatternFragmentImpl;
import org.linkeddatafragments.fragments.tpf.TriplePatternFragmentRequest;

import com.hp.hpl.jena.rdf.model.Model;
import org.linkeddatafragments.fragments.tpf.ITriplePatternFragmentRequest;

/**
* Base class for implementations of {@link IFragmentRequestProcessor} that
* process {@link TriplePatternFragmentRequest}s.
* process {@link ITriplePatternFragmentRequest}s.
*
* @param <TermType> type for representing RDF terms in triple patterns
* @param <VarType> type for representing specific variables in triple patterns
*
* @author <a href="http://olafhartig.de">Olaf Hartig</a>
*/
public abstract class AbstractRequestProcessorForTriplePatterns
extends AbstractRequestProcessor
public abstract class
AbstractRequestProcessorForTriplePatterns<TermType,VarType>
extends AbstractRequestProcessor
{
@Override
protected Worker getWorker( final LinkedDataFragmentRequest request )
protected final Worker<TermType,VarType> getWorker(
final LinkedDataFragmentRequest request )
throws IllegalArgumentException
{
if ( request instanceof TriplePatternFragmentRequest )
return getWorker( (TriplePatternFragmentRequest) request );
if ( request instanceof ITriplePatternFragmentRequest<?,?> ) {
@SuppressWarnings("unchecked")
final ITriplePatternFragmentRequest<TermType,VarType> tpfRequest =
(ITriplePatternFragmentRequest<TermType,VarType>) request;
return getTPFSpecificWorker( tpfRequest );
}
else
throw new IllegalArgumentException( request.getClass().getName() );
}

abstract protected Worker getWorker(
final TriplePatternFragmentRequest request )
abstract protected Worker<TermType,VarType> getTPFSpecificWorker(
final ITriplePatternFragmentRequest<TermType,VarType> request )
throws IllegalArgumentException;


abstract static protected class Worker
abstract static protected class Worker<TermType,VarType>
extends AbstractRequestProcessor.Worker
{
public Worker( final TriplePatternFragmentRequest request )
public Worker(
final ITriplePatternFragmentRequest<TermType,VarType> request )
{
super( request );
}

@Override
public LinkedDataFragment createRequestedFragment()
public ILinkedDataFragment createRequestedFragment()
throws IllegalArgumentException
{
final long limit = LinkedDataFragmentRequest.TRIPLESPERPAGE;
Expand All @@ -51,44 +62,40 @@ public LinkedDataFragment createRequestedFragment()
else
offset = 0L;

final TriplePatternFragmentRequest tpfRequest =
(TriplePatternFragmentRequest) request;
@SuppressWarnings("unchecked")
final ITriplePatternFragmentRequest<TermType,VarType> tpfRequest =
(ITriplePatternFragmentRequest<TermType,VarType>) request;

return createFragment( tpfRequest.getSubject(),
tpfRequest.getPredicate(),
tpfRequest.getObject(),
offset, limit );
}

abstract protected LinkedDataFragment createFragment( final String subj,
final String pred,
final String obj,
final long offset,
final long limit )
abstract protected ILinkedDataFragment createFragment(
final ITriplePatternElement<TermType,VarType> subj,
final ITriplePatternElement<TermType,VarType> pred,
final ITriplePatternElement<TermType,VarType> obj,
final long offset,
final long limit )
throws IllegalArgumentException;

protected TriplePatternFragment createEmptyTriplePatternFragment()
protected ITriplePatternFragment createEmptyTriplePatternFragment()
{
return new TriplePatternFragmentImpl( request.getFragmentURL(),
request.getDatasetURL() );
}

protected TriplePatternFragment createTriplePatternFragment(
protected ITriplePatternFragment createTriplePatternFragment(
final Model triples,
final long totalSize,
final boolean isLastPage )
{
final long pageNumber;
if ( request.isPageRequest() )
pageNumber = request.getPageNumber();
else
pageNumber = 1L;

return new TriplePatternFragmentImpl( triples,
totalSize,
request.getFragmentURL(),
request.getDatasetURL(),
pageNumber,
request.getPageNumber(),
isLastPage );
}

Expand Down
47 changes: 0 additions & 47 deletions src/org/linkeddatafragments/datasource/DataSource.java

This file was deleted.

29 changes: 29 additions & 0 deletions src/org/linkeddatafragments/datasource/DataSourceBase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.linkeddatafragments.datasource;

/**
*
* @author mielvandersande
* @author Bart Hanssens
*/
public abstract class DataSourceBase implements IDataSource {
protected String title;
protected String description;

public DataSourceBase(String title, String description) {
this.title = title;
this.description = description;
}

@Override
public String getDescription() {
return this.description;
};

@Override
public String getTitle() {
return this.title;
};

@Override
public void close() {}
}
Loading

0 comments on commit 5c8969e

Please sign in to comment.