예제 #1
0
 public static final void evaluate(final PlayerContext pc) {
   if (pc == null) {
     return;
   }
   final Profile profile = pc.profile;
   final Set<Integer> achieved = profile.achievements;
   final int size = ALL.length;
   boolean any = false;
   for (int i = 0; i < size; i++) {
     final Integer key = Integer.valueOf(i);
     if (achieved.contains(key)) {
       continue;
     }
     final Achievement ach = ALL[i];
     if (ach.isMet(pc)) {
       achieved.add(key);
       final int award = ach.award;
       FurGuardiansGame.notify(
           pc, ach.getName() + ", " + award + " Gem bonus", new Gem(FurGuardiansGame.gemAchieve));
       pc.addGems(award);
       any = true;
     }
   }
   if (any) {
     profile.save();
   }
 }
  /**
   * Persist notifications
   *
   * @param pl Susbcriptors for each event
   * @param audits The events
   */
  private void createNotifications(
      List<Profile> pl, List<UGCAudit> audits, Map<String, Profile> actionOwnersCache) {
    if (pl == null || pl.size() == 0) {
      return;
    }

    for (UGCAudit currentAudit : audits) {
      UGC ugc = ugcRepository.findOne(currentAudit.getUgcId());
      if (ugc != null) {
        UGC.ModerationStatus modStatus = ugc.getModerationStatus();
        if (modStatus != UGC.ModerationStatus.SPAM && modStatus != UGC.ModerationStatus.TRASH) {
          for (Profile profile : pl) {
            if (log.isDebugEnabled()) {
              log.debug(
                  "Audit harvester creating notification event ROW "
                      + currentAudit.getRow()
                      + " for the subscriber: "
                      + profile.getUserName());
            }

            createNotification(profile, currentAudit, actionOwnersCache);
          }
        }
      }
    }
  }
예제 #3
0
 public ArrayList<String> getContactList(Profile profile) {
   ArrayList<String> contacts = new ArrayList<String>();
   try { // creates a SQL Statement object in order to execute the SQL insert command
     stmt = conn.createStatement();
     ResultSet result =
         stmt.executeQuery(
             "SELECT login FROM Profiles WHERE ProfileID IN "
                 + "(SELECT DISTINCT Friend2 FROM Friends WHERE Friend1 IN "
                 + "(SELECT ProfileID FROM Profiles "
                 + "WHERE (Login='******' AND isAccepted=TRUE)) UNION "
                 + "(SELECT DISTINCT Friend1 FROM Friends "
                 + "WHERE Friend2 IN (SELECT ProfileID FROM Profiles "
                 + "WHERE (Login='******' AND isAccepted=TRUE))))");
     while (result.next()) { // if result of the query is not empty
       contacts.add(result.getString(1));
     }
     stmt.close();
   } catch (SQLException e) {
     System.err.println(e.toString());
   }
   return contacts;
 }
 @Override
 public boolean canWrap(Node node, EnhGraph eg) {
   // node will support being an TransitiveProperty facet if it has rdf:type
   // owl:TransitiveProperty or equivalent
   Profile profile = (eg instanceof OntModel) ? ((OntModel) eg).getProfile() : null;
   return (profile != null) && profile.isSupported(node, eg, TransitiveProperty.class);
 }
예제 #5
0
 public String deleteFriendship(Profile friend1, Profile friend2) throws SQLException {
   String r = "Friendship deleted!";
   try {
     // creates a SQL Statement object in order to execute the SQL insert command
     stmt = conn.createStatement();
     stmt.execute(
         "DELETE FROM Friends WHERE "
             + "(Friend1 IN (SELECT ProfileID FROM Profiles "
             + "WHERE Login='******') AND "
             + "Friend2 IN (SELECT ProfileID FROM Profiles "
             + "WHERE Login='******')) "
             + "OR (Friend2 IN (SELECT ProfileID FROM Profiles "
             + "WHERE Login='******') AND "
             + "Friend1 IN (SELECT ProfileID FROM Profiles "
             + "WHERE Login='******'))");
     stmt.close();
     // System.out.println("Requête executée");
   } catch (SQLException e) {
     // System.err.println(e.toString());
     r = e.toString();
     throw e;
   }
   return r;
 }
