Examples of DFAgentDescription


Examples of jade.domain.FIPAAgentManagement.DFAgentDescription

    clean();
  }


  protected Object insert(Object name, Object fact) {
    DFAgentDescription desc = (DFAgentDescription)fact;
    if (desc.getLeaseTime() != null ) {
      entriesToDelete = true;
    }
    return super.insert(name, fact);
  }
View Full Code Here

Examples of jade.domain.FIPAAgentManagement.DFAgentDescription

    if (entriesToDelete) {
      ArrayList toBeRemoved = new ArrayList();
      Iterator iter = facts.values().iterator();   
      while(iter.hasNext()){
        DFAgentDescription dfd = (DFAgentDescription) iter.next();
        if(dfd.checkLeaseTimeExpired()) {
          toBeRemoved.add(dfd.getName());
        }
      }
      iter = toBeRemoved.iterator();
      while (iter.hasNext()) {
        facts.remove((AID) iter.next());
View Full Code Here

Examples of jade.domain.FIPAAgentManagement.DFAgentDescription

  }

  public static final boolean compare(Object template, Object fact) {

    try {
      DFAgentDescription templateDesc = (DFAgentDescription)template;
      DFAgentDescription factDesc = (DFAgentDescription)fact;
      // We must not return facts whose lease time has expired (no
      // matter if they match)
      if(factDesc.checkLeaseTimeExpired())
        return false;

      // Match name
      AID id1 = templateDesc.getName();
      if(id1 != null) {
        AID id2 = factDesc.getName();
        if((id2 == null) || (!matchAID(id1, id2)))
          return false;
      }

      // Match protocol set
      Iterator itTemplate = templateDesc.getAllProtocols();
      while(itTemplate.hasNext()) {
        String templateProto = (String)itTemplate.next();
        boolean found = false;
        Iterator itFact = factDesc.getAllProtocols();
        while(!found && itFact.hasNext()) {
          String factProto = (String)itFact.next();
          found = templateProto.equalsIgnoreCase(factProto);
        }
        if(!found)
          return false;
      }

      // Match ontologies set
      itTemplate = templateDesc.getAllOntologies();
      while(itTemplate.hasNext()) {
        String templateOnto = (String)itTemplate.next();
        boolean found = false;
        Iterator itFact = factDesc.getAllOntologies();
        while(!found && itFact.hasNext()) {
          String factOnto = (String)itFact.next();
          found = templateOnto.equalsIgnoreCase(factOnto);
        }
        if(!found)
          return false;
      }

      // Match languages set
      itTemplate = templateDesc.getAllLanguages();
      while(itTemplate.hasNext()) {
        String templateLang = (String)itTemplate.next();
        boolean found = false;
        Iterator itFact = factDesc.getAllLanguages();
        while(!found && itFact.hasNext()) {
          String factLang = (String)itFact.next();
          found = templateLang.equalsIgnoreCase(factLang);
        }
        if(!found)
          return false;
      }

      // Match services set
      itTemplate = templateDesc.getAllServices();
      while(itTemplate.hasNext()) {
        ServiceDescription templateSvc = (ServiceDescription)itTemplate.next();
        boolean found = false;
        Iterator itFact = factDesc.getAllServices();
        while(!found && itFact.hasNext()) {
          ServiceDescription factSvc = (ServiceDescription)itFact.next();
          found = compareServiceDesc(templateSvc, factSvc);
        }
        if(!found)
View Full Code Here

Examples of jade.domain.FIPAAgentManagement.DFAgentDescription

  /**
   *  Insert a new DFD object.
   *  @return the previous DFD (if any) corresponding to the same AID
   */
  protected Object insertSingle(Object name, Object fact) throws SQLException {
    DFAgentDescription dfd = (DFAgentDescription) fact;
    AID agentAID = dfd.getName();
    String agentName = agentAID.getName();
    DFAgentDescription dfdToReturn = null;
    String batchErrMsg = "";
   
    Connection conn = getConnectionWrapper().getConnection();
    PreparedStatements pss = getPreparedStatements();
    try {
View Full Code Here

Examples of jade.domain.FIPAAgentManagement.DFAgentDescription

   */
  protected Object removeSingle(Object name) throws SQLException {
    AID agentAID = (AID) name;
    String n = agentAID.getName();
   
    DFAgentDescription dfd = getDFD(n);
    if (dfd != null) {
      remove(n);
    }
   
    return dfd;
View Full Code Here

Examples of jade.domain.FIPAAgentManagement.DFAgentDescription

 
  /**
   Reconstruct the DFD corresponding to the given AID name (if any)
   */
  private DFAgentDescription getDFD(String aidN, Map allLanguages, Map allOntologies, Map allProtocols) throws SQLException {
    DFAgentDescription dfd = null;
    AID id = null;
   
    ResultSet rs = null;
    ResultSet rsS = null;
    String descrId = null;
   
    try{
      PreparedStatements pss = getPreparedStatements();
      // Check if there is a DFD corresponding to aidN and get lease time
      pss.stm_selLease.setString(1, aidN);
      rs = pss.stm_selLease.executeQuery();
      if (rs.next()) {
        dfd = new DFAgentDescription();
        id = getAID(aidN);
        dfd.setName(id);
        String sLease = rs.getString("lease");
        descrId = rs.getString("id");
        long lease = Long.parseLong(sLease);
        if (lease != -1) {
          dfd.setLeaseTime(new Date(lease));
        }
      }
      else {
        return null;
      }
      closeResultSet(rs);
     
      // Protocols
      loadProtocols(descrId, dfd, allProtocols);   
     
      // Languages
      loadLanguages(descrId, dfd, allLanguages);
     
      // Ontologies
      loadOntologies(descrId, dfd, allOntologies);
     
      // Services
      pss.stm_selServices.setString(1, descrId);
      rs = pss.stm_selServices.executeQuery();
      while(rs.next()) {
        ServiceDescription sd = new ServiceDescription();
        String serviceId = rs.getString("id");
        sd.setName(rs.getString("sname"));
        sd.setType(rs.getString("stype"));
        sd.setOwnership(rs.getString("sownership"));
       
        // Service protocols
        pss.stm_selServiceProtocols.setString(1, serviceId);
        rsS = pss.stm_selServiceProtocols.executeQuery();
        while(rsS.next()){
          sd.addProtocols(rsS.getString(PROTOCOL));
       
        closeResultSet(rsS);
       
        // Service languages
        pss.stm_selServiceLanguages.setString(1, serviceId);
        rsS = pss.stm_selServiceLanguages.executeQuery();
        while(rsS.next()){
          sd.addOntologies(rsS.getString(ONTOLOGY));
       
        closeResultSet(rsS);
       
        // Service ontologies
        pss.stm_selServiceOntologies.setString(1, serviceId);
        rsS = pss.stm_selServiceOntologies.executeQuery();
        while(rsS.next()){
          sd.addLanguages(rsS.getString(LANGUAGE));
        }
        closeResultSet(rsS);
       
        // Service properties
        pss.stm_selServiceProperties.setString(1, serviceId);
        rsS = pss.stm_selServiceProperties.executeQuery();
        while(rsS.next()){
          Property prop = new Property();
          prop.setName(rsS.getString("propkey"));
          String objStrVal = rsS.getString("propval_obj");
          String strStrVal = rsS.getString("propval_str");
          Object value = ( objStrVal == null )? strStrVal : deserializeObj(objStrVal);
          prop.setValue(value);
          sd.addProperties(prop);
        }
       
        dfd.addServices(sd);
      }
    }
    catch (SQLException sqle) {
      // Let it through
      throw sqle;
View Full Code Here

Examples of jade.domain.FIPAAgentManagement.DFAgentDescription

     {
       dfdAgent = dfd;
       newAID = dfd.getName();
     }
    else
     dfdAgent = new DFAgentDescription();
    
    JPanel p = new JPanel();
    JPanel main = new JPanel();
 
    JLabel l;
    JPanel bPane;
    JButton AIDButton;
   
    main.setLayout(new BoxLayout(main, BoxLayout.Y_AXIS));
   
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
    Border raised = BorderFactory.createRaisedBevelBorder();
    main.setBorder(raised);
   
    // Agent name
    main.add(Box.createRigidArea(new Dimension(300,5)));

    l = new JLabel("Agent-name:");
    l.setPreferredSize(new Dimension(80,26));
    p.add(l);
    p.add(Box.createHorizontalGlue());
    agentName = new JTextField();
    agentName.setEditable(false);
    agentName.setPreferredSize(new Dimension (250, 26));
    agentName.setMinimumSize(new Dimension(250,26));
    agentName.setMaximumSize(new Dimension(250,26));
    agentName.setBackground(Color.white);
    AID aidtemp = dfdAgent.getName();
    if (aidtemp == null)
      agentName.setText("");
    else
      agentName.setText(aidtemp.getName());
   
    AIDButton = new JButton(editable ? "Set":"View");
   
    AIDButton.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e)
      {
        String command = e.getActionCommand();
        AIDGui guiSender = new AIDGui(dlgParent);
     
        if(command.equals("View"))
          guiSender.ShowAIDGui(dfdAgent.getName(), false,false);
        else
          if(command.equals("Set"))
            {
             
              newAID = guiSender.ShowAIDGui(dfdAgent.getName(),true,checkSlots);
             
              if (newAID != null)
              { 
                agentName.setText(newAID.getName());
                dfdAgent.setName(newAID);
              }
            }
         
      }
    });
  
    p.add(AIDButton);
    p.add(agentName);
    main.add(p);
    main.add(Box.createRigidArea(new Dimension (0,3)));
   
    // Ontologies
    JPanel pOntologies = new JPanel();
    pOntologies.setLayout(new BorderLayout());
    pOntologies .setBorder(BorderFactory.createTitledBorder("Ontologies"));
    ontologiesListPanel = new VisualStringList(dfdAgent.getAllOntologies(),dlgParent);
    ontologiesListPanel.setDimension(new Dimension(400,45));
    ontologiesListPanel.setEnabled(editable);
    pOntologies.add(ontologiesListPanel);
     main.add(pOntologies);
    main.add(Box.createRigidArea(new Dimension (0,3)));
   
    // Languages
    JPanel pLanguages = new JPanel();
    pLanguages.setLayout(new BorderLayout());
    pLanguages .setBorder(BorderFactory.createTitledBorder("Languages"));
    languagesListPanel = new VisualStringList(dfdAgent.getAllLanguages(),dlgParent);
    languagesListPanel.setDimension(new Dimension(400,45));
    languagesListPanel.setEnabled(editable);
    pLanguages.add(languagesListPanel);
    main.add(pLanguages);
    main.add(Box.createRigidArea(new Dimension (0,3)));
   
    // Interaction protocols
    JPanel pProtocols = new JPanel();
    pProtocols .setLayout(new BorderLayout())
    pProtocols .setBorder(BorderFactory.createTitledBorder("Interaction-protocols"));
    protocolsListPanel = new VisualStringList(dfdAgent.getAllProtocols(),dlgParent);
    protocolsListPanel.setDimension(new Dimension(400,45));
    protocolsListPanel.setEnabled(editable);
    pProtocols.add(protocolsListPanel);
    main.add(pProtocols);
    main.add(Box.createRigidArea(new Dimension (0,3)));
  
    // Services list
    JPanel pServices = new JPanel();
    pServices.setBorder(BorderFactory.createTitledBorder("Agent services"));
    servicesListPanel = new VisualServicesList(dfdAgent.getAllServices(),dlgParent);
    servicesListPanel.setDimension(new Dimension(400,45));
    servicesListPanel.setEnabled(editable);
    servicesListPanel.setCheckMandatorySlots(checkMandatorySlots);
    pServices.add(servicesListPanel);
    main.add(pServices);
         
              /* lease-time panel
               * The duration or time at which the lease time for this registration
               * will expire. The default value of lease time is assumed to be
               * unlimeted
               */
               JPanel pLeaseTime = new JPanel();
              
              
               pLeaseTime.setEnabled(editable);
               pLeaseTime.setToolTipText("The duration at which the lease for this registration will expire");
              
               pLeaseTime.setSize(400, 45);
               pLeaseTime.setBorder(BorderFactory.createTitledBorder("Lease Time"));
               java.util.Date dleasetime = dfdAgent.getLeaseTime();
               if(dleasetime == null) {
                    textFieldLeaseTime = new JTextField("unlimited");
               } else {
                    textFieldLeaseTime = new JTextField(dleasetime.toString());
               }
               textFieldLeaseTime.setPreferredSize(new Dimension(335,26));
               textFieldLeaseTime.setMinimumSize(new Dimension(335,26));
               textFieldLeaseTime.setMaximumSize(new Dimension(335,26));

               textFieldLeaseTime.setEnabled(false);
              
               // add 2 buttons: one to set the date and the second to set the time
               // of the lease-time unlimeted
              
               setLTDateb = new JButton("Set");
               setLTDateb.setEnabled(editable);
               setLTDateb.setToolTipText("Set the date at which the lease time will expire");
              
               pLeaseTime.add(setLTDateb);
               pLeaseTime.add(textFieldLeaseTime);
               // when the button setLT is presse the dialog jade.gui.TimeChooser
               // is shown to set the date
               // this is value is used to set the value of DFAgentDescription returned
               // by the dialog (name of var is out see below)
               absDateLeaseTime = dfdAgent.getLeaseTime();
               setLTDateb.addActionListener(this);
               // when the button 'unlimited is pressed set the lease time to
               // the default value and the update the text field that shows
               // the value of the lease time
            
              
               main.add(pLeaseTime);
         
    getContentPane().add(main,BorderLayout.NORTH);
     
    // OK BUTTON
    bPane = new JPanel();
    bPane.setLayout(new BoxLayout(bPane, BoxLayout.X_AXIS));
    JButton bOK = new JButton("OK");
    bOK.addActionListener( new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {   
        String param = (String) e.getActionCommand();
        if (param.equals("OK"))
          { // the user pressed the OK button
            if(editable)
            { // if it is editable then I have to collect all data in the GUI and create a DFAgentDescription to return to the caller
              out = new DFAgentDescription();
             
              if(checkSlots)
                //AID
                if (newAID == null) //newAID was set when the "Set" button was pressed
                {
View Full Code Here

Examples of jade.domain.FIPAAgentManagement.DFAgentDescription

    if(constraints == null) //pressed the cancel button
      return;
     
    DFAgentDscDlg dlg = new DFAgentDscDlg((Frame) gui);
 
    DFAgentDescription editedDfd = dlg.ShowDFDGui(null,true,false); //checkMandatorySlots = false

    //If no df is selected, the df of the platform is used.
    if (editedDfd != null)
    { 
      GuiEvent ev = new GuiEvent((Object)gui,DFGUIAdapter.SEARCH);
View Full Code Here

Examples of jade.domain.FIPAAgentManagement.DFAgentDescription

  public void actionPerformed(ActionEvent e)
  {
 
    gui.setTab("Federate",null);
 
    DFAgentDescription editedDfd ;
    DFAgentDescription dfd = gui.myAgent.getDescriptionOfThisDF();
    AIDGui insertDlg = new AIDGui(gui);
    insertDlg.setTitle("Insert the AID of the DF with which federate");
    AID parent = insertDlg.ShowAIDGui(null,true,true);
   
    if (parent != null)
View Full Code Here

Examples of jade.domain.FIPAAgentManagement.DFAgentDescription

 
  public void actionPerformed(ActionEvent e)
  { 
    AID df;
    DFAgentDscDlg dlg = new DFAgentDscDlg((Frame) gui);
    DFAgentDescription editedDfd = dlg.ShowDFDGui(null,true,true);
 
    if (editedDfd != null)
    {
      int kind = gui.kindOfOperation();
   
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.