Ejemplo n.º 1
0
  @OPERATION
  public void createRestaurant(int userID, int cuisine) {

    System.out.println("HERE!");

    AgentId aid = getOpUserId();
    ArtifactConfig cf = new ArtifactConfig(aid, cuisine);
    ArtifactId id = null;
    String name = "restaurant" + aid.getAgentName();
    // String[] s = aid.getAgentName().split("[agent|_]");

    Pattern p = Pattern.compile("[0-9]*");
    Matcher m = p.matcher(aid.getAgentName());
    String agNr = "";
    while (m.find()) {
      agNr = m.group();
      if (!agNr.isEmpty()) break;
    }
    // get
    String className = "org.aria.rlandri.user" + userID + ".Restaurant" + agNr;
    // System.out.println("~~~~~~~~~"+className);
    try {
      id = makeArtifact(name, className, cf);
    } catch (OperationException e) {
      System.out.println("EPIC FAIL");
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    signal(aid, "rest", id);
    // System.out.println("Artifact id: " + id);
    ArrayList<ArtifactId> al = restaurantTable.get(cuisine);
    al.add(id);
    // System.out.println(restaurantTable);
  }
Ejemplo n.º 2
0
 @OPERATION
 private void createSystemRestaurants() {
   AgentId aid = getOpUserId();
   System.out.println("CREATING SYSTEM RESTAURANTS " + aid);
   for (int cuisine = 0; cuisine < NUM_CUISINE; cuisine++) {
     for (int index = 0; index < 2; index++) {
       // if(cuisine==3) continue;
       ArtifactConfig cf = new ArtifactConfig(aid, cuisine);
       ArtifactId id = null;
       String name = "restaurant" + cuisine + "-" + index;
       try {
         id = makeArtifact(name, "org.aria.rlandri.Restaurant", cf);
       } catch (OperationException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
       // System.out.println("Artifact id: " + id);
       ArrayList<ArtifactId> al = restaurantTable.get(cuisine);
       al.add(id);
     }
   }
   // System.out.println(restaurantTable);
 }