@Test(groups = {PERSISTENCE, INTEGRATION})
  @SpecAssertions({
    @SpecAssertion(section = PASSIVATION_CAPABLE_DEPENDENCY_EE, id = "db"),
    @SpecAssertion(section = PASSIVATION_CAPABLE_DEPENDENCY_EE, id = "dc")
  })
  public void testPersistenceUnitAndContext() throws IOException, ClassNotFoundException {

    Profile profile = getContextualReference(Profile.class);

    assertNotNull(profile);
    assertNotNull(profile.getEntityManager());
    assertTrue(profile.getEntityManager().isOpen());
    assertNotNull(profile.getEntityManagerFactory());
    assertTrue(profile.getEntityManagerFactory().isOpen());

    String profileId = profile.getId();

    byte[] serializedProfile = passivate(profile);

    Profile profileCopy = (Profile) activate(serializedProfile);

    assertEquals(profileCopy.getId(), profileId);
    assertNotNull(profileCopy.getEntityManager());
    assertTrue(profileCopy.getEntityManager().isOpen());
    assertNotNull(profileCopy.getEntityManagerFactory());
    assertTrue(profileCopy.getEntityManagerFactory().isOpen());
  }
 @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();
 }
  public static void updateActiveProfilesValue(
      final NewLiferayPluginProjectOp op, final ElementList<Profile> profiles) {
    final StringBuilder sb = new StringBuilder();

    if (profiles.size() > 0) {
      for (Profile profile : profiles) {
        if (!profile.getId().empty()) {
          sb.append(profile.getId().content());
          sb.append(',');
        }
      }
    }

    // remove trailing ','
    op.setActiveProfilesValue(sb.toString().replaceAll("(.*),$", "$1"));
  }
  private void createNotification(
      Profile profile, UGCAudit currentAudit, Map<String, Profile> actionOwnersCache) {
    if (currentAudit.getProfileId() != null
        && !currentAudit.getProfileId().equalsIgnoreCase("anonymous")) {
      Notification notification = new Notification();
      // ACTION of the current JOB
      notification.setAction(profile.getSubscriptions().getAction());

      notification.setCreatedDate(new Date());
      notification.setRow(currentAudit.getRow());

      // FORMAT of the current JOB
      notification.setFormat(profile.getSubscriptions().getFormat());

      // FORMAT of the current JOB
      notification.setFrequency(profile.getSubscriptions().getFrequency());
      notification.setSubscriberUsername(profile.getUserName());

      notification.setSubscriberEmail(profile.getEmail());
      notification.setSubscriberId(profile.getId());
      notification.setTransmitedStatus(TransmittedStatus.PENDING);

      notification.setEvent(
          createEvent(currentAudit, getActionAuditOwner(actionOwnersCache, currentAudit)));

      this.notificationRepository.save(notification);
    }
  }
  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);
  }
  public void awrite(Profile profile) {

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

    aclient.put(
        null,
        new WriteListener() {
          @Override
          public void onSuccess(Key key) {}

          @Override
          public void onFailure(AerospikeException e) {}
        },
        key,
        bin1);
  }
  private Profile getActionAuditOwner(
      Map<String, Profile> actionOwnersCache, UGCAudit currentAudit) {
    Profile p = actionOwnersCache.get(currentAudit.getProfileId());
    if (p == null) {
      Profile currentProfile =
          this.profileRepository.findOne(new ObjectId(currentAudit.getProfileId()));
      p = new Profile();
      if (currentProfile != null) {
        p.setUserName(currentProfile.getUserName());
        p.setTenantName(currentProfile.getTenantName());
        p.setEmail(currentProfile.getEmail());
        p.setId(currentProfile.getId());
      }
      actionOwnersCache.put(currentAudit.getProfileId(), p);
    }

    return p;
  }
 /**
  * Adds information about defined profile.
  *
  * @param pomDescriptor The descriptor for the current POM.
  * @param model The Maven Model.
  * @param scannerContext The scanner context.
  */
 private void addProfiles(
     MavenPomDescriptor pomDescriptor, Model model, ScannerContext scannerContext) {
   List<Profile> profiles = model.getProfiles();
   Store store = scannerContext.getStore();
   for (Profile profile : profiles) {
     MavenProfileDescriptor mavenProfileDescriptor = store.create(MavenProfileDescriptor.class);
     pomDescriptor.getProfiles().add(mavenProfileDescriptor);
     mavenProfileDescriptor.setId(profile.getId());
     addProperties(mavenProfileDescriptor, profile.getProperties(), store);
     addModules(mavenProfileDescriptor, profile.getModules(), store);
     addPlugins(mavenProfileDescriptor, profile.getBuild(), scannerContext);
     addManagedPlugins(mavenProfileDescriptor, profile.getBuild(), scannerContext);
     addManagedDependencies(
         mavenProfileDescriptor,
         profile.getDependencyManagement(),
         scannerContext,
         ProfileManagesDependencyDescriptor.class);
     addProfileDependencies(mavenProfileDescriptor, profile.getDependencies(), scannerContext);
     addActivation(mavenProfileDescriptor, profile.getActivation(), store);
   }
 }
