Ejemplo n.º 1
0
 private String cleanAndTrim(String valueToClean, Class clazz, String propertyName) {
   String returnString = StringHelper.cleanUpWhiteSpace(valueToClean);
   ATFieldInfo fieldInfo = ATFieldInfo.getFieldInfo(clazz, propertyName);
   if (fieldInfo.getStringLengthLimit() != null && fieldInfo.getStringLengthLimit() > 0) {
     return StringHelper.trimToLength(returnString, fieldInfo.getStringLengthLimit());
   } else {
     return returnString;
   }
 }
Ejemplo n.º 2
0
  private void parseAccessionNumber(Accessions accession, IdentifierType value) {
    String composite = value.getComposite();

    if (composite != null) {
      StringTokenizer st = new StringTokenizer(composite, "./-");
      int count = 0;
      String thisToken;
      while (st.hasMoreTokens()) {
        count++;
        thisToken = StringHelper.cleanUpWhiteSpace((String) st.nextElement());
        if (count == 1) {
          accession.setAccessionNumber1(
              StringHelper.trimToLength(
                  thisToken,
                  ATFieldInfo.checkFieldLength(
                      Accessions.class, Accessions.PROPERTYNAME_ACCESSION_NUMBER_1)));
        } else if (count == 2) {
          accession.setAccessionNumber2(
              StringHelper.trimToLength(
                  thisToken,
                  ATFieldInfo.checkFieldLength(
                      Accessions.class, Accessions.PROPERTYNAME_ACCESSION_NUMBER_2)));
        } else if (count == 3) {
          accession.setAccessionNumber3(
              StringHelper.trimToLength(
                  thisToken,
                  ATFieldInfo.checkFieldLength(
                      Accessions.class, Accessions.PROPERTYNAME_ACCESSION_NUMBER_3)));
        } else if (count == 4) {
          accession.setAccessionNumber4(
              StringHelper.trimToLength(
                  thisToken,
                  ATFieldInfo.checkFieldLength(
                      Accessions.class, Accessions.PROPERTYNAME_ACCESSION_NUMBER_4)));
        }
      }
    } else {
      accession.setAccessionNumber1(
          cleanAndTrim(
              value.getPart1(), Accessions.class, Accessions.PROPERTYNAME_ACCESSION_NUMBER_1));
      if (value.getPart2() != null) {
        accession.setAccessionNumber2(
            cleanAndTrim(
                value.getPart2(), Accessions.class, Accessions.PROPERTYNAME_ACCESSION_NUMBER_2));
      }
      if (value.getPart3() != null) {
        accession.setAccessionNumber3(
            cleanAndTrim(
                value.getPart3(), Accessions.class, Accessions.PROPERTYNAME_ACCESSION_NUMBER_3));
      }
      if (value.getPart4() != null) {
        accession.setAccessionNumber4(
            cleanAndTrim(
                value.getPart4(), Accessions.class, Accessions.PROPERTYNAME_ACCESSION_NUMBER_4));
      }
    }
  }
Ejemplo n.º 3
0
 public static String getLabel(Did did) {
   String returnString = "Unknown component";
   for (Object o : did.getMDid()) {
     if (o instanceof Unittitle) {
       return StringHelper.cleanUpWhiteSpace(EADHelper.ObjectNodetoString(o));
     }
   }
   return returnString;
 }
Ejemplo n.º 4
0
 // This function parses the container element and call the fucntion to populate the instance
 // object
 private String parseContainers(
     ArchDescriptionAnalogInstances instance, int status, Container container) {
   if (StringHelper.isEmpty(container.getType())) {
     String value = (String) EADHelper.getClassFromList(container.getContent(), String.class);
     if (value == null) return null;
     else {
       value.trim();
       String c[] = value.split(" ");
       if (c.length == 2) {
         if ((c[0].equalsIgnoreCase("box"))
             || (c[0].equalsIgnoreCase("boxes"))
             || (c[0].equalsIgnoreCase("folder"))) {
           setInstance(c[0], c[1], instance, status);
         }
       }
     }
   } else {
     String value = (String) EADHelper.getClassFromList(container.getContent(), String.class);
     setInstance(container.getType(), value, instance, status);
   }
   return container.getId();
 }
Ejemplo n.º 5
0
  private void addResource(
      Accessions accession,
      IdentifierType resourceId,
      DomainImportController controller,
      String accesionNumber,
      int recordNumber)
      throws ImportException {

    if (resourceId != null) {

      String resourceId1;
      String resourceId2 = null;
      String resourceId3 = null;
      String resourceId4 = null;
      if (resourceId.getComposite() != null) {
        resourceId1 =
            StringHelper.trimToLength(
                resourceId.getComposite(),
                ATFieldInfo.checkFieldLength(
                    Resources.class, Resources.PROPERTYNAME_RESOURCE_IDENTIFIER_1));
      } else {
        resourceId1 = resourceId.getPart1();
        resourceId2 = resourceId.getPart2();
        resourceId3 = resourceId.getPart3();
        resourceId4 = resourceId.getPart4();
      }

      ResourcesDAO resourceDao = new ResourcesDAO();
      Resources resource;
      if (resourceCreation.equalsIgnoreCase(AccessionImportXmlHandler.RESOURCE_CREATION_NONE)) {
        resource =
            resourceDao.lookupResource(
                resourceId1, resourceId2, resourceId3, resourceId4, false, repository);
      } else {
        resource =
            resourceDao.lookupResource(
                resourceId1, resourceId2, resourceId3, resourceId4, true, repository);
      }
      if (resourceDao.getNewRecordCreated()
          && resourceCreation.equalsIgnoreCase(AccessionImportXmlHandler.RESOURCE_CREATION_FULL)) {
        try {
          resource = (Resources) resourceDao.findByPrimaryKeyLongSession(resource.getIdentifier());
          resource.populateResourceFromAccession(accession);
          resourceDao.updateLongSession(resource);

        } catch (LookupException e) {
          throw new ImportException(
              "Error creating resource: " + resourceId + ", " + e.getMessage(), e);
        } catch (PersistenceException e) {
          throw new ImportException(
              "Error creating resource: " + resourceId + ", " + e.getMessage(), e);
        } catch (DuplicateLinkException e) {
          throw new ImportException(
              "Error creating resource: duplicate link" + resourceId + ", " + e.getMessage(), e);
        }
      }
      if (resource != null) {
        AccessionsResources accessionResource = new AccessionsResources(resource, accession);
        accession.addAccessionsResources(accessionResource);
      }
    } else {
      if (!resourceCreation.equalsIgnoreCase(AccessionImportXmlHandler.RESOURCE_CREATION_NONE)) {
        controller.addLineToImportLog(
            "Record # "
                + recordNumber
                + " - "
                + accesionNumber
                + " has no resource id so no resource record was created");
      }
    }
  }