Пример #1
0
 private java.lang.String askInterpreter(context.arch.storage.AttributeNameValues input) {
   context.arch.comm.DataObject result = server.askInterpreter(intHost, intPort, intId, input);
   context.arch.storage.AttributeNameValues atts =
       new context.arch.storage.AttributeNameValues(result);
   if (atts == null) {
     return null;
   } else {
     if (atts.numAttributeNameValues() == 0) {
       return new java.lang.String("There are no more demos to recommend.");
     }
   }
   java.lang.StringBuffer sb = new java.lang.StringBuffer();
   for (int i = 0; i++ < atts.numAttributeNameValues(); i++) {
     sb.append(atts.getAttributeNameValueAt(i).getValue() + ", ");
   }
   return sb.toString();
 }
Пример #2
0
 public context.arch.comm.DataObject handle(
     java.lang.String callback, context.arch.comm.DataObject data)
     throws context.arch.InvalidMethodException, context.arch.MethodException {
   if (callback.equals(SUBSCRIBER_ID + Constants.SPACER + WTourRegistration.UPDATE)) {
     demoInterests = new context.apps.Tour.DemoInterests();
     demoVisits = new context.apps.Tour.DemoVisits();
     context.arch.storage.AttributeNameValues atts =
         new context.arch.storage.AttributeNameValues(data);
     manu.enterScheduler(WTourRegistration.UPDATE, "1");
     interests =
         (java.lang.String) atts.getAttributeNameValue(WTourRegistration.INTERESTS).getValue();
     manu.exitScheduler(WTourRegistration.UPDATE, "1");
     context.arch.storage.AttributeNameValue att =
         atts.getAttributeNameValue(WTourRegistration.CONTACT_INFO);
     context.arch.storage.AttributeNameValues atts2 =
         (context.arch.storage.AttributeNameValues) att.getValue();
     manu.enterScheduler(WTourRegistration.UPDATE, "2");
     name = (java.lang.String) atts2.getAttributeNameValue(WTourRegistration.NAME).getValue();
     manu.exitScheduler(WTourRegistration.UPDATE, "2");
     affiliation =
         (java.lang.String) atts2.getAttributeNameValue(WTourRegistration.AFFILIATION).getValue();
     email = (java.lang.String) atts2.getAttributeNameValue(WTourRegistration.EMAIL).getValue();
     initialTime =
         new java.lang.Long(
             (java.lang.String)
                 atts.getAttributeNameValue(WTourRegistration.TIMESTAMP).getValue());
     context.arch.storage.AttributeNameValues input =
         new context.arch.storage.AttributeNameValues();
     input.addAttributeNameValue(WTourRegistration.INTERESTS, interests);
     input.addAttributeNameValue(
         Demos.DEMOS, demo.getDemos().toAttributeNameValues(), Attribute.STRUCT);
     java.lang.String result = askInterpreter(input);
   } else {
     if (callback.equals(SUBSCRIBER_ID + Constants.SPACER + WTourDemo.VISIT)) {
       manu.enterScheduler(WTourDemo.VISIT, "3");
       context.arch.storage.AttributeNameValues atts =
           new context.arch.storage.AttributeNameValues(data);
       manu.exitScheduler(WTourDemo.VISIT, "3");
       java.lang.String demourl =
           (java.lang.String) atts.getAttributeNameValue(WTourDemo.DEMO_URL).getValue();
       java.lang.String demoerurl =
           (java.lang.String) atts.getAttributeNameValue(WTourDemo.DEMOER_URL).getValue();
       manu.enterScheduler(WTourDemo.VISIT, "4");
       java.lang.String demoName =
           (java.lang.String) atts.getAttributeNameValue(WTourDemo.DEMO_NAME).getValue();
       manu.exitScheduler(WTourDemo.VISIT, "4");
       java.lang.String timestamp =
           (java.lang.String) atts.getAttributeNameValue(WTourDemo.TIMESTAMP).getValue();
       context.apps.Tour.DemoInterest demoInterest =
           new context.apps.Tour.DemoInterest(demoName, NO_INTEREST);
       demoInterests.addDemoInterest(demoInterest);
       demoVisits.addDemoVisit(demoName, demourl, demoerurl, timestamp);
       context.arch.storage.AttributeNameValues input =
           new context.arch.storage.AttributeNameValues();
       input.addAttributeNameValue(
           DemoInterests.DEMO_INTERESTS, demoInterests.toAttributeNameValues(), Attribute.STRUCT);
       input.addAttributeNameValue(WTourRegistration.INTERESTS, interests);
       input.addAttributeNameValue(
           Demos.DEMOS, demo.getDemos().toAttributeNameValues(), Attribute.STRUCT);
       java.lang.String result = askInterpreter(input);
     } else {
       if (callback.equals(SUBSCRIBER_ID + Constants.SPACER + WTourDemo.INTEREST)) {
         context.arch.storage.AttributeNameValues atts =
             new context.arch.storage.AttributeNameValues(data);
         manu.enterScheduler(WTourDemo.INTEREST, "5");
         java.lang.String interest =
             (java.lang.String) atts.getAttributeNameValue(WTourDemo.INTEREST_LEVEL).getValue();
         manu.exitScheduler(WTourDemo.INTEREST, "5");
         java.lang.String demoName =
             (java.lang.String) atts.getAttributeNameValue(WTourDemo.DEMO_NAME).getValue();
         manu.enterScheduler(WTourDemo.INTEREST, "6");
         demoInterests.addDemoInterest(demoName, interest);
         manu.exitScheduler(WTourDemo.INTEREST, "6");
         context.arch.storage.AttributeNameValues input =
             new context.arch.storage.AttributeNameValues();
         input.addAttributeNameValue(
             DemoInterests.DEMO_INTERESTS,
             demoInterests.toAttributeNameValues(),
             Attribute.STRUCT);
         input.addAttributeNameValue(WTourRegistration.INTERESTS, interests);
         input.addAttributeNameValue(
             Demos.DEMOS, demo.getDemos().toAttributeNameValues(), Attribute.STRUCT);
         java.lang.String result = askInterpreter(input);
         context.apps.Tour.DemoVisit dv = demoVisits.getDemoVisit(demoName);
         if (dv != null) {
           dv.setInterest(interest);
         }
       } else {
         if (callback.equals(SUBSCRIBER_ID + Constants.SPACER + WTourEnd.END)) {
           manu.enterScheduler(WTourEnd.END, "7");
           context.arch.storage.AttributeNameValues input =
               new context.arch.storage.AttributeNameValues();
           manu.exitScheduler(WTourEnd.END, "7");
           input.addAttributeNameValue(
               DemoInterests.DEMO_INTERESTS,
               demoInterests.toAttributeNameValues(),
               Attribute.STRUCT);
           input.addAttributeNameValue(WTourRegistration.INTERESTS, interests);
           input.addAttributeNameValue(
               Demos.DEMOS, demo.getDemos().toAttributeNameValues(), Attribute.STRUCT);
           manu.enterScheduler(WTourEnd.END, "8");
           java.lang.String result = askInterpreter(input);
           manu.exitScheduler(WTourEnd.END, "8");
           java.lang.StringBuffer message =
               new java.lang.StringBuffer(
                   name + ", thank you for visiting the FCL lab and taking our tour!\n\n");
           message.append("Following is a summary of your tour:\n\n");
           for (int i = 0; i < demoVisits.numDemoVisits(); i++) {
             context.apps.Tour.DemoVisit dv = demoVisits.getDemoVisitAt(i);
             message.append(
                 "At "
                     + (new java.util.Date(dv.getTime())).toString()
                     + ", you visited the "
                     + dv.getDemoName()
                     + " demo.\n");
             message.append(
                 "Your level of interest in this demo was: " + dv.getInterest() + ".\n");
             message.append(
                 "If you would like more information on this demo, please go to the demo's web page at\n");
             message.append(
                 dv.getDemoUrl()
                     + ", or go the demoer's web page at "
                     + dv.getDemoerUrl()
                     + ".\n\n");
           }
           message.append(
               "Based on your interests which you used to register with the tour guide program, we think\n");
           message.append("the following demos might also be interesting to you: \n" + result);
           context.arch.util.SendMail sm = new context.arch.util.SendMail();
           sm.sendMail(
               server.getHostAddress(),
               "study.cs.hku.hk",
               "*****@*****.**",
               email,
               "FCL Demo Trip Summary",
               message.toString());
         } else {
           throw new context.arch.InvalidMethodException(Error.UNKNOWN_CALLBACK_ERROR);
         }
       }
     }
   }
   return null;
 }