예제 #6
0
  public static void main(String args[]) throws Exception {
    IAFProperties.setGraphicsOn(false);

    new Thread() {
      public void run() {
        String[] args1 = new String[4];
        args1[0] = "-port";
        args1[1] = "60000";
        args1[2] = "-file-dir";
        args1[3] = "jade/";
        jade.Boot.main(args1);
      }
    }.start();

    // Get a hold on JADE runtime
    jade.core.Runtime rt = jade.core.Runtime.instance();

    // Exit the JVM when there are no more containers around
    rt.setCloseVM(true);

    // Create a default profile
    Profile p = new ProfileImpl();
    p.setParameter("preload", "a*");
    p.setParameter(Profile.MAIN_PORT, "60000");
    p.setParameter(Profile.FILE_DIR, "jade/");

    // Waits for JADE to start
    boolean notConnected = true;

    while (notConnected) {
      try {
        Socket s = new Socket("localhost", Integer.parseInt("60000"));
        notConnected = false;
      } catch (NumberFormatException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (UnknownHostException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (IOException e) {

        System.err.println("Error: " + e.getMessage());
        System.err.println("Reconnecting in one second");
        try {
          Thread.currentThread().sleep(1000);
        } catch (InterruptedException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        }
      }
    }

    // Create a new non-main container, connecting to the default
    // main container (i.e. on this host, port 1099)
    final jade.wrapper.AgentContainer ac = rt.createAgentContainer(p);

    {
    }
    MainInteractionManager.getInstance().setTitle("node ");
  }
예제 #7
0
 public static long timePassed(String name) {
   Profile p = profiles.get(name);
   if (p != null) {
     return p.timePassed();
   }
   return 0;
 }
 /**
  * Set the selected profile. The profile must already be contained in this profile manager.
  *
  * @param profile The profile to select
  */
 public void setSelected(Profile profile) {
   final Profile newSelected = fProfiles.get(profile.getID());
   if (newSelected != null && !newSelected.equals(fSelected)) {
     fSelected = newSelected;
     notifyObservers(SELECTION_CHANGED_EVENT);
   }
 }
예제 #9
0
 public static long getCount(String name) {
   Profile p = profiles.get(name);
   if (p != null) {
     return p.getCount();
   }
   return 0;
 }
  public static void update(Long idGroup, List<SqlRow> gpms) {
    Group group = Group.findById(idGroup);
    if (group == null) return;

    Ebean.beginTransaction();
    try {
      deleteForGroup(idGroup);

      Integer i = 1;
      for (SqlRow man : gpms) {
        Profile prof = Profile.lastProfileByGpmId(man.getLong("gpm"));
        if (prof == null) continue;

        CacheClassifier cc =
            new CacheClassifier(
                group,
                i++,
                prof.gpm.idGpm,
                prof.name,
                prof.image,
                (prof.gender == null) ? null : prof.gender.value,
                (prof.relationshipStatus == null) ? null : prof.relationshipStatus.status,
                prof.nFollowers);
        if (cc.name == null || cc.name.isEmpty())
          cc.name = Profile.getLastNotEmptyField(prof.gpm.id, "name");
        cc.save();
      }

      Ebean.commitTransaction();
    } finally {
      Ebean.endTransaction();
    }
  }
예제 #11
0
  public synchronized void addProfile(Profile p) {
    if (p.isStranded()) {
      stranded = true;
    }
    if (p.length() != params.getNumBins()) {
      throw new IllegalArgumentException(
          String.format(
              "Profile length %d doesn't" + " match bin-length %d",
              p.length(), params.getNumBins()));
    }

    if (isNormalized()) {
      throw new IllegalArgumentException("Can't add profile to a normalized MetaProfile");
    }

    if (profiles.contains(p)) {
      /*throw new IllegalArgumentException(String.format(
      "Can't add same profile %s to MetaProfile",
      p.getName()));*/
    } else {

      profiles.add(p);
      p.addProfileListener(this);
      for (int i = 0; i < values.length; i++) {
        values[i] += p.value(i);
        max = Math.max(max, values[i]);
        min = Math.min(min, values[i]);
      }

      dispatchChange(new ProfileEvent(this, p));
    }
  }
예제 #12
0
  public Profile getProfile(int profileID) {
    Profile profile = null;
    try { // creates a SQL Statement object in order to execute the SQL insert command
      stmt = conn.createStatement();
      ResultSet result =
          stmt.executeQuery("SELECT * FROM PROFILES WHERE ProfileID=" + profileID + "");
      if (result.next()) { // if result of the query is not empty
        profile =
            new Profile(
                result.getString(2),
                result.getString(3),
                result.getString(5),
                result.getBoolean(7));
        profile.setLogin(result.getString(4));
        profile.setStatus(Status.convertValue(result.getInt(8)));
        if (result.getString(6) != null) {
          profile.setEmail(result.getString(6));
        }
      }
      stmt.close();

    } catch (SQLException e) {
      System.err.println(e.toString());
    }
    return profile;
  }
  /** Test the Private Key setting. */
  @Test
  public void testCertificatePrivateKeyMissing() throws ProfileException {
    Profile profile = profiles.get(3);

    boolean result = profile.usePrivateKeyEscrow();

    assertFalse(result);
  }
  /**
   * Test the Private Key setting.
   *
   * <p><Keys>Store Private Keys</Keys>
   */
  @Test
  public void testCertificatePrivateKeyValid() throws ProfileException {
    Profile profile = profiles.get(1);

    boolean result = profile.usePrivateKeyEscrow();

    assertTrue(result);
  }
예제 #15
0
 public static void addCounter(String name, int count) {
   Profile p = profiles.get(name);
   if (p == null) {
     p = new Profile(name);
     profiles.put(name, p);
   }
   p.addCount(count);
 }
예제 #16
0
파일: World.java 프로젝트: robinp/libgdx
  /**
   * Take a time step. This performs collision detection, integration, and constraint solution.
   *
   * @param timeStep the amount of time to simulate, this should not vary.
   * @param velocityIterations for the velocity constraint solver.
   * @param positionIterations for the position constraint solver.
   */
  public void step(float dt, int velocityIterations, int positionIterations) {
    stepTimer.reset();
    // log.debug("Starting step");
    // If new fixtures were added, we need to find the new contacts.
    if ((m_flags & NEW_FIXTURE) == NEW_FIXTURE) {
      // log.debug("There's a new fixture, lets look for new contacts");
      m_contactManager.findNewContacts();
      m_flags &= ~NEW_FIXTURE;
    }

    m_flags |= LOCKED;

    step.dt = dt;
    step.velocityIterations = velocityIterations;
    step.positionIterations = positionIterations;
    if (dt > 0.0f) {
      step.inv_dt = 1.0f / dt;
    } else {
      step.inv_dt = 0.0f;
    }

    step.dtRatio = m_inv_dt0 * dt;

    step.warmStarting = m_warmStarting;

    // Update contacts. This is where some contacts are destroyed.
    tempTimer.reset();
    m_contactManager.collide();
    m_profile.collide = tempTimer.getMilliseconds();

    // Integrate velocities, solve velocity constraints, and integrate positions.
    if (m_stepComplete && step.dt > 0.0f) {
      tempTimer.reset();
      solve(step);
      m_profile.solve = tempTimer.getMilliseconds();
    }

    // Handle TOI events.
    if (m_continuousPhysics && step.dt > 0.0f) {
      tempTimer.reset();
      solveTOI(step);
      m_profile.solveTOI = tempTimer.getMilliseconds();
    }

    if (step.dt > 0.0f) {
      m_inv_dt0 = step.inv_dt;
    }

    if ((m_flags & CLEAR_FORCES) == CLEAR_FORCES) {
      clearForces();
    }

    m_flags &= ~LOCKED;
    // log.debug("ending step");

    m_profile.step = stepTimer.getMilliseconds();
  }
 /**
  * Check whether a user-defined profile in this profile manager already has this name.
  *
  * @param name The name to test for
  * @return Returns <code>true</code> if a profile with the given name exists
  */
 public boolean containsName(String name) {
   for (final Iterator<Profile> iter = fProfilesByName.iterator(); iter.hasNext(); ) {
     Profile curr = iter.next();
     if (name.equals(curr.getName())) {
       return true;
     }
   }
   return false;
 }
 /**
  * Get the names of all profiles stored in this profile manager, sorted alphabetically. Unless the
  * set of profiles has been modified between the two calls, the sequence is guaranteed to
  * correspond to the one returned by <code>getSortedProfiles</code>.
  *
  * @return All names, sorted alphabetically
  * @see #getSortedProfiles()
  */
 public String[] getSortedDisplayNames() {
   final String[] sortedNames = new String[fProfilesByName.size()];
   int i = 0;
   for (final Iterator<Profile> iter = fProfilesByName.iterator(); iter.hasNext(); ) {
     Profile curr = iter.next();
     sortedNames[i++] = curr.getName();
   }
   return sortedNames;
 }
예제 #19
0
 public static void addTime(String name) throws IOException {
   Profile p = profiles.get(name);
   if (p == null) {
     p = new Profile(name);
     profiles.put(name, p);
   }
   p.addTime();
   if (trace) reportProfile();
 }
 @Override
 protected Profile clone() throws CloneNotSupportedException {
   Profile p = (Profile) super.clone();
   if (values != null) {
     p.values = new ProfileValue[values.length];
     for (int i = 0; i < values.length; i++) p.values[i] = values[i].clone();
   }
   return p;
 }
예제 #21
0
 @Override
 @SuppressWarnings(value = "unchecked")
 public RunImportData constructRunImportData() {
   // Instanciate the DOM document
   DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
   docFactory.setIgnoringComments(true);
   docFactory.setIgnoringElementContentWhitespace(true);
   docFactory.setValidating(false);
   DocumentBuilder docBuilder;
   Document xmlDoc = null;
   try {
     docBuilder = docFactory.newDocumentBuilder();
     xmlDoc = docBuilder.parse(new InputSource("./LC480.xml"));
   } catch (Exception ex) {
     Exceptions.printStackTrace(ex);
   }
   // Setup the objects need for the import
   // Setup the Run object
   //            Run run = new RunImpl();
   // Set the run name and date
   Run run = new RunImpl();
   // Retrieve the xml file
   // For development purposes, just use an example xml file
   //        File lcRdmlFile = IOUtilities.openXmlFile("Lightcycler XML Data Import");
   //        if (lcRdmlFile == null) {
   //            return null;
   //        }
   // Setup the profile arraylists
   ArrayList<SampleProfile> sampleProfileList = Lists.newArrayList();
   ArrayList<CalibrationProfile> calbnProfileList = Lists.newArrayList();
   // Determine the strandedness of the majority of the Targets...too bad that this is not provided
   // by the instrument
   TargetStrandedness targetStrandedness = RunImportUtilities.isTheTargetSingleStranded();
   // Get the all of the profile nodes
   NodeList profileNodeList = xmlDoc.getElementsByTagName("series");
   // Cycle through all of the profile nodes
   for (int i = 0; i < profileNodeList.getLength(); i++) {
     // TODO determine whether this profile is sample or calibration
     Profile profile = createProfileType(run);
     Element profileElement = (Element) profileNodeList.item(i);
     String wellLabel = profileElement.getAttribute("title");
     // TODO parse the well label, sample and amplicon name from the wellLabel
     NodeList cycleList = profileElement.getElementsByTagName("point");
     // Collect and set the Fc reading
     profile.setFcReadings(retrieveFcReadings(cycleList));
     if (CalibrationProfile.class.isAssignableFrom(profile.getClass())) {
       CalibrationProfile calProfile = (CalibrationProfile) profile;
       calbnProfileList.add(calProfile);
     } else {
       SampleProfile sampleProfile = (SampleProfile) profile;
       sampleProfileList.add(sampleProfile);
     }
   }
   return null;
 }
예제 #22
0
 /**
  * Write the XML representation of this object
  *
  * @param writer
  * @param indent
  * @see XMLwriter
  */
 public void toXML(XMLWriter writer, int indent) {
   for (Profile p : mProfiles) {
     p.toXML(writer, indent + 1);
   }
   for (MetaData m : mMetadata) {
     m.toXML(writer, indent + 1);
   }
   for (PFN f : mPFNs) {
     f.toXML(writer, indent + 1);
   }
 }
예제 #23
0
  public void menuSelect(Menu menu, byte action) {
    switch (action) {
      case MENU_CONTACTMENU:
        if (uins.size() < 1) {
          return;
        }
        String uincm = (String) uins.elementAt(getCurrTextIndex());
        ContactItem cItemcm;
        if (profile.getItemByUIN(uincm) == null) {
          cItemcm = profile.createTempContact(uincm);
        } else {
          cItemcm = profile.getItemByUIN(uincm);
        }
        Menu mc = new Menu(this, (byte) 1);
        JimmUI.fillContactMenu(cItemcm, mc);
        Jimm.setPrevScreen(getVisibleObject());
        Jimm.setDisplay(mc);
        return;
        // #sijapp cond.if modules_DEBUGLOG is "true"#
      case MENU_DEBUGLOG:
        DebugLog.activateEx();
        return;
        // #sijapp cond.end#
      case MENU_OPTIONS:
        new OptionsEye(this);
        return;
      case MENU_COPYTEXT:
      case MENU_COPY_ALLTEXT:
        JimmUI.setClipBoardText(getCurrText(0, (action == MENU_COPY_ALLTEXT)));
        break;

      case MENU_COPYUIN:
        JimmUI.setClipBoardText((String) uins.elementAt(getCurrTextIndex()));
        break;

      case MENU_CLEAR:
        boolean needRemoveCommands = uins.size() > 0;
        idx = 0;
        uins = null;
        uins = new Vector();
        lock();
        if (uins.size() == 0 && needRemoveCommands) {
          removeCommandEx(JimmUI.cmdMenu);
        }
        clear();
        setColorScheme();
        unlock();
        break;
    }

    if (menu != null) {
      menu.back();
    }
  }
예제 #24
0
  public synchronized void clear() {
    for (Profile p : profiles) {
      p.removeProfileListener(this);
    }

    normalization = null;
    profiles.clear();
    min = max = 0.0;
    for (int i = 0; i < values.length; i++) {
      values[i] = 0.0;
    }
  }
예제 #25
0
  public void write(Profile profile) {

    com.aerospike.client.Key key = new com.aerospike.client.Key("test", "demo", profile.getId());
    Bin bin1 = new Bin("bin1", profile.toJSon());
    // Bin bin2 = new Bin("bin2", "value2");

    //    console.info("Put: namespace=%s set=%s key=%s bin1=%s value1=%s bin2=%s value2=%s",
    //          key.namespace, key.setName, key.userKey, bin1.name, bin1.value, bin2.name,
    // bin2.value);

    client.put(null, key, bin1);
  }
예제 #26
0
 public static void startTime(String name) throws IOException {
   if (trace) {
     out("startTime %s", name);
   }
   Profile p = profiles.get(name);
   if (p == null) {
     p = new Profile(name);
     profiles.put(name, p);
   }
   p.startTime();
   p.count++;
 }
예제 #27
0
  private void registerAction(String uin, String laction, String msg) {
    if (!profile.getBoolean(Profile.OPTION_ENABLE_MM)) {
      return;
    }
    boolean needAddCommands = uins.size() == 0;
    uins.addElement(uin);

    if (uins.size() >= 1 && needAddCommands) {
      addCommandEx(JimmUI.cmdMenu, MENU_TYPE_LEFT_BAR);
    }
    ContactItem contact = profile.getItemByUIN(uin);
    String action = ResourceBundle.getString(laction);
    int counter = idx++;
    String date = DateAndTime.getDateString(true, false);
    int color = getColor(COLOR_CAP2);
    lock();

    if (contact == null) {
      addBigText(
          "[" + counter + "]: " + uin + " (" + date + ")\n", color, Font.STYLE_BOLD, counter);
    } else {
      addBigText(
          "[" + counter + "]: " + contact.name + " (" + date + ")\n",
          color,
          Font.STYLE_BOLD,
          counter);
    }
    color = getColor(COLOR_TEXT);

    if (contact != null) {
      if ((contact.getIntValue(ContactItem.CONTACTITEM_STATUS) == ContactItem.STATUS_OFFLINE)
          && (action.equals(ResourceBundle.getString("read xtraz"))
              || action.equals(ResourceBundle.getString("read status message")))
          && !contact.getBooleanValue(ContactItem.CONTACTITEM_IS_TEMP)) {
        addBigText(ResourceBundle.getString("status_invisible"), color, Font.STYLE_PLAIN, counter);
        contact.setStatus(ContactItem.STATUS_INVISIBLE, true);
      } else {
        addBigText(action, color, Font.STYLE_PLAIN, counter);
      }
    } else {
      addBigText(action, color, Font.STYLE_PLAIN, counter);
    }

    if (msg != null) {
      doCRLF(counter);
      addBigText(msg, color, Font.STYLE_PLAIN, counter);
    }

    doCRLF(counter);
    unlock();
  }
  public static void main(String[] args) {
    ApplicationContext applicationContext =
        new ClassPathXmlApplicationContext("application-context.xml");
    Profile profile = (Profile) applicationContext.getBean("profile");

    System.out.println();
    profile.printName();
    profile.printAge();

    HelloWorld helloWorld = (HelloWorld) applicationContext.getBean("helloWorld");
    helloWorld.getMessage();

    ((AbstractApplicationContext) applicationContext).registerShutdownHook();
    ((AbstractApplicationContext) applicationContext).close();
  }
  /**
   * Display profile on window.
   *
   * @param p profile reference
   */
  private void showProfile(Profile p) {
    fullscreen_checkbox.setSelected(p.isFullscreen());
    vsync_checkbox.setSelected(p.isVsync());
    sound_checkbox.setSelected(p.isSound());
    music_checkbox.setSelected(p.isMusic());

    sound_slider.setValue((double) p.getSoundVolume());
    music_slider.setValue((double) p.getMusicVolume());

    sizex_field.setText(String.valueOf(p.getSizex()));
    sizey_field.setText(String.valueOf(p.getSizey()));

    user_combobox.setValue(p);
    resolution_combobox.setValue(findResolutionString(p.getResx(), p.getResy()));
  }
예제 #30
0
 @POST
 @Path("/profile")
 @Consumes(MediaType.APPLICATION_JSON)
 @Produces(MediaType.APPLICATION_JSON)
 public Response addProfile(Profile profile) {
   // http://localhost:8080/CitoServer/rest/profileService/add
   if (profile.getId() > 0) {
     dao.updateProfile(mapper.mapToDb(profile));
   } else {
     int id = dao.addProfile(mapper.mapToDb(profile));
     profile.setId(id);
   }
   ReturnId returnId = new ReturnId(profile.getId());
   return Response.status(200).entity(returnId).build();
 }