コード例 #1
0
  private static boolean matchFramework(
      ProjectCategory projectCategory, FrameworkSupportInModuleProvider framework) {

    FrameworkRole[] roles = framework.getRoles();
    if (roles.length == 0) return true;

    List<FrameworkRole> acceptable = Arrays.asList(projectCategory.getAcceptableFrameworkRoles());
    return ContainerUtil.intersects(Arrays.asList(roles), acceptable);
  }
コード例 #2
0
  /**
   * Creates draft copilot posting for the newly created project.
   *
   * @param directProject the direct project.
   * @return the created competition
   * @throws Exception if error happens when creating the contest.
   * @since 1.1
   */
  private SoftwareCompetition createCopilotDraftPosting(ProjectData directProject)
      throws Exception {
    SoftwareCompetition cp = new SoftwareCompetition();
    cp.setAssetDTO(getAssetDTOForNewSoftware());

    String name = getAssetDTO().getName();
    if (name == null || name.equals("")) {
      name = directProject.getName();
    }
    cp.getAssetDTO().setName(name);

    GregorianCalendar c = new GregorianCalendar();
    c.setTime(new Date());
    c.add(Calendar.DAY_OF_MONTH, 2);
    XMLGregorianCalendar contestStartDate =
        DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
    cp.getAssetDTO().setProductionDate(contestStartDate);

    // build the project header
    Project projectHeader = new Project();
    ProjectCategory projectCategory = new ProjectCategory();
    projectCategory.setId(29);
    projectCategory.setName("Copilot Posting");
    projectCategory.setProjectType(ProjectType.APPLICATION);
    projectHeader.setProjectCategory(projectCategory);
    projectHeader.setId(-1L);
    if (projectData.getProjectBillingAccountId() > 0) {
      projectHeader.setProperty(
          ProjectPropertyType.BILLING_PROJECT_PROJECT_PROPERTY_KEY,
          String.valueOf(projectData.getProjectBillingAccountId()));
    } else {
      projectHeader.setProperty(ProjectPropertyType.BILLING_PROJECT_PROJECT_PROPERTY_KEY, "0");
    }
    projectHeader.setProperty("Confidentiality Type", "public");
    projectHeader.setProperty("Copilot Cost", "0");
    projectHeader.setProperty("Project Name", name);
    projectHeader.setTcDirectProjectId(directProject.getProjectId());
    projectHeader.setTcDirectProjectName(directProject.getName());

    // set spec info - do not need spec review
    ProjectSpec projectSpec = new ProjectSpec();
    projectSpec.setProjectSpecId(0L);
    if (getProjectHeader() != null && getProjectHeader().getProjectSpec() != null) {
      projectSpec.setDetailedRequirements(
          getProjectHeader().getProjectSpec().getDetailedRequirements());
    }
    projectHeader.setProjectSpec(projectSpec);

    // add prize
    List<Prize> prizes = new ArrayList<Prize>();
    Prize firstPlace = new Prize();
    firstPlace.setNumberOfSubmissions(1);
    firstPlace.setPlace(1);
    firstPlace.setPrizeAmount(150);
    firstPlace.setProjectId(directProject.getProjectId());

    Prize secondPlace = new Prize();
    secondPlace.setNumberOfSubmissions(1);
    secondPlace.setPlace(2);
    secondPlace.setPrizeAmount(75);
    secondPlace.setProjectId(directProject.getProjectId());

    com.topcoder.management.project.PrizeType prizeType =
        new com.topcoder.management.project.PrizeType();
    prizeType.setDescription("Contest Prize");
    prizeType.setId(15L);

    firstPlace.setPrizeType(prizeType);
    prizes.add(firstPlace);
    secondPlace.setPrizeType(prizeType);
    prizes.add(secondPlace);

    projectHeader.setPrizes(prizes);
    projectHeader.setProperty(ProjectPropertyType.ADMIN_FEE_PROJECT_PROPERTY_KEY, "0");
    projectHeader.setProperty(ProjectPropertyType.COPILOT_COST_PROJECT_PROPERTY_KEY, "0");
    projectHeader.setProperty(ProjectPropertyType.DR_POINTS_PROJECT_PROPERTY_KEY, "0");
    projectHeader.setProperty(ProjectPropertyType.PAYMENTS_PROJECT_PROPERTY_KEY, "150");
    projectHeader.setProperty(ProjectPropertyType.FIRST_PLACE_COST_PROJECT_PROPERTY_KEY, "150");
    projectHeader.setProperty(ProjectPropertyType.RELIABILITY_BONUS_COST_PROJECT_PROPERTY_KEY, "0");
    projectHeader.setProperty(ProjectPropertyType.CHECKPOINT_BONUS_COST_PROJECT_PROPERTY_KEY, "0");
    projectHeader.setProperty(ProjectPropertyType.SPEC_REVIEW_COSTS_PROJECT_PROPERTY_KEY, "0");
    projectHeader.setProperty(ProjectPropertyType.SECOND_PLACE_COST_PROJECT_PROPERTY_KEY, "75");
    projectHeader.setProperty(ProjectPropertyType.REVIEW_COSTS_PROJECT_PROPERTY_KEY, "0");

    cp.setId(-1L);
    cp.setProjectHeader(projectHeader);

    initializeCompetition(cp);
    populateCompetition(cp);

    cp =
        getContestServiceFacade()
            .createSoftwareContest(
                DirectUtils.getTCSubjectFromSession(),
                cp,
                directProject.getProjectId(),
                null,
                null);

    return cp;
  }
