Exemplo n.º 1
0
 /**
  * 从一个string类型的list中移出没有实际内容(包括只含空格内容)的元素 返回一个新的list
  *
  * @param list
  * @return
  */
 public static List<String> filterBlankElements(List<String> list) {
   List<String> result = new ArrayList<String>();
   if (list == null || list.isEmpty()) {
     return result;
   }
   for (String element : list) {
     if (StringUtil.isEmpty(element) || StringUtil.isEmpty(element.trim())) {
       continue;
     }
     result.add(element);
   }
   return result;
 }
Exemplo n.º 2
0
  /**
   * Retruns the xml string equivalent of this object
   *
   * @param document instance of Xml Document.
   * @return org.w3c.dom.Node
   * @exception FioranoException thrown in case of error.
   */
  protected Node toJXMLString(Document document) throws FioranoException {
    Node root0 = document.createElement("InPort");

    ((Element) root0).setAttribute("isSyncRequestType", "" + isSyncRequestType());

    Node child = null;

    child = XMLDmiUtil.getNodeObject("Name", m_strPortName, document);
    if (child != null) {
      root0.appendChild(child);
    }

    child = XMLDmiUtil.getNodeObject("Description", m_strDscription, document);
    if (child != null) {
      root0.appendChild(child);
    }

    if (m_strXSD != null) {
      Element elem = document.createElement("XSD");
      CDATASection cdata = document.createCDATASection(m_strXSD);

      elem.appendChild(cdata);
      root0.appendChild(elem);
    }

    child = XMLDmiUtil.getNodeObject("JavaClass", m_strJavaClass, document);
    if (child != null) {
      root0.appendChild(child);
    }

    if (m_params != null && m_params.size() > 0) {
      Enumeration _enum = m_params.elements();

      while (_enum.hasMoreElements()) {
        Param param = (Param) _enum.nextElement();
        if (!StringUtil.isEmpty(param.getParamName())
            && !StringUtil.isEmpty(param.getParamValue())) {
          Node paramNode = param.toJXMLString(document);

          root0.appendChild(paramNode);
        }
      }
    }

    return root0;
  }
 public boolean isVerified() {
   boolean enable = !StringUtil.isEmpty(getProjectName());
   try {
     enable = (new Float(getProjectVersion()) > 0);
   } catch (NumberFormatException e) {
     enable = false;
   } // end of try-catch
   return enable;
 }
Exemplo n.º 4
0
 /**
  * Constructs a String of the fixed length given. If the string passed in is greater than length,
  * then the string is truncated to length. If the string is greater than length then the string is
  * padded with spaces. If s is empty or null, then an empty string of spaces is returned.
  *
  * @param s - string to operate on
  * @param length - desired length
  * @return - fixed length String
  */
 public static String createFixedLengthString(String s, int length) {
   String result = null;
   if (StringUtil.isEmpty(s)) {
     StringBuffer sb = new StringBuffer(length);
     for (int i = 0; i < length; i++) {
       sb.append(" ");
     }
     result = sb.toString();
   } else {
     if (s.length() == length) {
       result = s;
     } else if (s.length() > length) {
       result = s.substring(0, length);
     } else { // s.length() is < length
       StringBuffer sb = new StringBuffer(length);
       sb.append(s);
       for (int i = s.length(); i < length; i++) {
         sb.append(" ");
       }
       result = sb.toString();
     }
   }
   return result;
 }
