Examples of Information


Examples of org.apache.slide.projector.Information

    public Result process(Map parameter, Context context) throws Exception {
        String username = parameter.get(USERNAME).toString();
        String password = parameter.get(PASSWORD).toString();
        Credentials credentials = Projector.getRepository().login(username, password);
        if ( credentials == null ) {
            context.addInformation(new Information(Information.ERROR, new ErrorMessage("login/invalidLogin"), new String[] { USERNAME, PASSWORD }));
            return new Result(LOGIN_FAILED);
        }
        context.setCredentials(credentials);
        return new Result(LOGIN_OK);
    }
View Full Code Here

Examples of org.apache.slide.projector.Information

            if ( validate ) {
              try {
                controlValue = ProcessorManager.prepareValue(parameterDescriptor, controlValue, context);
              } catch ( ValidationException exception ) {
                controlValue = StringValueDescriptor.ANY.valueOf(controlValue, context).toString();
                context.addInformation(new Information(Information.ERROR, exception.getErrorMessage(), new String[] { parameterName }));
              }
              controlParameters.put(Control.VALUE, controlValue);
              if ( hasErrors(informations, parameterName) ) {
                if ( required ) {
                  controlState = Control.REQUIRED_INVALID_CONTROL;
                } else {
                  controlState = Control.OPTIONAL_INVALID_CONTROL;
                }
                explodeInformations(controlParameters, informations, parameterName, locale);
              } else {
                if ( required ) {
                  controlState = Control.REQUIRED_VALID_CONTROL;
                } else {
                  controlState = Control.OPTIONAL_VALID_CONTROL;
                }
              }
            }
            controlParameters.put(Control.STATE, controlState);
            controlParameters.put(Control.VALUE, controlValue);
            Result controlResult = control.process(controlParameters, context);
            if ( controlContainerUri != NullValue.NULL ) {
              Processor controlContainer = ProcessorManager.getInstance().getProcessor((URI)controlContainerUri);
              Map controlContainerParameters = new HashMap();
              controlContainerParameters.putAll(parameter);
              if ( hasErrors(informations, parameterName) ) {
                explodeInformations(controlContainerParameters, informations, parameterName, locale);
              }
              controlContainerParameters.put(Control.STATE, controlState);
              controlContainerParameters.put(CONTROL, controlResult.getResultEntries().get(OUTPUT));
              controlContainerParameters.put(TITLE, description.getTitle(locale, parameterName ));
              try {
                controlContainerParameters.put(TEXT, description.getText(locale));
                controlContainerParameters.put(PROMPT, description.getPrompt(locale));
              } catch ( MessageNotFoundException exception ) {
                controlContainerParameters.put(TEXT, NO_PARAMETER_MESSAGE_AVAILABLE.getText(locale, " "));
                controlContainerParameters.put(PROMPT, NO_PARAMETER_MESSAGE_AVAILABLE.getPrompt(locale, " "));
              }
              try {
                ProcessorManager.prepareValues(controlContainer.getParameterDescriptors(), controlContainerParameters, context);
              } catch ( ValidationException exception ) {
                throw new ValidationException(new ErrorMessage("controlComposer/controlContainerParameterInvalid", new Object[] { controlContainerUri }), exception);
              }
              Result controlContainerResult = controlContainer.process(controlContainerParameters, context);
              generatedControls.add(new MapValue(controlName, (Value)controlContainerResult.getResultEntries().get(OUTPUT)));
            } else {
              generatedControls.add(new MapValue(controlName, (Value)controlResult.getResultEntries().get(OUTPUT)));
            }
            if ( controlState == Control.OPTIONAL_INVALID_CONTROL || controlState == Control.REQUIRED_INVALID_CONTROL  ) {
              state = INVALID_STATE;
            } else if ( state == DEFAULT_STATE && ( controlState == Control.OPTIONAL_VALID_CONTROL || controlState == Control.REQUIRED_VALID_CONTROL ) ) {
              state = VALID_STATE;
            }
        }
        Result composerResult = new Result(state, GENERATED_CONTROLS, new ArrayValue((Value [])generatedControls.toArray(new Value[generatedControls.size()])));
    List generatedTriggers = new ArrayList();
    for (int i = 0; i < triggerDescriptions.length; i++ ) {
          Map triggerParameters = ((MapValue)triggerDescriptions[i]).getMap();
          String triggerName = triggerParameters.get(TRIGGER_NAME).toString();
          Value involvedTriggerParameters = (Value)triggerParameters.get(Trigger.INVOLVED_PARAMETERS);
          if ( involvedTriggerParameters == NullValue.NULL ) {
            involvedTriggerParameters = new ArrayValue((StringValue[])involvedParameters.toArray(new StringValue[involvedParameters.size()]));
          }
          triggerParameters.put(Trigger.INVOLVED_PARAMETERS, involvedTriggerParameters);
          URI triggerUri = (URI)triggerParameters.get(TRIGGER);
          Trigger trigger = (Trigger)ProcessorManager.getInstance().getProcessor(triggerUri);
          Value triggerActionUri = (Value)triggerParameters.get(Trigger.ACTION);
          if ( triggerActionUri == NullValue.NULL ) triggerActionUri = actionUri;
           triggerParameters.put(Trigger.ACTION, triggerActionUri);
          try {
            ProcessorManager.prepareValues(trigger.getParameterDescriptors(), triggerParameters, context);
          } catch ( ValidationException exception ) {
            throw new ValidationException(new ErrorMessage("controlComposer/triggerParameterInvalid", new Object[] { triggerUri }), exception);
          }
            Value triggerContainerUri = (Value)triggerParameters.get(TRIGGER_CONTAINER);
            Result triggerResult = trigger.process(triggerParameters, context);
            if ( triggerContainerUri != NullValue.NULL ) {
              Processor triggerContainer = ProcessorManager.getInstance().getProcessor((URI)triggerContainerUri);
              Map triggerContainerParameters = new HashMap();
              triggerContainerParameters.putAll(parameter);
              triggerContainerParameters.put(TRIGGER, triggerResult.getResultEntries().get(OUTPUT));
              try {
                ProcessorManager.prepareValues(triggerContainer.getParameterDescriptors(), triggerContainerParameters, context);
              } catch ( ValidationException exception ) {
                throw new ValidationException(new ErrorMessage("controlComposer/triggerContainerParameterInvalid", new Object[] { triggerContainerUri }), exception);
              }
              Result triggerContainerResult = triggerContainer.process(triggerContainerParameters, context);
              generatedTriggers.add(new MapValue(triggerName, (Value)triggerContainerResult.getResultEntries().get(OUTPUT)));
            } else {
              generatedTriggers.add(new MapValue(triggerName, (Value)triggerResult.getResultEntries().get(OUTPUT)));
            }
        }
        composerResult.addResultEntry(GENERATED_TRIGGERS, new ArrayValue((Value [])generatedTriggers.toArray(new Value[generatedTriggers.size()])));
        if ( errorsProcessorUri instanceof URI ) {
          Processor errorsTable = ProcessorManager.getInstance().getProcessor((URI)errorsProcessorUri);
          List errorList = new ArrayList();
          for ( Iterator i = context.getInformations().iterator(); i.hasNext(); ) {
            Information info = (Information)i.next();
            Map errors = new HashMap();
            explodeInformation(errors, info, locale );
            errorList.add(new MapValue(errors));
          }
          Map errorsParameter = new HashMap();
View Full Code Here

Examples of org.apache.slide.projector.Information

    protected void explodeInformations(Map parameters, List informations, String parameterName, Locale locale) {
        // FIXME: Use template for error numbers
        List matchingInfos = getErrors(informations, parameterName);
        StringBuffer buffer = new StringBuffer();
        for ( Iterator i = matchingInfos.iterator(); i.hasNext(); ) {
            Information info = (Information)i.next();
          buffer.append(info.getNumber()).append(") ");
            explodeInformation(parameters, info, locale);
        }
        parameters.put(ERROR_NUMBER, buffer.toString());
    }
View Full Code Here

Examples of org.apache.slide.projector.Information

        }
    }

   protected boolean hasErrors(List informations, String parameterName) {
       for ( Iterator i = informations.iterator(); i.hasNext(); ) {
         Information info = (Information)i.next();
           if ( info.isParameterInvolved(parameterName) && info.getSeverity() == Information.ERROR ) {
               return true;
           }
       }
       return false;
   }
