Package edu.uga.galileo.voci.bo

Examples of edu.uga.galileo.voci.bo.VociBusinessObject


    }

    if ((command.getOther() == null)
        || ((command.getOther() != null) && (!command.getOther().get(0)
            .equals("basic")))) {
      VociBusinessObject searchVBO = contentManager.getVBO(command, -1,
          false, false);
      ArrayList<GUIElement> guiElements = searchVBO
          .createGUIElementsForMetadataRegistryElements();
      ArrayList<GUIElement> finalGUIElements = new ArrayList<GUIElement>();

      GUIElement element;
      for (int m = 0; m < guiElements.size(); m++) {
View Full Code Here


   *
   */
  private VociBusinessObject getVBO( ContentType type, int projectId,
      boolean active )
  {
    VociBusinessObject vbo = null;

    if (type == ContentType.COMMUNITY)
    {
      Community community = new Community();
      community.setCommunityId(-1);
View Full Code Here

    // 2. dc_subject = '' (all repo that match)
    /*
     * Get text from the XML based on content type, create an empty VBO
     * based on content type
     */
    VociBusinessObject vbo = null;
    List<Element> lineItems = (List<Element>) singleRecord.getChildren();
    HashMap<String, String> ultimateFieldNamesValues = new HashMap<String, String>();
    HashMap<String, Boolean> publicToActiveValue = new HashMap<String, Boolean>();
    publicToActiveValue.put("yes", true);
    publicToActiveValue.put("no", false);
    boolean isActive = false;

    /*
     * Add Ultimate field name/value pairs into HashMap. If key already
     * exist, concatenate its values.
     */
    for( Element elem : lineItems )
    {
      if (elem.getName().equalsIgnoreCase("public"))
      {
        // set active flag
        isActive = publicToActiveValue.get(elem.getValue().toLowerCase());
      }
     
      // if subject value contains comma, map to subject.personal
      // otherwise map to subject.others
      if ( elem.getName().equalsIgnoreCase("dc_subject") )
      {
        if ( elem.getValue().contains(",") )
        {
          if ( ultimateFieldNamesValues.containsKey("subject_comma"))
          {
            ultimateFieldNamesValues.put("subject_comma",
                ultimateFieldNamesValues.get("subject_comma")
                    + "^"
                    + StringUtils.doSpecialCharReplacements(elem
                        .getValue()));
          }
          else
          {
            ultimateFieldNamesValues.put("subject_comma", StringUtils
              .doSpecialCharReplacements(elem.getValue()))
          }
        }
        else
        {
          if ( ultimateFieldNamesValues.containsKey("subject_no_comma"))
          {
            ultimateFieldNamesValues.put("subject_no_comma",
                ultimateFieldNamesValues.get("subject_no_comma")
                    + "^"
                    + StringUtils.doSpecialCharReplacements(elem
                        .getValue()));
          }
          else
          {
            ultimateFieldNamesValues.put("subject_no_comma", StringUtils
              .doSpecialCharReplacements(elem.getValue()))
          }
        }       
      }
      if (ultimateFieldNamesValues.containsKey(elem.getName()))
      {
        ultimateFieldNamesValues.put(elem.getName(),
            ultimateFieldNamesValues.get(elem.getName())
                + "^"
                + StringUtils.doSpecialCharReplacements(elem
                    .getValue()));
      }
      else
      {
        ultimateFieldNamesValues.put(elem.getName(), StringUtils
            .doSpecialCharReplacements(elem.getValue()));
      }
    }
    Logger.debug("\n the map looks like....> \n"
        + ultimateFieldNamesValues.toString() + "\n");

    vbo = getVBO(type, projectId, isActive);
    if (vbo == null)
      Logger.debug("\n vbo is null \n");

    /*
     * Check Ultimate fields against voci's. Add the values and metadataId
     * to the vbo.
     */
    HashMap<ContentType, HashMap> vociTypeToUltimate = new HashMap<ContentType, HashMap>();
    vociTypeToUltimate.put(ContentType.COLLECTION, vociVsUltimateFieldsCollections);
    vociTypeToUltimate.put(ContentType.COMMUNITY, vociVsUltimateFieldsCommunity);
    vociTypeToUltimate.put(ContentType.ITEM, vociVsUltimateFieldsItems);
   
    HashMap<String, String> vociToUltimateKeyValues = vociTypeToUltimate.get(type);
    Logger.debug("\n the vociToUltimateKeyValues has the following maps"
        + vociToUltimateKeyValues.toString() + "\n");
    String keys[] = new String[ultimateFieldNamesValues.size()];
    keys = ultimateFieldNamesValues.keySet().toArray(keys);
    String vociName = null;
    String elementQual[];
    String element;
    String qualifier;
    int metadataId = -1;

    boolean isRepoCollOther = false;
    int contentId = -1;
    HashMap<String, String> repoCollOtherAndPublic = new HashMap<String, String>();
    repoCollOtherAndPublic.put("repo", "addToImportCommunityHolder");
    repoCollOtherAndPublic.put("repo_other", "addToImportCommunityHolder");
    repoCollOtherAndPublic.put("coll", "addToImportCollectionHolder");
    repoCollOtherAndPublic.put("coll_other", "addToImportCollectionHolder");
    String valueFromUltimate = "";
   
    for( int i = 0; i < keys.length; i++ )
    {     
      isRepoCollOther = ((keys[i].equalsIgnoreCase("repo"))
          || (keys[i].equalsIgnoreCase("coll"))
          || (keys[i].equalsIgnoreCase("repo_other")) || (keys[i]
          .equalsIgnoreCase("coll_other")));
      // check this (ultimate key) against voci's
      vociName = vociToUltimateKeyValues.get(keys[i]);

      if ((vociName == null) && (!isRepoCollOther))
      {
        Logger.debug("\n vociName = .. >" + vociName + "\n");
        Logger.debug("\n ultimate's name ..>" + keys[i] + "\n");
        continue;
      }
     
      if ((vociName != null) && (vociName.contains(".")))
      {
        elementQual = vociName.split("\\.");
        element = elementQual[0];
        qualifier = elementQual[1];
        Logger.debug("\n (voci.contains) element IS:.. " + element
            + " \n");
        Logger.debug("\n (voci.contains) qualifier IS:.. " + qualifier
            + " \n");
        valueFromUltimate = ultimateFieldNamesValues.get(keys[i]);
      }
      else
      {
        element = vociName;
        qualifier = null;
        valueFromUltimate = ultimateFieldNamesValues.get(keys[i]);
      }

      try
      {
        if (isRepoCollOther)
        {
          try
          {
            metadataId = MetadataManager
                .getMetadataId(
                    "id",
                    null,
                    projectId,
                    keys[i].startsWith("repo") ? ContentType.COMMUNITY
                        .getValue()
                        : ContentType.COLLECTION
                            .getValue());
          }
          catch( NoSuchMetadataException e )
          {
            throw new ImportException(
                "Couldn't retrieve 'id' metadata field for "
                    + (keys[i].startsWith("repo") ? ContentType.COMMUNITY
                        .toString().toLowerCase()
                        : ContentType.COLLECTION
                            .toString()
                            .toLowerCase())
                    + " content type.");
          }

          Logger
              .debug("\n I'M isRepoCollOther AND THE metadataID for the 'id' field of "
                  + type.toString().toLowerCase()
                  + " content type IS : "
                  + metadataId
                  + " \n");

          try
          {
            contentId = DAOFactory
                .getHelperDAO()
                .getElementIdByMetadataValue(
                    metadataId,
                    keys[i].startsWith("repo") ? ContentType.COMMUNITY
                        : ContentType.COLLECTION,
                    valueFromUltimate);
            if (contentId == -1)
            {
              vbo.addToImportErrorHolder(
                  "Couldn't locate parent repository with ID '"
                      + valueFromUltimate + "'", false);
            }
            else
            {
              Method testMethod = vbo.getClass().getMethod(
                  repoCollOtherAndPublic.get(keys[i]),
                  new Class[] { Integer.class });
              Object[] args = new Integer[] { contentId };
              testMethod.invoke(vbo, args);
            }
          }
          catch( NoSuchMetadataException e )
          {
            vbo.addToImportErrorHolder(keys[i] + " parent '"
                + valueFromUltimate + "' couldn't be located.",
                false);
          }
        }
        else
        {
          Logger
              .debug("\n I'M trying to add a regular metadataId... \n");
          Logger.debug("\n element IS:.. " + element + " \n");
          Logger.debug("\n qualifier IS:.. " + qualifier + " \n");

          try
          {
            metadataId = MetadataManager.getMetadataId(element,
                qualifier, projectId, type.getValue());
            Logger.debug("\n metadataId IS:.. " + metadataId
                + " \n");

            if (valueFromUltimate == null)
            {
              Logger.debug("\n valueFromUltimate = null \n");
              Logger.debug("\n for the following Ultimate key "
                  + keys[i] + " \n");
              vbo.addToMetadataRegistry(metadataId, "");
            }
            else
            {
              vbo.addToMetadataRegistry(metadataId,
                  valueFromUltimate);
            }
          }
          catch( NoSuchMetadataException e )
          {
            vbo.addToImportErrorHolder(
                "Couldn't get a metadata ID for element '"
                    + element + "' and qualifier '"
                    + qualifier + "'", true);
          }
        }
View Full Code Here

      Logger.debug("Got " + results.size() + " results from "
          + importer.getClass().getSimpleName());

      // TODO: parse through the results, and do the special char
      // replacements and validation
      VociBusinessObject vbo;
      ArrayList<MetadataElement> metadataElements;
      MetadataElement metadataElement;
      String metadataValue;
      CommunityManager communityManager = new CommunityManager();
      CollectionManager collectionManager = new CollectionManager();
      BundleManager bundleManager = new BundleManager();
      ItemManager itemManager = new ItemManager();
      for (int m = 0; m < results.size(); m++) {
        vbo = results.get(m);
        Logger.debug("trying to import '" + vbo.getMetadataBasedTitle()
            + "' of type " + ContentType.valueOf(vbo.getType()));
        metadataElements = MetadataManager.getMetadataList(
            (new ProjectManager()).getProjectID(project), vbo
                .getType());
        for (int n = 0; n < metadataElements.size(); n++) {
          metadataElement = metadataElements.get(n);
          metadataValue = vbo.getMetadataData(metadataElement
              .getElement(), metadataElement.getQualifier());
          if (metadataValue == null) {
            metadataValue = "";
          }
          vbo.addToMetadataRegistry(metadataElement.getMetadataId(),
              metadataValue);
          try {
            vbo.validateMetadata(metadataElement, metadataValue);
          } catch (ValidationException e) {
            vbo.addToImportErrorHolder("Validation error on "
                + metadataElement
                    .getFriendlyElementQualifierName()
                + ": " + e.getMessage(), true);
          }
        }

        // check to see if any fatal errors occurred with this
        // element
        boolean hadFatalErrors = false;
        HashMap<String, Boolean> errorMessages = vbo
            .getImportErrorMessages();
        String[] errorKeys = new String[errorMessages.size()];
        errorKeys = errorMessages.keySet().toArray(errorKeys);
        for (int n = 0; n < errorKeys.length; n++) {
          if (errorMessages.get(errorKeys[n])) {
            hadFatalErrors = true;
            break;
          }
        }

        if (!hadFatalErrors) {
          if (((vbo.getType() == ContentType.ITEM.getValue()) || (vbo
              .getType() == ContentType.BUNDLE.getValue()))
              && (vbo.getImportCollectionIDs().size() == 0)
              && vbo.getImportCommunityIDs().size() == 0) {
            vbo.addToImportErrorHolder(
                "Imported items and bundles "
                    + "must have a collection or "
                    + "community parent.", true);
          } else {
            importCounter++;
            try {
              if (vbo.getType() == ContentType.COMMUNITY
                  .getValue()) {
                communityManager.addCommunity(user,
                    ((Community) vbo), -1);
                vbo.setSuccessfullyImported(true);
                Logger
                    .debug("community vbo successfully imported");
                for (int n = 0; n < vbo.getImportCommunityIDs()
                    .size(); n++) {
                  communityManager.addCommunityMapping(vbo
                      .getId(), vbo
                      .getImportCommunityIDs().get(n));
                  Logger.debug("-> mapped to community "
                      + vbo.getImportCommunityIDs()
                          .get(n));
                }
              } else if (vbo.getType() == ContentType.COLLECTION
                  .getValue()) {
                collectionManager.addCollection(user,
                    ((Collection) vbo), -1);
                vbo.setSuccessfullyImported(true);
                Logger
                    .debug("collection vbo successfully imported");

                for (int n = 0; n < vbo.getImportCommunityIDs()
                    .size(); n++) {
                  collectionManager.addCollectionMapping(vbo
                      .getId(), vbo
                      .getImportCommunityIDs().get(n));
                  Logger.debug("-> mapped to community "
                      + vbo.getImportCommunityIDs()
                          .get(n));
                }
                for (int n = 0; n < vbo
                    .getImportCollectionIDs().size(); n++) {
                  collectionManager.addCollectionMapping(vbo
                      .getId(), vbo
                      .getImportCollectionIDs().get(n));
                  Logger.debug("-> mapped to collection "
                      + vbo.getImportCollectionIDs().get(
                          n));
                }
              } else if (vbo.getType() == ContentType.BUNDLE
                  .getValue()) {
                bundleManager.addBundle(user, ((Bundle) vbo), -1);
                vbo.setSuccessfullyImported(true);
                Logger
                    .debug("bundle vbo successfully imported");

                for (int n = 0; n < vbo.getImportCommunityIDs()
                    .size(); n++) {
                  bundleManager.addBundleMapping(vbo.getId(),
                      vbo.getImportCommunityIDs().get(n));
                  Logger.debug("-> mapped to community "
                      + vbo.getImportCommunityIDs()
                          .get(n));
                }
                for (int n = 0; n < vbo
                    .getImportCollectionIDs().size(); n++) {
                  bundleManager
                      .addBundleMapping(vbo.getId(), vbo
                          .getImportCollectionIDs()
                          .get(n));
                  Logger.debug("-> mapped to collection "
                      + vbo.getImportCollectionIDs().get(
                          n));
                }
              } else if (vbo.getType() == ContentType.ITEM
                  .getValue()) {
                itemManager.addItem(user, ((Item) vbo), -1);
                vbo.setSuccessfullyImported(true);
                Logger.debug("item vbo successfully imported");
                for (int n = 0; n < vbo.getImportCommunityIDs()
                    .size(); n++) {
                  itemManager.addItemMapping(vbo.getId(), vbo
                      .getImportCommunityIDs().get(n));
                  Logger.debug("-> mapped to community "
                      + vbo.getImportCommunityIDs()
                          .get(n));
                }
                for (int n = 0; n < vbo
                    .getImportCollectionIDs().size(); n++) {
                  itemManager.addItemMapping(vbo.getId(), vbo
                      .getImportCollectionIDs().get(n));
                  Logger.debug("-> mapped to collection "
                      + vbo.getImportCollectionIDs().get(
                          n));
                }
                for (int n = 0; n < vbo.getImportBundleIDs()
                    .size(); n++) {
                  itemManager.addItemMapping(vbo.getId(), vbo
                      .getImportBundleIDs().get(n));
                  Logger.debug("-> mapped to bundle "
                      + vbo.getImportBundleIDs().get(n));
                }
              }
            } catch (SQLException e) {
              // this is the only exception that'll mean
              // the item itself wasn't imported ... the
              // rest are failed mappings that we'll leave
              // to the administrator to resolve.
              importCounter--;
              vbo.addToImportErrorHolder(
                  "A database problem occurred: "
                      + e.getMessage(), false);
              Logger.warn("SQLException during import", e);
            } catch (NoSuchCommunityException e) {
              vbo.addToImportErrorHolder(
                  "A community couldn't be found for mapping: "
                      + e.getMessage(), false);
              Logger.debug("mapping to community failed", e);
            } catch (NoSuchCollectionException e) {
              vbo.addToImportErrorHolder(
                  "A collection couldn't be found for mapping: "
                      + e.getMessage(), false);
              Logger.debug("mapping to collection failed", e);
            } catch (NoSuchBundleException e) {
              vbo.addToImportErrorHolder(
                  "A bundle couldn't be found for mapping: "
                      + e.getMessage(), false);
              Logger.debug("mapping to bundle failed", e);
            } catch (NoSuchItemException e) {
              vbo.addToImportErrorHolder(
                  "An item couldn't be found for mapping: "
                      + e.getMessage(), false);
              Logger.debug("mapping to item failed", e);
            }
          }
        } else {
          Logger.debug("vbo import had fatal errors");
        }

        if (vbo.getImportErrorMessages().size() > 0) {
          problems.add(vbo);
        }
      }
    } catch (NumberFormatException e) {
      Logger.warn("Bad content type (" + contentType + ") entered", e);
View Full Code Here

    ArrayList<VBOTreeNodeWrapper> result = new ArrayList<VBOTreeNodeWrapper>();
    if (nodes == null) {
      return result;
    }

    VociBusinessObject vbo;
    boolean userCanEdit = false;
    for (VBOTreeNode node : nodes) {
      vbo = node.getVociBusinessObject();

      // decide whether to continue building this node or not
      if (((!vbo.isActive()) && (mustBeActive))
          || ((linkToType != -1) && (vbo.getType() > linkToType))) {
        continue;
      }

      ArrayList<VBOTreeNode> childNodes = node.getChildren();
      boolean isOpen = (limitToId == null ? ((openNodes != null) ? (openNodes
          .contains(vbo.getId()) ? true : false)
          : false)
          : true);

      if (user == null) {
        userCanEdit = false;
      } else {
        userCanEdit = workflowManager.canEdit(user, projectHandle,
            ContentType.valueOf(vbo.getType()).getPlural(), vbo
                .getId());
      }

      if ((limitToId != null)
          || (node.getVociBusinessObject().getType() != ContentType.ITEM
              .getValue())) {
        if ((limitToId == null)
            || (limitToId.intValue() == node
                .getVociBusinessObject().getId())) {
          result.add(new VBOTreeNodeWrapper(node, level, isOpen,
              userCanEdit, path));
        }

        if ((node.getVociBusinessObject().getType() != ContentType.ITEM
            .getValue())
            && (((limitToId != null) && (limitToId.intValue() != node
                .getVociBusinessObject().getId())) || ((openNodes != null) && (openNodes
                .contains(vbo.getId()))))) {
          result.addAll(getTreeNodeWrappers(childNodes, openNodes,
              (level + 1), mustBeActive, linkToType, user,
              projectHandle, (path.length() > 0 ? path + "/"
                  : path)
                  + node.getVociBusinessObject().getId(),
View Full Code Here

  @SuppressWarnings("unchecked")
  private ArrayList<Integer> getIDsOfType(ArrayList<VBOTreeNode> nodes,
      int contentType) {
    ArrayList<Integer> result = new ArrayList<Integer>();
    if (nodes != null) {
      VociBusinessObject vbo;
      for (VBOTreeNode node : nodes) {
        vbo = node.getVociBusinessObject();
        if (vbo.getType() == contentType) {
          result.add(vbo.getId());
        }
        ArrayList<Integer> childIds = (getIDsOfType(node.getChildren(),
            contentType));
        for (Integer integer : childIds) {
          if (!result.contains(integer)) {
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  private ArrayList<Integer> getIDs(ArrayList<VBOTreeNode> nodes) {
    ArrayList<Integer> result = new ArrayList<Integer>();
    if (nodes != null) {
      VociBusinessObject vbo;
      for (VBOTreeNode node : nodes) {
        vbo = node.getVociBusinessObject();
        result.add(vbo.getId());

        ArrayList<Integer> childIds = (getIDs(node.getChildren()));
        for (Integer integer : childIds) {
          if (!result.contains(integer)) {
            result.add(integer);
View Full Code Here

        nodes.add(new VBOTreeNode(addedVBO, null, null, null, null));
        Collections.sort(nodes);
      } else {
        ArrayList<VBOTreeNode> childNodes;
        if (nodes != null) {
          VociBusinessObject vbo;
          for (VBOTreeNode node : nodes) {
            vbo = node.getVociBusinessObject();
            if (vbo.getId() == parentId) {
              node.addVBO(addedVBO);
              return true;
            } else {
              childNodes = node.getChildren();
              if (addVBO(childNodes, addedVBO, parentId)) {
View Full Code Here

      VociBusinessObject vbo, HttpSession session)
      throws ContentLockedException {
    Logger.debug("lock request on " + ContentType.valueOf(vbo.getType())
        + "/" + vbo.getId() + " for session " + session.getId());

    VociBusinessObject key;
    if ((key = getKey(vboToSessionMap, vbo)) != null) {
      if (!(((User) vboToSessionMap.get(key).getAttribute("user"))
          .getUserId() == (((User) session.getAttribute("user")))
          .getUserId())) {
        Logger.debug("another user has the lock");
View Full Code Here

  private static VociBusinessObject getKey(
      Map<VociBusinessObject, HttpSession> map, VociBusinessObject vbo) {
    VociBusinessObject[] vbos = new VociBusinessObject[0];
    vbos = vboToSessionMap.keySet().toArray(vbos);

    VociBusinessObject key;
    for (int m = vbos.length - 1; m >= 0; m--) {
      key = vbos[m];
      if ((key.getType() == vbo.getType())
          && (key.getId() == vbo.getId())) {
        return key;
      }
    }

    return null;
View Full Code Here

TOP

Related Classes of edu.uga.galileo.voci.bo.VociBusinessObject

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.