/*
Performs the GetFeatureOfInterest request to obtain the locations of sources of data that match the required
observed properties and procedures.
@param {SensorObservationServiceCatalogItem} item
@return Promise for the request.
173943
function loadFeaturesOfInterest(item) {
  const filter = {
    observedProperty: item.observableProperties.map(
      observable => observable.identifier
    ) // eg. 'http://bom.gov.au/waterdata/services/parameters/Storage Level'
  };
  if (item.filterByProcedures) {
    filter.procedure = item.procedures.map(procedure => procedure.identifier); // eg. 'http://bom.gov.au/waterdata/services/tstypes/Pat7_C_B_1_YearlyMean',
  }
  const templateContext = {
    action: "GetFeatureOfInterest",
    actionClass: "foiRetrieval",
    parameters: convertObjectToNameValueArray(filter),
    temporalFilters: getTemporalFiltersContext(item)
  };
  return loadSoapBody(item, templateContext)
    .then(function(body) {
      var featuresResponse = body.GetFeatureOfInterestResponse;
      // var locations = featuresResponse.featureMember.map(x=>x.MonitoringPoint.shape.Point.pos.text);
      if (!featuresResponse) {
        throw new TerriaError({
          sender: item,
          title: item.name,
          message: "There are no features matching your query."
        });
      }
      if (!defined(featuresResponse.featureMember)) {
        throw new TerriaError({
          sender: item,
          title: item.name,
          message: "The server responded with an unknown feature format."
        });
      }
      var featureMembers = featuresResponse.featureMember;
      if (!Array.isArray(featureMembers)) {
        featureMembers = [featureMembers];
      }
      if (item.stationIdWhitelist) {
        featureMembers = featureMembers.filter(
          m =>
            m.MonitoringPoint &&
            item.stationIdWhitelist.indexOf(
              String(m.MonitoringPoint.identifier)
            ) >= 0
        );
      }
      if (item.stationIdBlacklist) {
        featureMembers = featureMembers.filter(
          m =>
            m.MonitoringPoint &&
            !item.stationIdBlacklist.indexOf(
              String(m.MonitoringPoint.identifier)
            ) >= 0
        );
      }
      if (item.representAsGeoJson) {
        item._geoJsonItem = createGeoJsonItemFromFeatureMembers(
          item,
          featureMembers
        );
        return item._geoJsonItem.load().then(function() {
          item.rectangle = item._geoJsonItem.rectangle;
          return;
        });
      } else {
        item._featureMapping = createMappingFromFeatureMembers(featureMembers);
      }
    })
    .otherwise(function(e) {
      throw e;
    });
}
952020
function(item) {
			this.scope("");
			return this.fileClient.getWorkspace(item.Location).then(function(workspace) {
				return this.loadRoot(workspace).then(function() {
					return this.showItem(item, false); // call with reroot=false to avoid recursion
				}.bind(this));
			}.bind(this));
		}
303809
private void notifyFactories(Object item) {
    for(VisualizationProcessor f : factories) {
      try {
        f.processNewResult(this, item);
      }
      catch(Throwable e) {
        LOG.warning("VisFactory " + f.getClass().getCanonicalName() + " failed:", e);
      }
    }
  }
677124
public ESigItem add(ESigItem item) {
        if (!items.contains(item)) {
            items.add(item);
            fireEvent("ADD", item);
        }
        
        return item;
    }
293410
function(item) {
            var itemElm;
            switch(item.type) {
                case 'milestone':
                    itemElm = this._buildMilestoneElement(item);
                    break;
                case 'smallItem':
                    itemElm = this._buildSmallItemElement(item);
                    break;
                case 'bigItem':
                    itemElm = this._buildBigItemElement(item);
                    break;
            }
            item.element = itemElm;
            this._refreshItemPosition(item);

            item.element.on('timelineMe.itemHeightChanged', function(event) {
                // Do some stuff
            });
            item.element.on('timelineMe.smallItem.displayfull', function(event) {
                // Do some stuff
            });
            item.element.on('timelineMe.bigItem.flipped', function(event) {
                var container = item.element.find('.timeline-me-content-container');
                if(item.element.hasClass('timeline-me-flipped')) {
                    container.height(item.fullContentElement.outerHeight());
                } else {
                    container.height(item.shortContentElement.outerHeight());
                }
            });

            this._buildItemContent(item);
            this._fillItem(item);

            return itemElm;
        }
654770
private ItemData getItemData(final String identifier, final boolean doInitACL) throws RepositoryException
   {
      if (cache.isEnabled())
      {
         // 1. Try from cache
         ItemData data = getCachedCleanItemData(identifier);

         // 2 Try from container
         if (data == null)
         {
            final DataRequest request = new DataRequest(identifier);

            try
            {
               request.start();
               // Try first to get the value from the cache since a
               // request could have been launched just before
               data = getCachedCleanItemData(identifier);
               if (data == null)
               {
                  data = executeAction(new PrivilegedExceptionAction<ItemData>()
                  {
                     public ItemData run() throws RepositoryException
                     {
                        return getPersistedItemData(identifier);
                     }
                  });
               }
            }
            finally
            {
               request.done();
            }
         }

         if (data instanceof NullItemData)
         {
            return null;
         }

         if (data != null && !data.isNode())
         {
            fixPropertyValues((PropertyData)data);
         }

         return data;
      }
      else
      {
         return executeAction(new PrivilegedExceptionAction<ItemData>()
         {
            public ItemData run() throws RepositoryException
            {
               ItemData item = CacheableWorkspaceDataManager.super.getItemData(identifier);
               if (item != null && item.isNode() && doInitACL)
               {
                  return initACL(null, (NodeData)item);
               }
               else
               {
                  return item;
               }
            }
         });
      }
   }
245121
public boolean execute(Canvas target, Menu menu, MenuItem item) {
		int count = mapWidget.getMapModel().getNrSelectedFeatures();
		if (count == 1) {
			for (VectorLayer layer : mapWidget.getMapModel().getVectorLayers()) {
				if (layer.getSelectedFeatures().size() == 1) {
					// It's already selected, so we assume the feature is fully loaded:
					feature = layer.getFeatureStore().getPartialFeature(layer.getSelectedFeatures().iterator().next());
					return true;
				}
			}
			return true;
		}
		return false;
	}
276371
public GeoServiceItem toGeoServiceItem(final GeoCodeItem item) {
        if (item == null) {
            return null;
        }
        return new GeoServiceItem(item.getPlaceName(),
                item.getModernPlaceName(),
                toGeoServiceGeocodingResult(item.getGeocodingResult()));
    }
281125
protected ItemData putItem(ItemData item)
   {
      if (item.isNode())
      {
         return putNode((NodeData)item, ModifyChildOption.MODIFY);
      }
      else
      {
         return putProperty((PropertyData)item, ModifyChildOption.MODIFY);
      }
   }
1189724
private void initItem(IManagedContext<?> item, ISurveyCallback callback) {
        try {
            localChangeBegin(item);

            if (hasSubject(item.getContextName())) {
                item.setContextItems(contextItems);
            } else {
                item.init();
            }

            localChangeEnd(item, callback);
        } catch (ContextException e) {
            log.error("Error initializing context.", e);
            execCallback(callback, new SurveyResponse(e.toString()));
        }
    }
55904
public boolean filterMatches(AbstractItem item)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "filterMatches", item);

    boolean result = true;

    if (_selectorTree != null || _discriminatorTree != null)
    { 
      SIMPMessage msg = (SIMPMessage) item;
      // Defect 382250, set the unlockCount from MsgStore into the message
      // in the case where the message is being redelivered.
      // 668676, get the message if available
      JsMessage jsMsg = msg.getMessageIfAvailable();
      if ( msg == null)
      {
    	  result = false;
      }
      else
      {
          int redelCount = msg.guessRedeliveredCount();
           
          if (redelCount > 0)
          {
              if(TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                  SibTr.debug(tc, "Set deliverycount into message: " + redelCount);          
              jsMsg.setDeliveryCount(redelCount);
          }
          // Evaluate message against selector tree
          result =
              _messageProcessor.getMessageProcessorMatching().evaluateMessage(
              _selectorTree,
              _discriminatorTree,
              jsMsg);
      }
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "filterMatches", new Boolean(result));
    return result;

  }
612528
public boolean execute(Canvas target, Menu menu, MenuItem item) {
		FeatureTransaction featureTransaction = mapWidget.getMapModel().getFeatureEditor().getFeatureTransaction();
		if (featureTransaction != null) {
			boolean operationCount = featureTransaction.getOperationQueue().size() > 0;
			if (operationCount) {
				// The first addCoordinateOp may not be undone!
				FeatureOperation firstOperation = featureTransaction.getOperationQueue().get(0);
				if (firstOperation instanceof AddCoordinateOp) {
					if (featureTransaction.getNewFeatures()[0].getGeometry().getNumPoints() == 1) {
						return false;
					}
				}

				return true;
			}
		}
		return false;
	}
1319901
function loadDataflow(item) {
  var dataflowUrl = cleanAndProxyUrl(item, item._dataflowUrl);
  return loadJson(dataflowUrl).then(function(json) {
    // Then access:
    //   - result.structure.dimensions.observation[k] for {keyPosition, id, name, values[]} to get the name & id of dimension keyPosition and its array of allowed values (with {id, name}).
    //   - result.structure.dimensions.attributes.dataSet has some potentially interesting things such as units, unit multipliers, reference periods (eg. http://stats.oecd.org/sdmx-json/dataflow/QNA).
    //   - result.structure.dimensions.attributes.observation has some potentially interesting things such as time formats and status (eg. estimated value, forecast value).
    var structureSeries = json.structure.dimensions.observation;

    item._fullDimensions = buildDimensions(item, structureSeries);
    if (
      !defined(
        getDimensionIndexById(item._fullDimensions, item.regionDimensionId)
      )
    ) {
      throw noRegionsError(item);
    }
    item._concepts = buildConcepts(item, item._fullDimensions);
    // console.log('concepts', item._concepts);
    // The rest of the magic occurs because the concepts are made active.
    // So that the loading flow works properly, make that happen now.
    return changedActiveItems(item);
  });
}
834247
@Override
    public AbstractItem findById(long itemID) throws MessageStoreException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "findById", Long.valueOf(itemID));

        AbstractItem item = _findById(itemID);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "findById", item);
        return item;
    }
423755
function (config) {
    return _.map(config.features, function(featureDef) {
      var feature = null
        , featurePath = null;

      var featureId = featureDef.$featureId || featureDef.feature;

      // Try to require the feature from each path listed in `config.featurePaths`.
      for (var i = 0; i < config.featurePaths.length; ++i) {
        featurePath = path.join(config.featurePaths[i], featureDef.feature);
        if (fs.existsSync(featurePath) || fs.existsSync(featurePath + '.js')) {
          feature = require(featurePath);
          break;
        }
      }

      if (!feature) {
        var errorMsg =
          'Cannot find feature: ' + util.inspect(featureDef.feature) +
          ' from featurePaths: ' + util.inspect(config.featurePaths);
        throw new Error(errorMsg);
      }

      var featureTasks = _.get(feature, 'tasks', []);

      return {
        featureId: featureId,
        featureDef: featureDef,
        featureConstructor : feature,
        tasks: featureTasks
      };
    });
  }
366020
def get_existing_item(self, item):
        
        params = {
            'project_id': item.project_id,
            'from_user_id': item.from_user_id,
            'to_user_id': item.to_user_id,
        }
        resp = requests.get(self.make_url(item.destination), headers=self.json_headers, params=params)
        self.check_response(resp)
        return resp
184853
function(item) {
        if (item && Selectivity.isValidId(item.id) && isString(item.text)) {
            return item;
        } else {
            throw new Error('Item should have id (number or string) and text (string) properties');
        }
    }