コード例 #1
0
  @Override
  public int save(T object) {
    if (!Interpretation.class.isAssignableFrom(clazz)
        && currentUserService.getCurrentUser() != null
        && SharingUtils.isSupported(clazz)) {
      BaseIdentifiableObject identifiableObject = (BaseIdentifiableObject) object;

      // TODO we might want to allow setting sharing props on save, but for now we null them out
      identifiableObject.setPublicAccess(null);
      identifiableObject.setUserGroupAccesses(new HashSet<UserGroupAccess>());

      if (identifiableObject.getUser() == null) {
        identifiableObject.setUser(currentUserService.getCurrentUser());
      }

      if (SharingUtils.canCreatePublic(currentUserService.getCurrentUser(), identifiableObject)) {
        if (SharingUtils.defaultPublic(clazz)) {
          String build =
              AccessStringHelper.newInstance()
                  .enable(AccessStringHelper.Permission.READ)
                  .enable(AccessStringHelper.Permission.WRITE)
                  .build();

          identifiableObject.setPublicAccess(build);
        } else {
          String build = AccessStringHelper.newInstance().build();
          identifiableObject.setPublicAccess(build);
        }
      } else if (SharingUtils.canCreatePrivate(
          currentUserService.getCurrentUser(), identifiableObject)) {
        identifiableObject.setPublicAccess(AccessStringHelper.newInstance().build());
      } else {
        AuditLogUtil.infoWrapper(
            log,
            currentUserService.getCurrentUsername(),
            object,
            AuditLogUtil.ACTION_CREATE_DENIED);
        throw new CreateAccessDeniedException(object.toString());
      }
    }

    AuditLogUtil.infoWrapper(
        log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_CREATE);
    return (Integer) sessionFactory.getCurrentSession().save(object);
  }
コード例 #2
0
  @Override
  public void mergeWith(IdentifiableObject other) {
    super.mergeWith(other);

    if (other.getClass().isInstance(this)) {
      Map map = (Map) other;

      user = map.getUser() == null ? user : map.getUser();
      longitude = map.getLongitude() == null ? longitude : map.getLongitude();
      latitude = map.getLatitude() == null ? latitude : map.getLatitude();
      zoom = map.getZoom() == null ? zoom : map.getZoom();

      mapViews.clear();
      mapViews.addAll(map.getMapViews());
    }
  }
コード例 #3
0
  @Override
  public void mergeWith(IdentifiableObject other) {
    super.mergeWith(other);

    if (other.getClass().isInstance(this)) {
      DataDictionary dataDictionary = (DataDictionary) other;

      description =
          dataDictionary.getDescription() == null ? description : dataDictionary.getDescription();
      region = dataDictionary.getRegion() == null ? region : dataDictionary.getRegion();

      removeAllDataElements();
      dataElements.addAll(dataDictionary.getDataElements());

      removeAllIndicators();
      indicators.addAll(dataDictionary.getIndicators());
    }
  }
コード例 #4
0
ファイル: ProgramStage.java プロジェクト: sunbiz/dhis2
  @Override
  public void mergeWith(IdentifiableObject other) {
    super.mergeWith(other);

    if (other.getClass().isInstance(this)) {
      ProgramStage programStage = (ProgramStage) other;

      description = programStage.getDescription();
      minDaysFromStart = programStage.getMinDaysFromStart();
      irregular = programStage.getIrregular();
      program = programStage.getProgram();
      dataEntryForm = programStage.getDataEntryForm();
      standardInterval = programStage.getStandardInterval();
      reportDateDescription = programStage.getReportDateDescription();
      autoGenerateEvent = programStage.isAutoGenerated();
      validCompleteOnly = programStage.getValidCompleteOnly();
      displayGenerateEventBox = programStage.getDisplayGenerateEventBox();
      captureCoordinates = programStage.getCaptureCoordinates();
      blockEntryForm = programStage.getBlockEntryForm();
      remindCompleted = programStage.getRemindCompleted();
      generatedByEnrollmentDate = programStage.getGeneratedByEnrollmentDate();
      allowGenerateNextVisit = programStage.getAllowGenerateNextVisit();
      openAfterEnrollment = programStage.getOpenAfterEnrollment();
      reportDateToUse = programStage.getReportDateToUse();
      preGenerateUID = programStage.getPreGenerateUID();

      programStageDataElements.clear();
      programStageDataElements.addAll(programStage.getProgramStageDataElements());

      programStageSections.clear();
      programStageSections.addAll(programStage.getProgramStageSections());

      reminders.clear();
      reminders.addAll(programStage.getReminders());
    }
  }