/* updateScholarDVs
  *
  * This is not currently used. It was
  * developed for 16a, but there is an
  * issue with casting and the java
  * persistence layer.
  * Leaving it here as a placeholder.
  *
  *
  * @author wbossons
  */
 public VDC updateScholarDVs(VDC scholarDV) {
   //
   String updateString =
       "update vdc set firstname = '"
           + scholarDV.getFirstName()
           + "', lastname='"
           + scholarDV.getLastName()
           + "', name='"
           + scholarDV.getName()
           + "', alias='"
           + scholarDV.getAlias()
           + "', affiliation='"
           + scholarDV.getAffiliation()
           + "', dtype = 'Scholar' where id = "
           + scholarDV.getId();
   Connection conn = null;
   PreparedStatement updateStatement = null;
   try {
     conn = dvnDatasource.getConnection();
     updateStatement = conn.prepareStatement(updateString);
     int rowcount = updateStatement.executeUpdate();
   } catch (java.sql.SQLException e) {
     // Do nothing, just return null.
   }
   em.flush();
   VDC scholardataverse = em.find(VDC.class, scholarDV.getId());
   return scholardataverse;
   //
 }
  /** 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);
  }