Exemple #9
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // 特定の行(position)のデータを得る
    Profile item = (Profile) getItem(position);

    // convertViewは使い回しされている可能性があるのでnullの時だけ新しく作る
    if (null == convertView) {
      convertView = layoutInflater_.inflate(R.layout.profilerow, null);
    }

    // 奇数行
    if (position % 2 == 0) {
      convertView.setBackgroundColor(Color.parseColor("#FFE0C0"));
    }
    // 偶数行
    else {
      convertView.setBackgroundColor(Color.parseColor("#FFEABF"));
    }

    // CustomDataのデータをViewの各Widgetにセットする
    // ID
    TextView textView_id;
    textView_id = (TextView) convertView.findViewById(R.id.id);
    textView_id.setText(item.getId());

    // 会社名
    TextView textView_company;
    textView_company = (TextView) convertView.findViewById(R.id.company);
    textView_company.setText(item.getCompany());

    // 役職
    TextView textView_yakushoku;
    textView_yakushoku = (TextView) convertView.findViewById(R.id.yakushoku);
    textView_yakushoku.setText(item.getYakushoku());

    // 名前
    TextView textView_name;
    textView_name = (TextView) convertView.findViewById(R.id.name);
    textView_name.setText(item.getName());

    // メールアドレス
    TextView textView_mail;
    textView_mail = (TextView) convertView.findViewById(R.id.mail);
    textView_mail.setText(item.getMail());

    // 電話番号
    TextView textView_phone;
    textView_phone = (TextView) convertView.findViewById(R.id.phone);
    textView_phone.setText(item.getPhone());

    // 20161008 yasui add start
    // よみがな
    TextView textView_nameKana;
    textView_nameKana = (TextView) convertView.findViewById(R.id.nameKana);
    textView_nameKana.setText(item.getNameKana());

    // 性別
    TextView textView_sex;
    textView_sex = (TextView) convertView.findViewById(R.id.sex);
    textView_sex.setText(Integer.toString(item.getSex()));

    // メモ
    TextView textView_memo;
    textView_memo = (TextView) convertView.findViewById(R.id.memo);
    textView_memo.setText(item.getMemo());
    // 20161008 yasui add end

    return convertView;
  }
Exemple #10
0
  private void computeCorrelations() {
    log.info("Filling repository with most correlated profiles");

    List<String> referenceProfile;

    for (AssayType assayType : AssayType.values()) {

      referenceProfile = getReferenceProfile(assayType);
      List<Profile> profiles = profileRepository.findByAssayType(assayType);

      String[] profileNames = new String[profiles.size()];
      double[][] distanceMatrix = new double[profiles.size()][profiles.size()];

      int i = 0;

      for (Profile profileA : profiles) {

        profileNames[i] = profileA.getId().toString();

        Double maxPearson = Double.MIN_VALUE;
        Profile maxProfile = profileA;

        int j = 0;

        for (Profile profileB : profiles) {
          if (profileA.equals(profileB)) {
            distanceMatrix[i][j] = 0;
            j++;
            continue;
          }

          double[] vectorA = profileA.getVector();
          double[] vectorB = profileB.getVector();

          PearsonsCorrelation pearson = new PearsonsCorrelation();
          Double pearsonCorrelation = pearson.correlation(vectorA, vectorB);

          if (pearsonCorrelation >= maxPearson) {
            maxPearson = pearsonCorrelation;
            maxProfile = profileB;
          }

          double[] profileAasDouble = UtilsTransform.intArrayToDouble(profileA.getColors());
          double[] profileBasDouble = UtilsTransform.intArrayToDouble(profileB.getColors());

          Double pearsonOfColors = pearson.correlation(profileAasDouble, profileBasDouble);
          distanceMatrix[i][j] = pearsonOfColors;
          j++;
        }

        profileA.setCorrelatedVector(maxProfile.getListWrapper());

        SortedSet<StringDouble> positivePeptides =
            UtilsStatistics.influentialPeptides(
                profileA.getVector(), maxProfile.getVector(), referenceProfile, true);

        profileA.setPositivePeptides(UtilsTransform.SortedSetToHTML(positivePeptides, false));

        DecimalFormat df = new DecimalFormat("0.0000");
        String peptideCorrelation = " <br/><br/><b style=\"color: #23527c;\">%s</b>";

        profileA.setPositiveCorrelation(
            maxProfile.toString() + String.format(peptideCorrelation, df.format(maxPearson)));

        profileRepository.save(profileA);
        i++;
      }
    }
  }