Skip to content
Snippets Groups Projects
Commit aa994e43 authored by Thorsten Vitt's avatar Thorsten Vitt
Browse files

removed obsolete filename code from Aggregation[Entry]

parent aa7d2a73
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,6 @@
import info.textgrid.namespaces.metadata.core._2010.ObjectType;
import java.io.File;
import java.net.URI;
import java.text.MessageFormat;
......@@ -12,15 +11,11 @@
* Represents an entry in an aggregation.
*/
public class AggregationEntry implements IAggregationEntry {
private static URI baseURI = new File(".").toURI().normalize();
private final ObjectType metadata;
protected final Optional<Aggregation> parent;
private String baseName;
protected AggregationEntry(final ObjectType metadata) {
this(metadata, null);
}
......@@ -50,66 +45,9 @@ public ObjectType getMetadata() {
return metadata;
}
/**
* Returns a filename for this component only.
*
* @param withExtension
* whether to append a content type specific extension.
*/
protected String getSimpleFileName(final boolean withExtension) {
if (baseName == null) {
baseName = FilenamePolicy.getTransliterator().transliterate(
getMetadata().getGeneric().getProvided().getTitle().get(0))
.concat(".")
.concat(URI.create(
getMetadata().getGeneric().getGenerated().getTextgridUri()
.getValue()).getSchemeSpecificPart());
}
if (withExtension)
return FileExtensionMap.getInstance().addExtension(baseName,
getFormat());
else
return baseName;
}
public String getFormat() {
return getMetadata().getGeneric().getProvided().getFormat();
}
public Optional<URI> getBase() {
if (getParent().isPresent())
return Optional.of(URI.create(getParent().get().getFileName(false).concat("/")));
else
return Optional.absent();
}
/**
* Returns a {@link File} representing the abstract file name for this
* aggregation entry from the root of the aggregation tree.
*
* @param withExtension
* if true, append a content type specific extension to the last
* component of the path.
*/
protected File getFile(final boolean withExtension) {
final Optional<Aggregation> parent = getParent();
if (parent.isPresent())
return new File(parent.get().getFile(false),
getSimpleFileName(withExtension));
else
return new File(getSimpleFileName(withExtension));
}
/**
* Returns a {@link File} representing the abstract file name for this
* aggregation entry from the root of the aggregation tree. Equivalent to
* {@code {@linkplain #getFile(boolean) getFileName(true)}}.
* @param withExtension TODO
*/
@Deprecated
public String getFileName(final boolean withExtension) {
return baseURI.relativize(getFile(withExtension).toURI()).toString();
}
@Override
public String toString() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment