Пример #1
0
  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);
  }
Пример #2
0
  /** 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);
  }
Пример #3
0
 public void updateDefaultTemplate(Long vdcId, Long templateId) {
   VDC vdc = em.find(VDC.class, vdcId);
   Template template = em.find(Template.class, templateId);
   vdc.setDefaultTemplate(template);
 }
Пример #4
0
  public void delete(Long vdcId) {
    VDC vdc = em.find(VDC.class, vdcId);
    em.refresh(vdc);
    List studyIds = new ArrayList();

    // Get the studyIds separately, to avoid a ConcurrentAccess Exception
    // (This is necessary because the studies are deleted in Native SQL)
    for (Iterator it = vdc.getOwnedStudies().iterator(); it.hasNext(); ) {
      Study elem = (Study) it.next();
      studyIds.add(elem.getId());
    }

    if (!studyIds.isEmpty()) {
      studyService.deleteStudyList(studyIds);
    }

    vdc.getOwnedStudies().clear();

    vdc.setRootCollection(null);

    for (Iterator it = vdc.getOwnedCollections().iterator(); it.hasNext(); ) {
      VDCCollection elem = (VDCCollection) it.next();
      elem.setParentCollection(null);
      elem.setOwner(null);
      // Remove this Collection from all linked VDCs
      for (Iterator itc = elem.getLinkedVDCs().iterator(); itc.hasNext(); ) {
        VDC linkedVDC = (VDC) itc.next();
        linkedVDC.getLinkedCollections().remove(elem);
      }
    }

    for (Iterator it = vdc.getLinkedCollections().iterator(); it.hasNext(); ) {
      VDCCollection elem = (VDCCollection) it.next();
      VDCCollection coll = em.find(VDCCollection.class, elem.getId());
      coll.getLinkedVDCs().remove(vdc);
    }

    for (Iterator it = vdc.getVdcGroups().iterator(); it.hasNext(); ) {
      VDCGroup vdcGroup = (VDCGroup) it.next();
      vdcGroup.getVdcs().remove(vdc);
    }

    for (Iterator it = vdc.getVdcRoles().iterator(); it.hasNext(); ) {
      VDCRole vdcRole = (VDCRole) it.next();
      VDCUser vdcUser = vdcRole.getVdcUser();
      vdcUser.getVdcRoles().remove(vdcRole);
    }

    if (vdc.isHarvestingDv()) {
      harvesterService.removeHarvestTimer(vdc.getHarvestingDataverse());
    }

    // If the vdc Default Template is in the list of dataverse templates
    // (not the Network Default Template), then remove the reference before deleting the dataverse.
    // If not removed, you will get a foreign key violation when the persistence logic deletes
    // the collection of templates.
    if (vdc.getTemplates().contains(vdc.getDefaultTemplate())) {
      vdc.setDefaultTemplate(null);
    }
    em.remove(vdc);
  }