Skip to content

Commit

Permalink
Merge pull request #112 from dbirtwellharvard/handle_fits_output
Browse files Browse the repository at this point in the history
Revised to handle various FITS Output for XmlContentCoverter toEbucore() method.
  • Loading branch information
dbirtwellharvard authored Jul 18, 2016
2 parents 41aac56 + 85e23e6 commit e6df589
Show file tree
Hide file tree
Showing 2 changed files with 811 additions and 3 deletions.
44 changes: 41 additions & 3 deletions src/edu/harvard/hul/ois/fits/XmlContentConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.jdom.Attribute;
import org.jdom.Element;
import org.jdom.Namespace;
import org.jdom.Text;

import edu.harvard.hul.ois.fits.identity.FitsIdentity;
import edu.harvard.hul.ois.ots.schemas.DocumentMD.Font;
Expand Down Expand Up @@ -851,6 +852,26 @@ public XmlContent toAES (FitsOutput fitsOutput,Element fitsAudio) {
* @param fitsVideo a video element in the FITS schema
*/
public XmlContent toEbuCoreVideo (FitsOutput fitsOutput,Element fitsVideo) {

//
// NOTE:
// The FitsOutput INPUT can be one of 3 types:
// 1) "FITS"
// 2) "Combined" (both FITS and Standard)
// 3) "Standard" (Ebucore)
// ... and either contain spaces in the XML, or not
//
// The XmlContent object returned output will be as follows for each
// input type:
// 1) FITS or Combined = Standard Ebucore
// 2) Standard (Ebucore) = null XmlContent Object, as the fitsOutput
// does not contain elements or data which can be parsed into Ebucore.
// In other words, there is no data present which can be used to
// transform the data to Ebucore because it is ALREADY Ebucore.
//
// TODO: - Maybe return an Ebucore-based FitsOutput based upon the
// Ebucore data contained in the Standard Element for FitsOutput input
// objects of type "Standard".

EbuCoreModel ebucoreModel = null;

Expand All @@ -859,14 +880,29 @@ public XmlContent toEbuCoreVideo (FitsOutput fitsOutput,Element fitsVideo) {

try {
ebucoreModel = new EbuCoreModel();
List<Element> videoElemList = fitsVideo.getContent();
List<Object> videoElemList = fitsVideo.getContent();

String mimeType = null;

// Walk through all of the elements and process them
for(Element elem : videoElemList) {
// skipping any Text Objects
for(Object obj : videoElemList) {

// Skip the text object.
// This is most likely due to spaces preceding the real element
if(obj instanceof Text) {
continue;
}

Element elem = (Element)obj;
String fitsName = elem.getName ();


// If we have a standard element, then we are done.
// We only wish to process the basic FITS output
if(fitsName.equals ("standard")) {
break;
}

// Ebucore can only be generated from MediaInfo output
if(!isMediaInfoTool(fitsName, elem))
return null;
Expand Down Expand Up @@ -936,6 +972,8 @@ boolean isMediaInfoTool(String fitsName, Element elem) {
// Ebucore can only be generated from MediaInfo output
Attribute toolNameAttr = elem.getAttribute("toolname");
String toolName = toolNameAttr.getValue();
if(toolName == null) // just in case
return false;
if(!toolName.equalsIgnoreCase("mediainfo"))
return false;

Expand Down
Loading

0 comments on commit e6df589

Please sign in to comment.