Search in sources :

Example 11 with User

use of org.hisp.dhis.user.User in project dhis2-core by dhis2.

the class MetaDataImportAction method execute.

// -------------------------------------------------------------------------
// Action Implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
    strategy = strategy != null ? strategy : ImportStrategy.NEW_AND_UPDATES;
    User user = currentUserService.getCurrentUser();
    TaskId taskId = new TaskId(TaskCategory.METADATA_IMPORT, user);
    notifier.clear(taskId);
    InputStream in = StreamUtils.wrapAndCheckCompressionFormat(new FileInputStream(upload));
    MetadataImportParams importParams = createMetadataImportParams(taskId, strategy, atomicMode, dryRun).setFilename(uploadFileName);
    if ("csv".equals(importFormat)) {
        if (classKey != null && CSV_SUPPORTED_CLASSES.containsKey(classKey)) {
            scheduler.executeTask(new ImportMetaDataCsvTask(importService, csvImportService, schemaService, importParams, in, CSV_SUPPORTED_CLASSES.get(classKey)));
        }
    } else if ("gml".equals(importFormat)) {
        scheduler.executeTask(new ImportMetaDataGmlTask(gmlImportService, importParams, in));
    } else if ("json".equals(importFormat) || "xml".equals(importFormat)) {
        scheduler.executeTask(new ImportMetaDataTask(importService, schemaService, importParams, in, importFormat));
    }
    return SUCCESS;
}
Also used : User(org.hisp.dhis.user.User) TaskId(org.hisp.dhis.scheduling.TaskId) MetadataImportParams(org.hisp.dhis.dxf2.metadata.MetadataImportParams) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ImportMetaDataTask(org.hisp.dhis.importexport.action.util.ImportMetaDataTask) ImportMetaDataCsvTask(org.hisp.dhis.importexport.action.util.ImportMetaDataCsvTask) FileInputStream(java.io.FileInputStream) ImportMetaDataGmlTask(org.hisp.dhis.importexport.action.util.ImportMetaDataGmlTask)

Example 12 with User

use of org.hisp.dhis.user.User in project dhis2-core by dhis2.

the class SendMessagesAction method updateRecipients.

/**
     * 
     * @param recipientCheckBox
     */
private void updateRecipients(String recipientCheckBox) {
    recipient = new HashSet<>();
    if (recipientCheckBox != null) {
        String[] rcbArray = recipientCheckBox.split(",");
        for (int i = 0; i < rcbArray.length; i++) {
            rcbArray[i] = rcbArray[i].trim();
            User u = userService.getUser(Integer.parseInt(rcbArray[i]));
            recipient.add(u);
        }
    }
}
Also used : User(org.hisp.dhis.user.User)

Example 13 with User

use of org.hisp.dhis.user.User in project dhis2-core by dhis2.

the class GetSettingsAction method execute.

// -------------------------------------------------------------------------
// Action Implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
    // ---------------------------------------------------------------------
    // Get available locales
    // ---------------------------------------------------------------------
    availableLocales = new ArrayList<>(resourceBundleManager.getAvailableLocales());
    Collections.sort(availableLocales, new Comparator<Locale>() {

        @Override
        public int compare(Locale locale0, Locale locale1) {
            return locale0.getDisplayName().compareTo(locale1.getDisplayName());
        }
    });
    currentLocale = localeManager.getCurrentLocale();
    // ---------------------------------------------------------------------
    // Get settings for current user
    // ---------------------------------------------------------------------
    User user = currentUserService.getCurrentUser();
    Validate.notNull(user);
    firstName = user.getFirstName();
    surname = user.getSurname();
    phoneNumber = user.getPhoneNumber();
    email = user.getEmail();
    return SUCCESS;
}
Also used : Locale(java.util.Locale) User(org.hisp.dhis.user.User)

Example 14 with User

use of org.hisp.dhis.user.User in project dhis2-core by dhis2.

the class AddRecipientAction method updateRecipients.

/**
     * 
     * @param recipientCheckBox
     */
private void updateRecipients(String recipientCheckBox) {
    recipient = new HashSet<>();
    if (recipientCheckBox != null) {
        String[] rcbArray = recipientCheckBox.split(",");
        for (int i = 0; i < rcbArray.length; i++) {
            rcbArray[i] = rcbArray[i].trim();
            User u = userService.getUser(Integer.parseInt(rcbArray[i]));
            recipient.add(u);
        }
    }
}
Also used : User(org.hisp.dhis.user.User)

Example 15 with User

use of org.hisp.dhis.user.User in project dhis2-core by dhis2.

the class FindUserAction method updateRecipients.

/**
     * 
     * @param recipientCheckBox
     */
private void updateRecipients(String recipientCheckBox) {
    recipient = new HashSet<>();
    if (recipientCheckBox != null) {
        String[] rcbArray = recipientCheckBox.split(",");
        for (int i = 0; i < rcbArray.length; i++) {
            rcbArray[i] = rcbArray[i].trim();
            User u = userService.getUser(Integer.parseInt(rcbArray[i]));
            recipient.add(u);
        }
    }
}
Also used : User(org.hisp.dhis.user.User)

Aggregations

User (org.hisp.dhis.user.User)715 Test (org.junit.jupiter.api.Test)254 TransactionalIntegrationTest (org.hisp.dhis.TransactionalIntegrationTest)168 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)132 DataElement (org.hisp.dhis.dataelement.DataElement)85 ArrayList (java.util.ArrayList)79 List (java.util.List)78 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)63 HashSet (java.util.HashSet)62 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)59 UserGroup (org.hisp.dhis.user.UserGroup)53 Date (java.util.Date)51 Transactional (org.springframework.transaction.annotation.Transactional)49 HashMap (java.util.HashMap)46 Program (org.hisp.dhis.program.Program)44 DataSet (org.hisp.dhis.dataset.DataSet)43 UserAuthorityGroup (org.hisp.dhis.user.UserAuthorityGroup)43 ClassPathResource (org.springframework.core.io.ClassPathResource)41 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)38 Set (java.util.Set)37