/*
(non-Javadoc)

@see com.ibm.ws.sib.processor.impl.interfaces.DestinationHandler#choosePtoPOutputHandler(com.ibm.ws.sib.mfp.JsDestinationAddress)
343674
@Override
    public OutputHandler choosePtoPOutputHandler(SIBUuid8 fixedMEUuid,
                                                 SIBUuid8 preferredMEUuid,
                                                 boolean localMessage,
                                                 boolean forcePut,
                                                 HashSet<SIBUuid8> scopedMEs)
                    throws
                    SIRollbackException,
                    SIConnectionLostException,
                    SIResourceException,
                    SIErrorException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "choosePtoPOutputHandler", new Object[] { fixedMEUuid,
                                                                     preferredMEUuid,
                                                                     localMessage,
                                                                     forcePut,
                                                                     scopedMEs });

        OutputHandler result = null;
        boolean error = false;

        // We're an alias so we should never be called with a scoped ME set
        if (scopedMEs != null)
        {
            SIMPErrorException e = new SIMPErrorException("Alias called with scoped ME set");

            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            {
                SibTr.exception(tc, e);
            }

            e.setExceptionReason(SIRCConstants.SIRC0901_INTERNAL_MESSAGING_ERROR);
            e.setExceptionInserts(new String[] { "com.ibm.ws.sib.processor.impl.ProducerSessionImpl.handleMessage",
                                                "1:750:1.71.2.6",
                                                SIMPUtils.getStackTrace(e) });
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(tc, "choosePtoPOutputHandlers", e);
            throw e;
        }

        // Pull out any scoped ME set that we have configured
        SIBUuid8 singleScopedME = null;
        HashSet<SIBUuid8> definedScopedMEs = null;

        // If this is an alias that's scoped the message points of the target destination
        // then we need to pass these onto the target.
        if (_hasScopedMessagePoints)
        {

            if (_singleScopedQueuePointME != null)
                singleScopedME = _singleScopedQueuePointME;
            else
                definedScopedMEs = _scopedQueuePointMEs;

            // If the caller has fixed an ME, first check it's in our set
            if (fixedMEUuid != null)
            {
                if ((singleScopedME != null) && !fixedMEUuid.equals(singleScopedME))
                    error = true;
                else if ((definedScopedMEs != null) && !definedScopedMEs.contains(fixedMEUuid))
                    error = true;
            }

            // If we have a single ME scoped by this alias we may as pass it to the target as
            // a fixed ME (which it must match as we've already checked that) to save
            // having to parse a HashSet everywhere for no need.
            if (singleScopedME != null)
                fixedMEUuid = singleScopedME;
        }

        // Look to the resolved destination to choose an output handler as the
        // alias destination doesnt store any messages
        if (!error)
            result = _targetDestinationHandler.choosePtoPOutputHandler(fixedMEUuid,
                                                                       preferredMEUuid,
                                                                       localMessage,
                                                                       forcePut,
                                                                       definedScopedMEs);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "choosePtoPOutputHandler", result);

        return result;
    }
682848
function setOutput(msg, outputType, output, value) {
      try {
        switch ( outputType ) {
          case 'msg':
            RED.util.setMessageProperty(msg, output, value);
            break;
          case 'flow':
            node.context().flow.set(output, value);
            break;
          case 'global':
            node.context().global.set(output, value);
            break;
          default:
            node.warn('Unrecognised Output Type, ' + outputType + '. No output.');
        }
      } catch (err) {
        node.warn('Output property, ' + outputType + '.' + output + ', cannot be set. No output.', err);
      }
    }
927264
@Override
    public void createControlAdapter()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createControlAdapter");

        DestinationHandler dh = null;
        try
        {
            ItemStream is = getItemStream();
            if (is instanceof PubSubMessageItemStream)
            {
                dh = ((PubSubMessageItemStream) is).getDestinationHandler();
                controlAdapter = new QueuedMessage(this, dh, is);
            }
            else if (is instanceof MQLinkMessageItemStream)
            {
                dh = ((MQLinkMessageItemStream) is).getDestinationHandler();
                controlAdapter = new MQLinkQueuedMessage(this, dh, is);
            }
            else if (is instanceof PtoPMessageItemStream)
            {
                dh = ((PtoPMessageItemStream) is).getDestinationHandler();
                controlAdapter = new QueuedMessage(this, dh, is);
            }
            else
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    SibTr.debug(this, tc, "Unknown item stream type " + is);
            }
        } catch (Exception e)
        {
            FFDCFilter.processException(
                                        e,
                                        "com.ibm.ws.sib.processor.impl.store.items.MessageItem.createControlAdapter",
                                        "1:2585:1.244.1.40",
                                        this);

            SibTr.exception(tc, e);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "createControlAdapter");
    }
1325917
public void setRoutingDestination(JsDestinationAddress value) {
    if (value != null) {
      jmo.setField(ControlAccess.ROUTINGDESTINATION_VALUE_NAME, value.getDestinationName());
      if (value.getME() != null) {
        jmo.setField(ControlAccess.ROUTINGDESTINATION_VALUE_MEID, value.getME().toByteArray());
      }
      else {
        jmo.setField(ControlAccess.ROUTINGDESTINATION_VALUE_MEID, null);
      }
      jmo.setField(ControlAccess.ROUTINGDESTINATION_VALUE_BUSNAME, value.getBusName());
    }
    else {
      jmo.setChoiceField(ControlAccess.ROUTINGDESTINATION, ControlAccess.IS_ROUTINGDESTINATION_EMPTY);
    }
  }
279512
private static void insertAddressUsingCallable(AddressClient client, String newAddressName)
      throws InterruptedException, ExecutionException {
    // Begin samplegen code for insertAddress().
    ProjectRegionName region = ProjectRegionName.of(PROJECT_NAME, REGION);
    Address address = Address.newBuilder().build();
    InsertAddressHttpRequest request =
        InsertAddressHttpRequest.newBuilder()
            .setRegion(region.toString())
            .setAddressResource(address)
            .build();
    ApiFuture<Operation> future = client.insertAddressCallable().futureCall(request);
    // Do something
    Operation response = future.get();

    // End samplegen code for insertAddress().
    System.out.format("Result of insert: %s\n", response.toString());
  }
1351044
void insertOutputGate(final int pos, final ExecutionGate outputGate) {

		if (this.outputGates[pos] != null) {
			throw new IllegalStateException("Output gate at position " + pos + " is not null");
		}

		this.outputGates[pos] = outputGate;
	}
1086807
public static void consumeTPVObject(TPVObject tpv, Processor processor, GpsdEndpoint endpoint, ExceptionHandler exceptionHandler) {
        // Simplify logging when https://github.com/taimos/GPSd4Java/pull/19 is merged into upstream.
        LOG.debug("About to consume TPV object {},{} from {}", tpv.getLatitude(), tpv.getLongitude(), endpoint);

        Validate.notNull(tpv);
        Validate.notNull(processor);
        Validate.notNull(endpoint);

        GpsCoordinates coordinates = gpsCoordinates(new Date(new Double(tpv.getTimestamp()).longValue()), tpv.getLatitude(), tpv.getLongitude());
        Exchange exchange = anExchange(endpoint.getCamelContext()).withPattern(OutOnly).
                withHeader(TPV_HEADER, tpv).withBody(coordinates).build();

        try {
            processor.process(exchange);
        } catch (Exception e) {
            exceptionHandler.handleException(e);
        }
    }
469278
protected void chooseOperation() throws CoreException
	{
		final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new DecorationgVdmLabelProvider(new VdmUILabelProvider()), new MergedModuleVdmOutlineTreeContentProvider());

		dialog.setTitle(getModuleLabelName()
				+ " and function/operation selection");
		dialog.setMessage("Select a function or operation");
		
		dialog.setComparator(new ViewerComparator(new Comparator<String>() {

			@Override
			public int compare(String str1, String str2) {
		        int res = String.CASE_INSENSITIVE_ORDER.compare(str1, str2);
		        if (res == 0) {
		            res = str1.compareTo(str2);
		        }
		        return res;
			}
		}));

		dialog.addFilter(new ExecutableFilter());
		dialog.setAllowMultiple(false);
		dialog.setValidator(new ISelectionStatusValidator()
		{

			public IStatus validate(Object[] selection)
			{
				if (selection.length == 1
						&& (selection[0] instanceof SOperationDefinition
								&& ((SOperationDefinition) selection[0]).getBody() != null || selection[0] instanceof SFunctionDefinition
								&& ((SFunctionDefinition) selection[0]).getBody() != null))
				{
					return Status.OK_STATUS;
				}
				return new Status(IStatus.CANCEL, IDebugConstants.PLUGIN_ID, "Invalid selection");
			}
		});

		final IProject project = getProject();
		IVdmProject vdmProject = (IVdmProject) project.getAdapter(IVdmProject.class);

		if (VdmTypeCheckerUi.typeCheck(getShell(), vdmProject))
		{
			dialog.setInput(vdmProject.getModel());
			dialog.addFilter(new ExecutableFilter());
			if (dialog.open() == IDialogConstants.OK_ID)
			{
				if (dialog.getFirstResult() instanceof AModuleModules)
				{
					AModuleModules m = (AModuleModules) dialog.getFirstResult();
					defaultModule = m.getName().getName();
					fModuleNameText.setText(DisplayNameCreator.getDisplayName(m));
					return;
				}

				PDefinition method = (PDefinition) dialog.getFirstResult();
				INode module = null;

				if (method.getClassDefinition() != null)
				{
					if (!assistantFactory.createPAccessSpecifierAssistant().isStatic(method.getAccess()))
					{
						boolean foundConstructor = false;
						for (PDefinition def : method.getClassDefinition().getDefinitions())
						{
							if (def instanceof AExplicitOperationDefinition
									&& ((AExplicitOperationDefinition) def).getIsConstructor())
							{
								foundConstructor = true;
								module = def;
								defaultModule = def.getName().getName();
								fModuleNameText.setText(DisplayNameCreator.getDisplayName(def));
							}
						}
						if (!foundConstructor)
						{
							module = method.getClassDefinition();
							defaultModule = method.getClassDefinition().getName().getName();
							fModuleNameText.setText(DisplayNameCreator.getDisplayName(method.getClassDefinition())
									+ MODULE_POST_FIX);
						}
					} else
					{
						module = method.getClassDefinition();
						defaultModule = method.getClassDefinition().getName().getName();
						fModuleNameText.setText(DisplayNameCreator.getDisplayName(method.getClassDefinition()));
					}
				} else if (method.getLocation() != null
						&& method.getLocation().getModule() != null)
				{
					defaultModule = method.getLocation().getModule();
					fModuleNameText.setText(defaultModule);
				} else
				{
					defaultModule = "DEFAULT";
					fModuleNameText.setText(defaultModule);// undetermined
					// module
				}

				String opName = DisplayNameCreator.getDisplayName(method);

				staticOperation = isStaticCall(module, method);
				expression = getExpression(fModuleNameText.getText().trim(), opName.trim(), staticOperation);
				fOperationText.setText(opName);

			}
		}
	}
1023881
public T withOptionalPagingStateString(Optional<String> pagingStateString) {
        pagingStateString.ifPresent(cl -> getOptions().setPagingState(Optional.of(PagingState.fromString(pagingStateString.get()))));
        return getThis();
    }
1151419
private void cmdExportResultActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_buttonSaveResultsActionPerformed
		JFileChooser fileChooser = new JFileChooser(System.getProperty("user.dir"));
		fileChooser.setDialogTitle("Export to...");
		int response = fileChooser.showSaveDialog(this);
		if (response == JFileChooser.APPROVE_OPTION) {
			File targetFile = fileChooser.getSelectedFile();
			final String fileLocation = targetFile.getPath();
			if (canWrite(targetFile)) {
				Thread thread = new Thread() {
					public void run() {						
						getOBDASaveQueryToFileAction().run(fileLocation);
					}
				};
				thread.start();
			}
		}
	}
36722
@Override
    public void unlockPubsubOutputHandlers()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "unlockPubsubOutputHandlers");

        _targetDestinationHandler.unlockPubsubOutputHandlers();

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "unlockPubsubOutputHandlers");
    }
314944
public void deleteSystemDestination(JsDestinationAddress destAddr) throws SIResourceException, SINotPossibleInCurrentConfigurationException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "deleteSystemDestination", new Object[] { destAddr });

        BaseDestinationHandler destinationHandler = null;

        DestinationTypeFilter filter = new DestinationTypeFilter();
        filter.VISIBLE = Boolean.TRUE;
        filter.ALIAS = Boolean.FALSE;
        filter.FOREIGN_DESTINATION = Boolean.FALSE;
        DestinationHandler dh =
                        destinationIndex.findByName(destAddr.getDestinationName(), messageProcessor.getMessagingEngineBus(), filter);

        try
        {
            checkDestinationHandlerExists(
                                          dh != null,
                                          destAddr.getDestinationName(),
                                          messageProcessor.getMessagingEngineName());
        } catch (SITemporaryDestinationNotFoundException e)
        {
            // // FFDC
            FFDCFilter.processException(
                                        e,
                                        "com.ibm.ws.sib.processor.impl.DestinationManager.deleteSystemDestination",
                                        "1:5408:1.508.1.7",
                                        this);

            // This shouldn't occur as the Connection will create a valid system destination.
            // Or validate that the destination address passed in is a system destination

            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(tc, "deleteSystemDestination", "SIErrorException");

            throw new SIErrorException(
                            nls.getFormattedMessage(
                                                    "INTERNAL_MESSAGING_ERROR_CWSIP0003",
                                                    new Object[] { "com.ibm.ws.sib.processor.impl.DestinationManager",
                                                                  "1:5421:1.508.1.7",
                                                                  e,
                                                                  destAddr.getDestinationName() },
                                                    null),
                            e);
        }

        destinationHandler = (BaseDestinationHandler) dh;

        deleteSystemDestination(destinationHandler);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "deleteSystemDestination");
    }
975194
@Override
    public ControlHandler getControlHandler(
                                            ProtocolType type, SIBUuid8 sourceMEUuid, ControlMessage msg)
    {
        throw new InvalidOperationException(
                        nls.getFormattedMessage(
                                                "INTERNAL_MESSAGING_ERROR_CWSIP0005",
                                                new Object[] { "AbstractAliasDestinationHandler",
                                                              "1:681:1.67.1.22",
                                                              getBus() + " : " + getName() },
                                                null));
    }
1129874
@Override
	public void setOutputType(TypeInformation<OUT> outTypeInfo, ExecutionConfig executionConfig) {
		StreamingFunctionUtils.setOutputType(userFunction, outTypeInfo, executionConfig);
	}
86231
@Override
    public HashMap getAllPubSubOutputHandlers()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "getAllPubSubOutputHandlers");

        HashMap handlers =
                        _pubSubRealization.getAllPubSubOutputHandlers();

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "getAllPubSubOutputHandlers", handlers);

        return handlers;
    }
567561
@Override
    public InputHandler getInputHandler(ProtocolType type, SIBUuid8 sourceMEUuid, JsMessage msg)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "getInputHandler", new Object[] { type, sourceMEUuid });

        InputHandler msgHandler = null;

        if (type == ProtocolType.UNICASTINPUT)
        {
            msgHandler = getInputHandler();
        }
        else if (type == ProtocolType.PUBSUBINPUT)
        {
            msgHandler = getInputHandler();
        }
        else if (type == ProtocolType.ANYCASTINPUT)
        {
            //Defer remote get inputHandler to the resolved destination
            msgHandler = _targetDestinationHandler.getInputHandler(type, sourceMEUuid, msg);
        }
        else
        {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(tc, "getInputHandler", "SIErrorException");
            //unsupported protocol type
            throw new SIErrorException(
                            nls.getFormattedMessage(
                                                    "INTERNAL_MESSAGING_ERROR_CWSIP0005",
                                                    new Object[] { "AbstractAliasDestinationHandler",
                                                                  "1:751:1.67.1.22",
                                                                  getBus() + " : " + getName() },
                                                    null));
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "getInputHandler", msgHandler);

        return msgHandler;
    }
452603
@Override
    public JsDestinationAddress getReplyDestination()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        {
            SibTr.entry(tc, "getReplyDestination");
            SibTr.exit(tc, "getReplyDestination", _replyDest);
        }

        return _replyDest;
    }