NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import {
all,
fork,
call,
put,
takeLatest,
takeEvery,
} from 'redux-saga/effects';
import { pushNewSnackbar } from 'components/UniversalSnackbar/actions';
import connectionService from 'services/connectionService';
import standardObjectService from 'services/standardObjectService';
import tagService from 'services/tagService';
import userService from 'services/userService';
import filterService from 'services/filterService';
import datasetService from 'services/datasetService';
import loadConfigService from 'services/loadConfigService';
import {
SEARCH_USERS_API_START,
GET_CONNECTIONS_DROPDOWN_API_START,
GET_STANDARD_OBJECT_DROPDOWN_API_START,
SEARCH_TAGS_API_START,
GET_DATASET_FILTERS_API_START,
CHECK_MILESTONES_API_START,
GET_RECURRING_LOAD_API_START,
GET_INITIAL_LOAD_CONFIG_API_START,
DOWNLOAD_SAMPLE_TEMPLATE,
UPLOAD_HEADER_FILE_API,
GET_HRC_SO_COLUMNS_API_START,
GET_PICKLIST_VALUES_API_START,
CHECK_DUPLICATE_DATASET_API_START,
} from './constants';
import {
searchUsersApiSuccess,
searchUsersApiFail,
getConnectionsDropdownApiFail,
getConnectionsDropdownApiSuccess,
getStandardObjectDropdownApiFail,
getStandardObjectDropdownApiSuccess,
searchTagsApiSuccess,
searchTagsApiFail,
getDatasetFiltersApiSuccess,
getDatasetFiltersApiFail,
checkMilestonesApiFail,
checkMilestonesApiSuccess,
getRecurringLoadApiFail,
getRecurringLoadApiSuccess,
getInitialLoadConfigApiFail,
getInitialLoadConfigApiSuccess,
setConfigureTab,
setColumnMappingFileColumn,
getHrcSoColumnsApiSuccess,
getHrcSoColumnsApiFail,
getPicklistValuesApiSuccess,
getPicklistValuesApiFail,
checkDuplicateDatasetApiSuccess,
checkDuplicateDatasetApiFail,
} from './actions';

// HANDLER
function* searchUserHandler(action) {
try {
const response = yield call(userService.searchUsers, action.payload);
if (response) {
yield put(searchUsersApiSuccess(response.ArrayList));
} else {
yield put(searchUsersApiFail());
}
} catch (error) {
yield put(searchUsersApiFail());
}
}

function* getStandardObjectDropdownApiHandler(action) {
try {
const response = yield call(
standardObjectService.getStandardObjectByConnection,
action.payload.connectionName,
);
if (response) {
yield put(getStandardObjectDropdownApiSuccess(response.ArrayList));
} else {
yield put(getStandardObjectDropdownApiFail());
}
} catch (e) {
yield put(getStandardObjectDropdownApiFail());
}
}
function* getConnectionsDropdownApiHandler(action) {
try {
const response = yield call(
connectionService.getConnectionsByDataSource,
action.payload,
{},
);
if (response?.connectionList) {
yield put(
getConnectionsDropdownApiSuccess(response.connectionList.connection),
);
} else {
yield put(getConnectionsDropdownApiFail());
}
} catch (e) {
yield put(getConnectionsDropdownApiFail());
}
}

function* searchTagHandler(action) {
try {
if (action.payload?.length >= 3) {
const response = yield call(tagService.searchTagByName, action.payload);

if (response) {
yield put(searchTagsApiSuccess(response.ArrayList));
} else {
yield put(searchTagsApiFail());
}
} else {
yield put(searchTagsApiSuccess([]));
}
} catch (error) {
yield put(searchTagsApiFail());
}
}

function* getDatasetFiltersApiHandler(action) {
try {
const response = yield call(
filterService.getDatasetFilters,
action.payload.dataSourceId,
action.payload.objectId,
);
if (response.fieldOperator.dcFilterMetadataDto) {
yield put(
getDatasetFiltersApiSuccess(response.fieldOperator.dcFilterMetadataDto),
);
} else {
yield put(getDatasetFiltersApiFail());
}
} catch (error) {
yield put(getDatasetFiltersApiFail());
}
}

