Package org.fao.geonet.kernel

Examples of org.fao.geonet.kernel.SelectionManager


        .getParam(params, "relation", "true");

    UserSession session = context.getUserSession();

    Log.info(Geonet.MEF, "Create export task for selected metadata(s).");
    SelectionManager selectionManger = SelectionManager.getManager(session);
    Set<String> uuids = selectionManger
        .getSelection(SelectionManager.SELECTION_METADATA);
    Set<String> uuidsBeforeExp = Collections
        .synchronizedSet(new HashSet<String>(0));
        Log.info(Geonet.MEF, "Current record(s) in selection: " + uuids.size());
        uuidsBeforeExp.addAll(uuids);

        // If provided uuid, export the metadata record only
        if (uuid != null) {
            SelectionManager.getManager(session).close(SelectionManager.SELECTION_METADATA);

            SelectionManager.getManager(session).addSelection(
                    SelectionManager.SELECTION_METADATA, uuid);

            uuids = selectionManger
                    .getSelection(SelectionManager.SELECTION_METADATA);
        }


        // If provided uuid, export the metadata record only
        if (uuid != null) {
            SelectionManager.getManager(session).close(SelectionManager.SELECTION_METADATA);

            SelectionManager.getManager(session).addSelection(
                    SelectionManager.SELECTION_METADATA, uuid);

            uuids = selectionManger
                    .getSelection(SelectionManager.SELECTION_METADATA);
        }

    // MEF version 1 only support one metadata record by file.
    // Uuid parameter MUST be set and add to selection manager before
    // export.
    if (version == null) {
      file = MEFLib.doExport(context, uuid, format, skipUUID, resolveXlink, removeXlinkAttribute);
    } else {
      // MEF version 2 support multiple metadata record by file.

      if (relatedMetadataRecord.equals("true")) {
        // Adding children in MEF file
        Set<String> tmpUuid = new HashSet<String>();
        for (Iterator<String> iter = uuids.iterator(); iter.hasNext();) {
          String _uuid = (String) iter.next();

          // Creating request for services search
          Element childRequest = new Element("request");
          childRequest.addContent(new Element("parentUuid")
              .setText(_uuid));
          childRequest.addContent(new Element("to").setText("1000"));

          // Get children to export - It could be better to use GetRelated service TODO
          Set<String> childs = getUuidsToExport(_uuid, context,
              childRequest);
          if (childs.size() != 0) {
            tmpUuid.addAll(childs);
          }

          // Creating request for services search
          Element servicesRequest = new Element(Jeeves.Elem.REQUEST);
          servicesRequest.addContent(new Element(
              org.fao.geonet.constants.Params.OPERATES_ON)
              .setText(_uuid));
          servicesRequest.addContent(new Element(
              org.fao.geonet.constants.Params.TYPE)
              .setText("service"));

          // Get linked services for export
          Set<String> services = getUuidsToExport(_uuid, context,
              servicesRequest);
          if (services.size() != 0) {
            tmpUuid.addAll(services);
          }
        }

        if (selectionManger.addAllSelection(
            SelectionManager.SELECTION_METADATA, tmpUuid))
          Log.info(Geonet.MEF,
              "Child and services added into the selection");
      }

      uuids = selectionManger
          .getSelection(SelectionManager.SELECTION_METADATA);
      Log.info(Geonet.MEF, "Building MEF2 file with " + uuids.size()
          + " records.");

      file = MEFLib
          .doMEF2Export(context, uuids, format, false, stylePath, resolveXlink, removeXlinkAttribute);
    }

    // -- Reset selection manager
    selectionManger.close();
    selectionManger.addAllSelection(SelectionManager.SELECTION_METADATA,
        uuidsBeforeExp);

    String fname = String.valueOf(Calendar.getInstance().getTimeInMillis());

    return BinaryFile.encode(200, file, "export-" + format + "-" + fname
View Full Code Here


        if (oldSearcher instanceof LuceneSearcher) ((LuceneSearcher)oldSearcher).close();
      }
    }

    context.info("Get selected metadata");
    SelectionManager sm = SelectionManager.getManager(session) ;

    // Get the sortBy params in order to apply on new result list.
        if (StringUtils.isNotEmpty(params.getChildText(Geonet.SearchResult.SORT_BY)) ) {
            params.addContent(new Element(Geonet.SearchResult.SORT_BY).setText(params.getChildText(Geonet.SearchResult.SORT_BY)));
        }

        if (StringUtils.isNotEmpty(params.getChildText(Geonet.SearchResult.SORT_ORDER))) {
            params.addContent(new Element(Geonet.SearchResult.SORT_ORDER).setText(params.getChildText(Geonet.SearchResult.SORT_ORDER)));
        }
       
    if (sm != null) {
      String uuids= "";
      boolean first = true;
      synchronized(sm.getSelection("metadata")) {
        for (Iterator<String> iter = sm.getSelection("metadata").iterator(); iter.hasNext();) {
          String uuid = (String) iter.next();
          if (first) {
            uuids = (String) uuid;
            first = false;
          }
View Full Code Here

    // --- see if we need to process selected set or just uuid
    if (uuid.length() == 0) { // no uuid so process selected set
      if(context.isDebugEnabled()) context.debug("Get selected metadata");

      SelectionManager sm = SelectionManager.getManager(session);

      synchronized(sm.getSelection("metadata")) {
      for (Iterator<String> iter = sm.getSelection("metadata").iterator(); iter.hasNext();) {
        uuid = (String) iter.next();
        processRecord(context, uuid, category, xpath, getTit, xpathTit, doChanges, metadata, notFound, notOwner, subtemplates, response);

      }
      }
View Full Code Here

        Set<Integer> metadata = new HashSet<Integer>();
        Set<Integer> notFound = new HashSet<Integer>();
        Set<Integer> notOwner = new HashSet<Integer>();

        context.info("Get selected metadata");
        SelectionManager sm = SelectionManager.getManager(session);

        synchronized (sm.getSelection("metadata")) {
            for (Iterator<String> iter = sm.getSelection("metadata").iterator(); iter.hasNext(); ) {
                String uuid = (String) iter.next();
                String id = dm.getMetadataId(uuid);

                context.info("Attempting to set metadata owner on: " + id);
View Full Code Here

     if (oldSearcher != null)
       if (oldSearcher instanceof LuceneSearcher)
         ((LuceneSearcher)oldSearcher).close();
   
    // possibly close old selection
    SelectionManager oldSelection = (SelectionManager)session.getProperty(Geonet.Session.SELECTED_RESULT);
   
    if (oldSelection != null){
      oldSelection.close();
    }
   

    // perform the search and save search query into session
    MetaSearcher searcher;
View Full Code Here

    Set<Integer> notOwner = new HashSet<Integer>();
        boolean backupFile = Util.getParam(params, Params.BACKUP_FILE, true);

        if(context.isDebugEnabled())
            context.debug("Get selected metadata");
    SelectionManager sm = SelectionManager.getManager(session);

    synchronized(sm.getSelection("metadata")) {
    for (Iterator<String> iter = sm.getSelection("metadata").iterator(); iter.hasNext();) {
      String uuid = (String) iter.next();
            if(context.isDebugEnabled())
                context.debug("Deleting metadata with uuid:"+ uuid);

      String id   = dataMan.getMetadataId(uuid);
View Full Code Here

    DataManager dm = gc.getBean(DataManager.class);
    UserSession us = context.getUserSession();


    context.info("Get selected metadata");
    SelectionManager sm = SelectionManager.getManager(us);

    Element ret = new Element("response");
   
    String paramId = Util.getParam(params, "id", null) ;
    ArrayList<String> lst = new ArrayList<String>();
   
    // case #1 : #id parameter is undefined
    if (paramId == null) {
        synchronized(sm.getSelection("metadata")) {
            for (Iterator<String> iter = sm.getSelection("metadata").iterator(); iter.hasNext();) {
                String uuid = (String) iter.next();
                String id   = dm.getMetadataId(uuid);
                lst.add(id);
            }
        }
View Full Code Here

    DataManager   dm = gc.getBean(DataManager.class);
    AccessManager accessMan = gc.getBean(AccessManager.class);
    UserSession   us = context.getUserSession();

    context.info("Get selected metadata");
    SelectionManager sm = SelectionManager.getManager(us);

    Set<Integer> metadata = new HashSet<Integer>();
    Set<String> notFound = new HashSet<String>();
    Set<Integer> notOwner = new HashSet<Integer>();

    synchronized(sm.getSelection(SELECTION_METADATA)) {
    for (Iterator<String> iter = sm.getSelection(SELECTION_METADATA).iterator(); iter.hasNext();) {
      String uuid = iter.next();

      //--- check access

      Metadata info = context.getBean(MetadataRepository.class).findOneByUuid(uuid);
View Full Code Here

    AccessManager accessMan = gc.getBean(AccessManager.class);
    UserSession us = context.getUserSession();


    context.info("Get selected metadata");
    SelectionManager sm = SelectionManager.getManager(us);

    Set<Integer> metadata = new HashSet<Integer>();
    Set<Integer> notFound = new HashSet<Integer>();
    Set<Integer> notOwner = new HashSet<Integer>();

    synchronized(sm.getSelection("metadata")) {
    for (Iterator<String> iter = sm.getSelection("metadata").iterator(); iter.hasNext();) {
      String uuid = (String) iter.next();
      String id   = dm.getMetadataId(uuid);
               
      //--- check access
View Full Code Here

    Set<Integer> notFound = new HashSet<Integer>();
    Set<Integer> notOwner = new HashSet<Integer>();

        if(context.isDebugEnabled())
            context.debug("Get selected metadata");
    SelectionManager sm = SelectionManager.getManager(session);

    synchronized(sm.getSelection("metadata")) {
    for (Iterator<String> iter = sm.getSelection("metadata").iterator(); iter.hasNext();) {
      String uuid = (String) iter.next();
            if(context.isDebugEnabled())
                context.debug("Deleting metadata with uuid:"+ uuid);

      String id   = dataMan.getMetadataId(uuid);
View Full Code Here

TOP

Related Classes of org.fao.geonet.kernel.SelectionManager

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.