/** scholar dataverse */
  private void createScholarDataverse(
      Long userId,
      String firstName,
      String lastName,
      String name,
      String affiliation,
      String alias,
      String dataverseType,
      List studyFields) {
    VDC sDV = new VDC();
    em.persist(sDV);
    sDV.setCreator(em.find(VDCUser.class, userId));
    sDV.setName(name);
    sDV.setFirstName(firstName);
    sDV.setLastName(lastName);
    sDV.setAffiliation(affiliation);
    sDV.setName(name);
    sDV.setAlias(alias);
    sDV.setDtype(dataverseType);
    sDV.setCreatedDate(DateUtil.getTimestamp());
    sDV.getRootCollection().setName(name);

    VDCNetwork vdcNetwork = vdcNetworkService.find(new Long(1));
    sDV.setDefaultTemplate(vdcNetwork.getDefaultTemplate());
    sDV.setHeader(vdcNetwork.getDefaultVDCHeader());
    sDV.setFooter(vdcNetwork.getDefaultVDCFooter());
    sDV.setRestricted(true);
    sDV.setDisplayAnnouncements(false);
    ArrayList advancedSearchFields = new ArrayList();
    ArrayList searchResultsFields = new ArrayList();

    for (Iterator it = studyFields.iterator(); it.hasNext(); ) {
      StudyField elem = (StudyField) it.next();
      if (elem.isAdvancedSearchField()) {
        advancedSearchFields.add(elem);
      }
      if (elem.isSearchResultField()) {
        searchResultsFields.add(elem);
      }
    }
    sDV.setAdvSearchFields(advancedSearchFields);
    sDV.setSearchResultFields(searchResultsFields);

    userService.addVdcRole(userId, findByAlias(sDV.getAlias()).getId(), roleService.ADMIN);
  }
  private void create(VDCUser user, String name, String alias, String dtype, List studyFields) {
    VDC addedSite = new VDC();
    addedSite.setCreator(user);

    VDCNetwork vdcNetwork = vdcNetworkService.find(new Long(1));
    addedSite.setDefaultTemplate(vdcNetwork.getDefaultTemplate());

    em.persist(addedSite);

    addedSite.setName(name);
    addedSite.setAlias(alias);
    addedSite.setDtype(dtype);
    addedSite.setCreatedDate(DateUtil.getTimestamp());
    addedSite.getRootCollection().setName(name);

    addedSite.setDefaultTemplate(vdcNetwork.getDefaultTemplate());
    addedSite.setHeader(vdcNetwork.getDefaultVDCHeader());
    addedSite.setFooter(vdcNetwork.getDefaultVDCFooter());
    addedSite.setRestricted(true);
    addedSite.setDisplayAnnouncements(false);
    ArrayList advancedSearchFields = new ArrayList();
    ArrayList searchResultsFields = new ArrayList();

    for (Iterator it = studyFields.iterator(); it.hasNext(); ) {
      StudyField elem = (StudyField) it.next();
      if (elem.isAdvancedSearchField()) {
        advancedSearchFields.add(elem);
      }
      if (elem.isSearchResultField()) {
        searchResultsFields.add(elem);
      }
    }
    addedSite.setAdvSearchFields(advancedSearchFields);
    addedSite.setSearchResultFields(searchResultsFields);

    userService.addVdcRole(
        user.getId(), findByAlias(addedSite.getAlias()).getId(), roleService.ADMIN);
  }
示例#3
0
文件: AddSitePage.java 项目: IQSS/dvn
  public String createScholarDataverse() {
    String dataversetype = dataverseType;

    String name = (String) dataverseName.getValue();
    String alias = (String) dataverseAlias.getValue();
    String strAffiliation = (String) affiliation.getValue();
    String strShortDescription = (String) shortDescription.getValue();
    Long userId = getVDCSessionBean().getLoginBean().getUser().getId();

    if (validateClassificationCheckBoxes()) {
      vdcService.createScholarDataverse(
          userId, firstName, lastName, name, strAffiliation, alias, dataversetype);
      VDC createdScholarDataverse = vdcService.findScholarDataverseByAlias(alias);
      saveClassifications(createdScholarDataverse);

      //  add default values to the VDC table and commit/set the vdc bean props
      createdScholarDataverse.setDisplayNetworkAnnouncements(
          getVDCRequestBean().getCurrentVdcNetwork().isDisplayAnnouncements());
      createdScholarDataverse.setDisplayAnnouncements(
          getVDCRequestBean().getCurrentVdcNetwork().isDisplayVDCAnnouncements());
      // on create if description is blank uncheck display flag
      if (strShortDescription.isEmpty()) {
        createdScholarDataverse.setDisplayAnnouncements(false);
      }
      createdScholarDataverse.setAnnouncements(
          getVDCRequestBean().getCurrentVdcNetwork().getDefaultVDCAnnouncements());
      createdScholarDataverse.setDisplayNewStudies(
          getVDCRequestBean().getCurrentVdcNetwork().isDisplayVDCRecentStudies());
      createdScholarDataverse.setAboutThisDataverse(
          getVDCRequestBean().getCurrentVdcNetwork().getDefaultVDCAboutText());
      createdScholarDataverse.setContactEmail(
          getVDCSessionBean().getLoginBean().getUser().getEmail());
      createdScholarDataverse.setDvnDescription(strShortDescription);
      createdScholarDataverse.setAnnouncements(
          strShortDescription); // also set default dv home page description from the the DVN home
                                // page short description
      VDCNetwork vdcNetwork;
      if (selectSubNetworkId != null && selectSubNetworkId > 0) {
        vdcNetwork = vdcNetworkService.findById(selectSubNetworkId);
        createdScholarDataverse.setVdcNetwork(vdcNetwork);
      } else {
        vdcNetwork = vdcNetworkService.findRootNetwork();
        createdScholarDataverse.setVdcNetwork(vdcNetwork);
      }
      // Set default template to subnet's default template
      Template template = vdcNetwork.getDefaultTemplate();
      createdScholarDataverse.setDefaultTemplate(template);

      vdcService.edit(createdScholarDataverse);

      String hostUrl = PropertyUtil.getHostUrl();
      VDCUser creator =
          userService.findByUserName(getVDCSessionBean().getLoginBean().getUser().getUserName());
      String toMailAddress = getVDCSessionBean().getLoginBean().getUser().getEmail();
      String siteAddress = hostUrl + "/dvn/dv/" + createdScholarDataverse.getAlias();

      mailService.sendAddSiteNotification(toMailAddress, name, siteAddress);

      // Refresh User object in LoginBean so it contains the user's new role of VDC administrator.
      getVDCSessionBean().getLoginBean().setUser(creator);
      getVDCRenderBean().getFlash().put("successMessage", "Your new dataverse has been created!");
      return "/site/AddSiteSuccessPage?faces-redirect=true&vdcId="
          + createdScholarDataverse.getId();
    } else {
      return null;
    }
  }