Exemplo n.º 5
0
  public void persist() {
    DataElementConcept dec = DomainObjectFactory.newDataElementConcept();
    List<DataElementConcept> decs = elements.getElements(dec);
    logger.debug("***** Inside DEC Persist ");
    int count = 0;
    sendProgressEvent(count++, decs.size(), "DECs");

    logger.debug("decs... ");
    if (decs != null) {
      for (ListIterator<DataElementConcept> it = decs.listIterator(); it.hasNext(); ) {
        DataElementConcept newDec = DomainObjectFactory.newDataElementConcept();
        dec = it.next();

        sendProgressEvent(count++, decs.size(), "DEC : " + dec.getLongName());

        List<AlternateName> passedAltNames = new ArrayList<AlternateName>();
        for (AlternateName _an : dec.getAlternateNames()) passedAltNames.add(_an);

        List<Definition> modelDefinitions = new ArrayList<Definition>();
        for (Definition _def : dec.getDefinitions()) modelDefinitions.add(_def);

        List<AdminComponentClassSchemeClassSchemeItem> passedACCSCSI = dec.getAcCsCsis();

        dec.removeDefinitions();
        dec.removeAlternateNames();

        if (!StringUtil.isEmpty(dec.getPublicId()) && dec.getVersion() != null) {
          newDec = existingMapping(dec);
          dec.setId(newDec.getId());
          for (AlternateName _an : passedAltNames) {
            persisterUtil.addAlternateName(dec, _an);
          }
          it.set(newDec);
          persisterUtil.addPackageClassification(dec);
          logger.info(PropertyAccessor.getProperty("mapped.to.existing.dec"));
          continue;
        }

        // update object class with persisted one
        if (dec.getObjectClass().getPublicId() == null)
          dec.setObjectClass(LookupUtil.lookupObjectClass(dec.getObjectClass().getPreferredName()));
        else
          dec.setObjectClass(
              LookupUtil.lookupObjectClass(
                  dec.getObjectClass().getPublicId(), dec.getObjectClass().getVersion()));

        newDec.setObjectClass(dec.getObjectClass());

        // update property with persisted one
        if (dec.getProperty().getPublicId() == null)
          dec.setProperty(LookupUtil.lookupProperty(dec.getProperty().getPreferredName()));
        else
          dec.setProperty(
              LookupUtil.lookupProperty(
                  dec.getProperty().getPublicId(), dec.getProperty().getVersion()));

        newDec.setProperty(dec.getProperty());

        logger.debug("dec name: " + dec.getLongName());
        //        logger.debug("alt Name: " + ne);

        List<String> eager = new ArrayList<String>();
        eager.add("definitions");

        // does this dec exist?
        List l = dataElementConceptDAO.find(newDec, eager);
        logger.debug("***** decs size : " + l.size());
        if (l.size() == 0) {
          logger.debug("***** one or more decs ");
          if (dec.getConceptualDomain() == null)
            dec.setConceptualDomain(defaults.getConceptualDomain());
          dec.setContext(defaults.getContext());
          dec.setLongName(
              dec.getObjectClass().getLongName() + " " + dec.getProperty().getLongName());
          dec.setPreferredDefinition(
              dec.getObjectClass().getPreferredDefinition()
                  + DEC_PREFERRED_DEF_CONCAT_CHAR
                  + dec.getProperty().getPreferredDefinition());

          dec.setPreferredName(
              ConventionUtil.publicIdVersion(dec.getObjectClass())
                  + DEC_PREFERRED_NAME_CONCAT_CHAR
                  + ConventionUtil.publicIdVersion(dec.getProperty()));

          dec.setVersion(new Float(1.0f));
          dec.setWorkflowStatus(defaults.getWorkflowStatus());

          dec.setProperty(LookupUtil.lookupProperty(dec.getProperty().getPreferredName()));

          dec.setAudit(defaults.getAudit());
          dec.setLifecycle(defaults.getLifecycle());

          StringBuilder builder = new StringBuilder();
          for (char currentChar : dec.getPreferredDefinition().toCharArray()) {
            Character replacementChar = charReplacementMap.get(currentChar);
            builder.append(replacementChar != null ? replacementChar : currentChar);
          }
          dec.setPreferredDefinition(builder.toString());
          logger.debug(
              "***** preferred name " + dec.getPreferredName() + " public ID " + dec.getPublicId());
          newDec = dataElementConceptDAO.create(dec);
          logger.info(PropertyAccessor.getProperty("created.dec"));

        } else {
          newDec = (DataElementConcept) l.get(0);
          logger.info(PropertyAccessor.getProperty("existed.dec"));

          /* if DEC alreay exists, check context
           * If context is different, add Used_by alt_name
           */
          dec.setId(newDec.getId());

          if (!newDec.getContext().getId().equals(defaults.getContext().getId())) {
            AlternateName _an = DomainObjectFactory.newAlternateName();
            _an.setName(defaults.getContext().getName());
            _an.setType(AlternateName.TYPE_USED_BY);
            persisterUtil.addAlternateName(dec, _an);
          }
        }

        dec.setId(newDec.getId());
        for (AlternateName _an : passedAltNames) {
          persisterUtil.addAlternateName(dec, _an);
        }

        for (Definition def : modelDefinitions) {
          persisterUtil.addAlternateDefinition(dec, def);
        }

        LogUtil.logAc(newDec, logger);
        logger.info("-- Public ID: " + newDec.getPublicId());
        logger.info(
            PropertyAccessor.getProperty("oc.longName", newDec.getObjectClass().getLongName()));
        logger.info(
            PropertyAccessor.getProperty("prop.longName", newDec.getProperty().getLongName()));

        dec.setAcCsCsis(passedACCSCSI);
        persisterUtil.addPackageClassification(dec);
        it.set(newDec);

        // dec still referenced in DE. Need ID to retrieve it in DEPersister.
        dec.setId(newDec.getId());
      }
    }
    logger.debug("***** End DEC persist");
  }