コード例 #3
0
  // new TemplatesGroup selected
  public void projectTypeChanged() {
    TemplatesGroup group = getSelectedGroup();
    if (group == null || group == myLastSelectedGroup) return;
    myLastSelectedGroup = group;
    PropertiesComponent.getInstance().setValue(PROJECT_WIZARD_GROUP, group.getId());
    ModuleBuilder groupModuleBuilder = group.getModuleBuilder();

    mySettingsStep = null;
    myHeaderPanel.removeAll();
    if (groupModuleBuilder != null && groupModuleBuilder.getModuleType() != null) {
      mySettingsStep = groupModuleBuilder.modifyProjectTypeStep(this);
    }

    if (groupModuleBuilder == null || groupModuleBuilder.isTemplateBased()) {
      showTemplates(group);
    } else if (!showCustomOptions(groupModuleBuilder)) {
      List<FrameworkSupportInModuleProvider> providers =
          FrameworkSupportUtil.getProviders(groupModuleBuilder);
      final ProjectCategory category = group.getProjectCategory();
      if (category != null) {
        List<FrameworkSupportInModuleProvider> filtered =
            ContainerUtil.filter(
                providers,
                new Condition<FrameworkSupportInModuleProvider>() {
                  @Override
                  public boolean value(FrameworkSupportInModuleProvider provider) {
                    return matchFramework(category, provider);
                  }
                });
        // add associated
        Map<String, FrameworkSupportInModuleProvider> map =
            ContainerUtil.newMapFromValues(providers.iterator(), PROVIDER_STRING_CONVERTOR);
        Set<FrameworkSupportInModuleProvider> set =
            new HashSet<FrameworkSupportInModuleProvider>(filtered);
        for (FrameworkSupportInModuleProvider provider : filtered) {
          for (FrameworkSupportInModuleProvider.FrameworkDependency depId :
              provider.getDependenciesFrameworkIds()) {
            FrameworkSupportInModuleProvider dependency = map.get(depId.getFrameworkId());
            set.add(dependency);
          }
        }

        myFrameworksPanel.setProviders(
            new ArrayList<FrameworkSupportInModuleProvider>(set),
            new HashSet<String>(Arrays.asList(category.getAssociatedFrameworkIds())),
            new HashSet<String>(Arrays.asList(category.getPreselectedFrameworkIds())));
      } else {
        myFrameworksPanel.setProviders(providers);
      }
      getSelectedBuilder().addModuleConfigurationUpdater(myConfigurationUpdater);

      showCard(FRAMEWORKS_CARD);
    }

    myHeaderPanel.setVisible(myHeaderPanel.getComponentCount() > 0);
    // align header labels
    List<JLabel> labels = UIUtil.findComponentsOfType(myHeaderPanel, JLabel.class);
    int width = 0;
    for (JLabel label : labels) {
      int width1 = label.getPreferredSize().width;
      width = Math.max(width, width1);
    }
    for (JLabel label : labels) {
      label.setPreferredSize(new Dimension(width, label.getPreferredSize().height));
    }
    myHeaderPanel.revalidate();
    myHeaderPanel.repaint();

    updateSelection();
  }