function* checkMilestonesApiHandler(action) {
try {
const response = yield call(
datasetService.checkMilestones,
action.payload.dataSourceId,
action.payload.objectId,
action.payload.flowType,
);
if (response.milestoneResponse) {
const milestones: any = {};
Object.entries(response.milestoneResponse).forEach(
([key, value]: any) => {
milestones[key] = Boolean(value?.exist);
},
);
yield put(checkMilestonesApiSuccess(milestones));
if (milestones.filter) {
yield put(
getDatasetFiltersApiSuccess(
response.milestoneResponse.filter.fieldDataList,
),
);
}
if (milestones.recurringLoad) {
yield put(
getRecurringLoadApiSuccess(
response.milestoneResponse.recurringLoad.fieldDataList,
),
);
}
if (milestones.initialLoad) {
yield put(
getInitialLoadConfigApiSuccess(
response.milestoneResponse.initialLoad.fieldDataList,
),
);
}
if (milestones.configure) {
yield put(
setConfigureTab(response.milestoneResponse.configure.fieldDataList),
);
}
} else {
yield put(checkMilestonesApiFail());
}
} catch (error) {
yield put(checkMilestonesApiFail());
}
}

function* getDatasetRecurringLoadApiHandler(action) {
try {
const response = yield call(
loadConfigService.getRecurringLoad,
action.payload.dataSourceId,
action.payload.objectId,
action.payload.configType,
);
if (response.ArrayList) {
yield put(getRecurringLoadApiSuccess(response.ArrayList));
} else {
yield put(getRecurringLoadApiFail());
}
} catch (error) {
yield put(getRecurringLoadApiFail());
}
}

function* getInitialLoadConfigApihandler(action) {
try {
const response = yield call(
loadConfigService.getInitialLoadConfig,
action.payload,
);
if (response && response.ArrayList) {
yield put(getInitialLoadConfigApiSuccess(response.ArrayList));
} else {
yield put(getInitialLoadConfigApiFail());
}
} catch (error) {
yield put(getInitialLoadConfigApiFail());
}
}

function* downloadSampleTemplateHandler(action) {
try {
const res = yield call(
datasetService.downloadSampleTemplate,
action.payload,
);
if (res) {
yield put(
pushNewSnackbar({
options: { variant: 'error' },
message: `Unable to Download`,
}),
);
}
} catch (e) {
yield put(
pushNewSnackbar({
options: { variant: 'error' },
message: 'Network Error has occurred. Please try again',
}),
);
}
}

function* uploadHeaderFileApiHandler(action) {
try {
const formData = new FormData();
formData.append('file', action.payload);

const res = yield call(datasetService.uploadHeaderFile, formData);
if (res && res.ArrayList) {
yield put(setColumnMappingFileColumn(res.ArrayList));
yield put(
pushNewSnackbar({
options: { variant: 'success' },
message: `Uploaded Successfully`,
}),
);
} else {
yield put(
pushNewSnackbar({
options: { variant: 'error' },
message: `Unable to Upload`,
}),
);
}
} catch (e) {
yield put(
pushNewSnackbar({
options: { variant: 'error' },
message: 'Network Error has occurred. Please try again',
}),
);
}
}

function* getHrcSoColumnApiHandler(action) {
try {
const res = yield call(datasetService.getHrcSoColumn, action.payload);
if (res && res.ArrayList) {
yield put(getHrcSoColumnsApiSuccess(res.ArrayList));
} else {
yield put(getHrcSoColumnsApiFail());
yield put(
pushNewSnackbar({
options: { variant: 'error' },
message: `Unable to Fetch HRC SO Columns`,
}),
);
}
} catch (e) {
yield put(getHrcSoColumnsApiFail());
yield put(
pushNewSnackbar({
options: { variant: 'error' },
message: 'Network Error has occurred. Please try again',
}),
);
}
}

function* getPicklistValuesApiHandler() {
try {
const res = yield call(datasetService.getPicklistValues);
if (res && res.ArrayList) {
yield put(getPicklistValuesApiSuccess(res.ArrayList));
} else {
yield put(getPicklistValuesApiFail());
yield put(
pushNewSnackbar({
options: { variant: 'error' },
message: `Unable to Fetch Picklist Values`,
}),
);
}
} catch (e) {
yield put(getPicklistValuesApiFail());
yield put(
pushNewSnackbar({
options: { variant: 'error' },
message: 'Network Error has occurred. Please try again',
}),
);
}
}