View Full Code Here

Examples of org.apache.slide.projector.Information

   }

    protected List getErrors(List informations, String parameterName) {
        List matchingInfos = new ArrayList();
        for ( Iterator i = informations.iterator(); i.hasNext(); ) {
          Information info = (Information)i.next();
          if ( info.isParameterInvolved(parameterName) && info.getSeverity() == Information.ERROR ) {
                matchingInfos.add(info);
            }
        }
        return matchingInfos;
    }
View Full Code Here

Examples of org.apache.slide.projector.Information

        return result;
  }

    protected boolean hasErrors(List informations) {
        for ( Iterator i = informations.iterator(); i.hasNext(); ) {
          Information info = (Information)i.next();
          if ( info.getSeverity() == Information.ERROR ) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

Examples of org.jboss.remoting.samples.transporter.complex.Information

   public Doctor findDoctor(Patient patient) throws NoDoctorAvailableException
   {
      // get the patient's ailment type and look for doctor that specializes
      String ailmentType = patient.getAilmentType();

      Information info = Information.getInstance();
      Doctor doc = info.getProviderBySpecialty(ailmentType);
      if(doc != null)
      {
         doc.addPatient(patient);
         return doc;
      }
View Full Code Here

Examples of org.jboss.remoting.samples.transporter.complex.Information

   }

   public void retireDoctor(Doctor doctor)
   {
      Information info = Information.getInstance();
      info.retireDoctor(doctor);
   }
View Full Code Here

Examples of org.nfctools.llcp.pdu.Information

        connect.getDestinationServiceAccessPoint()).processPdu(connectionManager);

    assertEquals(1, connectionManager.getOpenConnectionsSize());
    assertTrue(processPdu.toString(), processPdu instanceof Information);

    Information information = (Information)processPdu;
    assertEquals("Hello", new String(information.getServiceDataUnit()));
    processPdu = new ReceiveReady(information.getSourceServiceAccessPoint(),
        information.getDestinationServiceAccessPoint(), 1).processPdu(connectionManager);
    assertTrue(processPdu.toString(), processPdu instanceof Disconnect);

    Disconnect disconnect = (Disconnect)processPdu;
    processPdu = new DisconnectedMode(disconnect.getSourceServiceAccessPoint(),
        disconnect.getDestinationServiceAccessPoint(), 0).processPdu(connectionManager);
View Full Code Here

Examples of org.nfctools.llcp.pdu.Information

    AbstractProtocolDataUnit processPdu = new Connect(1, 32, new ServiceName(COM_ANDROID_NPP))
        .processPdu(connectionManager);
    assertTrue(processPdu.toString(), processPdu instanceof ConnectComplete);
    assertEquals(1, connectionManager.getOpenConnectionsSize());

    processPdu = new Information(32, 32, 0, 0, "Hello".getBytes()).processPdu(connectionManager);
    assertTrue(processPdu.toString(), processPdu instanceof ReceiveReady);
    ReceiveReady receiveReady = (ReceiveReady)processPdu;
    assertEquals(1, receiveReady.getReceived());
    assertEquals(0, receiveReady.getSend());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.