Package edu.harvard.hul.ois.fits.identity

Examples of edu.harvard.hul.ois.fits.identity.FitsIdentity


          aesModel = new AESModel ();
         
          String filename = fitsOutput.getMetadataElement("filename").getValue();
         
         
          FitsIdentity fitsIdent = fitsOutput.getIdentities().get(0);
          String version = null;
          if(fitsIdent.getFormatVersions().size() > 0) {
            version = fitsIdent.getFormatVersions().get(0).getValue();
          }
          aesModel.setFormat(fitsIdent.getFormat(),version);
         
          aesModel.aes.getPrimaryIdentifier().setText(new File(filename).getName());
         
          int sampleRate = 0;
          int channelCnt = 0;
View Full Code Here


      XPath xpath = XPath.newInstance("//fits:identity");
      Namespace ns = Namespace.getNamespace("fits",Fits.XML_NAMESPACE);
      xpath.addNamespace(ns);
      List<Element> identElements = xpath.selectNodes(fitsXml);
      for(Element element : identElements) {
        FitsIdentity fileIdentSect = new FitsIdentity();
       
        //get the identity attributes
        Attribute formatAttr = element.getAttribute("format");
        Attribute mimetypeAttr = element.getAttribute("mimetype");
        if(formatAttr != null) {
          fileIdentSect.setFormat(formatAttr.getValue());
        }
        if(mimetypeAttr != null) {
          fileIdentSect.setMimetype(mimetypeAttr.getValue());
        }
       
        //get the tool elements
        List<Element> toolElements = element.getChildren("tool",ns);
        for(Element toolElement : toolElements) {
          ToolInfo toolInfo = new ToolInfo();
          Attribute toolNameAttr = toolElement.getAttribute("toolname");
          Attribute toolVersionAttr = toolElement.getAttribute("toolversion");
          if(toolNameAttr != null) {
            toolInfo.setName(toolNameAttr.getValue());
          }
          if(toolVersionAttr != null) {
            toolInfo.setVersion(toolVersionAttr.getValue());
          }
          fileIdentSect.addReportingTool(toolInfo);
        }
       
        //get the version elements
        List<Element> versionElements = element.getChildren("version",ns);
        for(Element versionElement : versionElements) {
          ToolInfo toolInfo = new ToolInfo();
          Attribute toolNameAttr = versionElement.getAttribute("toolname");
          Attribute toolVersionAttr = versionElement.getAttribute("toolversion");
          if(toolNameAttr != null) {
            toolInfo.setName(toolNameAttr.getValue());
          }
          if(toolVersionAttr != null) {
            toolInfo.setVersion(toolVersionAttr.getValue());
          }
          String value = versionElement.getText();
          FormatVersion formatVersion = new FormatVersion(value,toolInfo);
          fileIdentSect.addFormatVersion(formatVersion);
        }
       
        //get the externalIdentifier elements
        List<Element> xIDElements = element.getChildren("externalIdentifier",ns);
        for(Element xIDElement : xIDElements) {
          String type = xIDElement.getAttributeValue("type");
          String value = xIDElement.getText();
          ToolInfo toolInfo = new ToolInfo();
          Attribute toolNameAttr = xIDElement.getAttribute("toolname");
          Attribute toolVersionAttr = xIDElement.getAttribute("toolversion");
          if(toolNameAttr != null) {
            toolInfo.setName(toolNameAttr.getValue());
          }
          if(toolVersionAttr != null) {
            toolInfo.setVersion(toolVersionAttr.getValue());
          }
          ExternalIdentifier xid = new ExternalIdentifier(type,value,toolInfo);
          fileIdentSect.addExternalID(xid);
        }
        identities.add(fileIdentSect);
      }
    } catch (JDOMException e) {
      e.printStackTrace();
View Full Code Here

        continue;
      }
      List<ToolIdentity> toolIdentities = result.getFileIdentity();
      if(result.getTool().canIdentify() && toolIdentities != null && toolIdentities.size() > 0) {
        for(ToolIdentity fileIdent : toolIdentities) { 
          identities.add(new FitsIdentity(fileIdent));
        }     
        break;
      }
    }
    return identities;
View Full Code Here

      }
      List<ToolIdentity> toolIdentities = result.getFileIdentity();
      if(result.getTool().canIdentify() && toolIdentities != null && toolIdentities.size() > 0) {     
        if(isPartialIdentity(toolIdentities)) {
          for(ToolIdentity fileIdent : toolIdentities) { 
            identities.add(new FitsIdentity(fileIdent));
          }
          break;
        }
       
      }
View Full Code Here

      ListIterator iter = consolidatedIdentities.listIterator();
      boolean anyMatches = false;
      boolean formatTreeMatch = false;
      while ( iter.hasNext() ) {
        //compare ident with conIdent
        FitsIdentity identitySection = (FitsIdentity)iter.next();
        if(identitiesMatch(ident,identitySection)) {
          //Add external identifiers from ident to the existing item
          mergeExternalIdentifiers(ident,identitySection);       
          //add format versions from ident to the existing item
          mergeFormatVersions(ident,identitySection);
          //add reporting tools from ident to the existing item
          identitySection.addReportingTool(ident.getToolInfo());
          //we found a match
          anyMatches = true;
          break;
        }
        //if identities don't match check format tree for specific/generic formats
        else {     
          int matchCondition = checkFormatTree(ident,identitySection);
          if(matchCondition == -1) {
            //ident is more specific.  Most specific identity should always
            // be first element in list
            FitsIdentity newSection = new FitsIdentity(ident);
            //add new section
            //backup on one position
            iter.previous();
            //add the new item
            iter.add(newSection);
            //skip head to next item
            iter.next();
            //delete
            iter.remove();
            //indicate we found a match
            anyMatches = true;
            break;
          }
          // existing format is more specific
          else if(matchCondition == 1) {
            formatTreeMatch = true;
            //do nothing, keep going and add to consolidated identities if no other matches
          }
          //formats are not specific or generic version of one another
          else {
            //leave anyMatches as false so ident is added to consolidated identities
          }
        }
      }
      //if there were no matches to existing consolidated identities add it
      if(!anyMatches && !formatTreeMatch) {
        iter.add(new FitsIdentity(ident));
      }
    }
    return consolidatedIdentities;
  }
View Full Code Here

TOP

Related Classes of edu.harvard.hul.ois.fits.identity.FitsIdentity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.