function* checkDuplicateDatasetApiHandler(action) {
try {
yield put(
pushNewSnackbar({
options: { variant: 'inProgress' },
message: `Checking for any existing dataset with name ${action.payload.name} `,
}),
);
const res = yield call(
datasetService.checkDuplicateDataset,
action.payload,
);
if (res && res?.response) {
yield put(checkDuplicateDatasetApiSuccess(res?.response?.success));
yield put(
pushNewSnackbar({
options: { variant: !res?.response?.success ? 'success' : 'error' },
message: `Dataset ${res?.response?.status} with name ${action.payload.name}`,
}),
);
} else {
yield put(checkDuplicateDatasetApiFail());
yield put(
pushNewSnackbar({
options: { variant: 'error' },
message: `Check failed due to backend error `,
}),
);
}
} catch (e) {
yield put(checkDuplicateDatasetApiFail());
yield put(
pushNewSnackbar({
options: { variant: 'error' },
message: 'Network Error has occurred. Please try again',
}),
);
}
}

// WATCHER
function* searchUserHandlerWatcher() {
yield takeLatest(SEARCH_USERS_API_START, searchUserHandler);
}

function* getConnectionsDropdownWatcher() {
yield takeLatest(
GET_CONNECTIONS_DROPDOWN_API_START,
getConnectionsDropdownApiHandler,
);
}
function* getStandardObjectDropdownWatcher() {
yield takeLatest(
GET_STANDARD_OBJECT_DROPDOWN_API_START,
getStandardObjectDropdownApiHandler,
);
}

function* searchTagsApiWatcher() {
yield takeLatest(SEARCH_TAGS_API_START, searchTagHandler);
}

function* getDatasetFiltersApiWatcher() {
yield takeLatest(GET_DATASET_FILTERS_API_START, getDatasetFiltersApiHandler);
}

function* checkMilestonesApiWatcher() {
yield takeLatest(CHECK_MILESTONES_API_START, checkMilestonesApiHandler);
}

function* getDatasetRecurringLoadApiWatcher() {
yield takeLatest(
GET_RECURRING_LOAD_API_START,
getDatasetRecurringLoadApiHandler,
);
}

function* getInitialLoadConfigApiWatcher() {
yield takeLatest(
GET_INITIAL_LOAD_CONFIG_API_START,
getInitialLoadConfigApihandler,
);
}

function* getHrcSoColumnApiWatcher() {
yield takeLatest(GET_HRC_SO_COLUMNS_API_START, (action) =>
getHrcSoColumnApiHandler(action),
);
}

function* getPicklistValuesApiWatcher() {
yield takeLatest(GET_PICKLIST_VALUES_API_START, getPicklistValuesApiHandler);
}

function* uploadHeaderFileApiWatcher() {
yield takeLatest(UPLOAD_HEADER_FILE_API, (action) =>
uploadHeaderFileApiHandler(action),
);
}

function* downloadUserSampleTemplateWatcher() {
yield takeEvery(DOWNLOAD_SAMPLE_TEMPLATE, (action) =>
downloadSampleTemplateHandler(action),
);
}

function* checkDuplicateDatasetApiWatcher() {
yield takeLatest(CHECK_DUPLICATE_DATASET_API_START, (action) =>
checkDuplicateDatasetApiHandler(action),
);
}

// ROOT SAGA
export default function* datasetsSaga() {
yield all(
[
searchUserHandlerWatcher,
getConnectionsDropdownWatcher,
getStandardObjectDropdownWatcher,
searchTagsApiWatcher,
getDatasetFiltersApiWatcher,
checkMilestonesApiWatcher,
getDatasetRecurringLoadApiWatcher,
getInitialLoadConfigApiWatcher,
downloadUserSampleTemplateWatcher,
uploadHeaderFileApiWatcher,
getHrcSoColumnApiWatcher,
getPicklistValuesApiWatcher,
checkDuplicateDatasetApiWatcher,
].map(fork),
);
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.