Skip to content

Commit

Permalink
Merge pull request #39 from AOT-Technologies/feature/update-lob
Browse files Browse the repository at this point in the history
Download and Search functionality
  • Loading branch information
nagarajaPC-AOT authored Mar 27, 2024
2 parents 70972d1 + 138dabe commit 2c6e9cf
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
downloadDocumentSchema,
updateDocumentSchema,
} from 'src/validation-schemas/document_validation.schema';
import { Binary } from 'typeorm';
@Controller('documents')
export class DocumentsController {
constructor(
Expand All @@ -40,6 +41,7 @@ export class DocumentsController {
@Headers() auth,
) {
try {

let documentDetails = await this.fileService.uploadFile(
file,
body,
Expand All @@ -51,6 +53,7 @@ export class DocumentsController {
'CREATE',
documentDetails,
body,
file.buffer
);
const data = this.documentService.createDocument(formattedDocument);
return data;
Expand Down Expand Up @@ -85,6 +88,7 @@ export class DocumentsController {
'UPDATE',
documentDetails,
body,
file
);
return this.documentService.update(body.id, document);
} else {
Expand All @@ -108,7 +112,11 @@ export class DocumentsController {
let documentDetails = await this.documentService.findOne(
parseInt(param.id),
);

let dms = await documentDetails.dmsprovider;
if (dms == 4) {
return res.send(new Buffer(documentDetails.file));
}
if (dms === 2) {
doc_id = await documentDetails.name;
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Field, ObjectType, Directive, ID } from '@nestjs/graphql';
import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm';
import { Entity, PrimaryGeneratedColumn, Column, OneToMany, Binary } from 'typeorm';

//_____________________Custom Imports_____________________//
import { Cases } from './cases.entity';
import { Versions } from 'src/versions/entities/version.entity';
import { Blob } from 'buffer';

@Entity()
@ObjectType()
Expand All @@ -17,6 +18,9 @@ export class CaseDocuments {
@Field()
caseId: number;

@Column({ type: "bytea", nullable: false })
file: Buffer;

@Column({ nullable: true })
@Field({ nullable: true })
documentref: string;
Expand Down Expand Up @@ -63,4 +67,6 @@ export class CaseDocuments {
@OneToMany(() => Versions, (versions) => versions.documents)
@Field(() => [Versions], { nullable: true })
versions: Versions[];


}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,43 @@ export class TransformService {
}
};

transform = (dms, type, document, data) => {
transformDatabase = (type, data, file) => {
try {
switch (type) {
case 'CREATE':
return {
caseId: data.caseId,
documentref: '',
name: data.name,
desc: data.desc,
addedbyuserid: data.addedbyuserid,
creationdate: new Date(),
dmsprovider: 4,
latestversion: '',
isdeleted: false,
type: data?.type,
size: data?.size,
file: file,
};

case 'UPDATE':
return {
documentref: '',
desc: data.desc,
addedbyuserid: data.addedbyuserid,
dmsprovider: 4,
latestversion:'',
isdeleted: false,
file: file,
};
}
} catch (error) {
console.log(error);
throw new InternalServerErrorException();
}
};

transform = (dms, type, document, data, file) => {
try {
switch (dms) {
case '1':
Expand All @@ -115,6 +151,9 @@ export class TransformService {

case '3':
return this.transformAlfresco(type, document, data);

case '4':
return this.transformDatabase(type, data, file);
}
} catch (error) {
console.log(error);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable, NotFoundException,BadRequestException } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Brackets, Repository } from 'typeorm';
import { HttpStatus } from '@nestjs/common/enums';
import { HttpException } from '@nestjs/common/exceptions';

Expand Down Expand Up @@ -189,8 +189,16 @@ export class CasesService {
}
default :
const [Cases,totalCount] = await (this.caseRepository.createQueryBuilder("table")
// .where("LOWER(table.name) LIKE :title", { title: `%${ searchField.toLowerCase() }%` })
.where('table.isdeleted = :status', {status:false})
.where(new Brackets((qb) => {
qb.where("LOWER(table.issuetype) LIKE :issuetype", { issuetype: `%${ searchField.toLowerCase() }%` })
.orWhere("LOWER(table.contactid) LIKE :contactid", { contactid: `%${ searchField.toLowerCase() }%` })
.orWhere("LOWER(table.individualid) LIKE :individualid", { individualid: `%${ searchField.toLowerCase() }%` })
.orWhere("LOWER(table.caseowner) LIKE :caseowner", { caseowner: `%${ searchField.toLowerCase() }%` })
.orWhere("LOWER(table.city) LIKE :city", { city: `%${ searchField.toLowerCase() }%` })
.orWhere("LOWER(table.region) LIKE :region", { region: `%${ searchField.toLowerCase() }%` })
.orWhere("LOWER(table.phonenumber) LIKE :phonenumber", { phonenumber: `%${ searchField.toLowerCase() }%` })
})
).andWhere('table.isdeleted = :status', {status:false})
.andWhere('table.creationdate >= :start_at', { start_at: fromDate})
.andWhere('table.creationdate <= :end_at', { end_at: toDate})
.orderBy({[orderBy]: orderType}).take(take).skip(skip)
Expand Down
2 changes: 1 addition & 1 deletion app/caseflow_web/public/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ window["_env_"] = {


// default DMS
REACT_APP_CASEFLOW_DMS:3,
REACT_APP_CASEFLOW_DMS:4,

// application name
APPLICATION_NAME:'caseflow.ai',
Expand Down
72 changes: 69 additions & 3 deletions app/caseflow_web/src/components/AdvanedSearch/advancedSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
import { DatePicker } from "@mui/x-date-pickers/DatePicker";
import { GENERIC_NAME } from "../../apiManager/endpoints/config";
import { getContactsData } from "../../services/ContactService";
import { getIndividualsData } from "../../services/IndividualService";

export default function AdvancedSearch() {
const [searchField, setSearchField] = useState("");
Expand All @@ -37,6 +39,8 @@ export default function AdvancedSearch() {
const [documentSearch, setDocumentsearch] = useState(false);
const [caseSearch, setCasesearch] = useState(false);
const [lobSearch, setLobsearch] = useState(false);
const [contactSearch, setContactSearch] = useState(false);
const [individualSearch, setIndividualSearch] = useState(false);
const [fromDateForSearch, setFromDateForSearch] = useState(null);
const [toDateForSearch, setToDateForSearch] = useState(null);
const [showDate, setShowDate] = useState(false);
Expand All @@ -59,8 +63,8 @@ export default function AdvancedSearch() {
totalCount = totalCount + searchCaseResult.totalCount;
searchCaseResult?.Cases.map((element) => {
result.push({
title: element.id + " - " + element.name,
content: element.desc,
title: element.id + " - " + element.issuetype,
content: element.individualid,
subtitle: GENERIC_NAME,
link: "/private/cases/" + element.id + "/details",
imgIcon: require("../../assets/CasesIcon.png"),
Expand Down Expand Up @@ -107,6 +111,38 @@ export default function AdvancedSearch() {
});
});
}),
(allSearch || contactSearch) &&
getContactsData(
1,
searchField
).then((contacts) => {
totalCount = totalCount + contacts?.totalCount;
contacts?.CaseflowContacts?.map((element) => {
result.push({
title: element.id + " - " + element.firstname +" "+element.lastname,
content: element.phonenumber,
subtitle: "Contact",
link: "/private/contacts/" + element.id + "/details",
imgIcon: require("../../assets/ContactsIcon.png"),
});
});
}),
(allSearch || individualSearch) &&
getIndividualsData(
1,
searchField
).then((individuals) => {
totalCount = totalCount + individuals?.CaseflowIndividuals?.totalCount;
individuals?.CaseflowIndividuals?.map((element) => {
result.push({
title: element.id + " - " + element.firstname +" "+element.lastname,
content: element.phonenumber,
subtitle: "Individual",
link: "/private/individuals/" + element.id + "/details",
imgIcon: require("../../assets/AssignedIcon.png"),
});
});
}),
]);

dispatch(
Expand All @@ -118,7 +154,9 @@ export default function AdvancedSearch() {
setCasesearch(false);
setAllsearch(true);
setDocumentsearch(false);
setContactSearch(false);
setLobsearch(false);
setIndividualSearch(false);
setFromDateForSearch(null);
setToDateForSearch(null);
setShowDate(false);
Expand All @@ -134,6 +172,8 @@ export default function AdvancedSearch() {
documentSearch,
caseSearch,
lobSearch,
contactSearch,
individualSearch,
toDateForSearch,
]);

Expand Down Expand Up @@ -180,6 +220,8 @@ export default function AdvancedSearch() {
setCasesearch(false);
setDocumentsearch(false);
setLobsearch(false);
setIndividualSearch(false);
setContactSearch(false);
}

}}
Expand Down Expand Up @@ -212,7 +254,7 @@ export default function AdvancedSearch() {
}
label="Documents"
/>
<FormControlLabel
{/* <FormControlLabel
control={
<Checkbox
checked={lobSearch}
Expand All @@ -223,6 +265,30 @@ export default function AdvancedSearch() {
/>
}
label="Line of Bussiness"
/> */}
<FormControlLabel
control={
<Checkbox
checked={individualSearch}
onChange={() => {
setIndividualSearch(!individualSearch);
setAllsearch(false);
}}
/>
}
label="Individuals"
/>
<FormControlLabel
control={
<Checkbox
checked={contactSearch}
onChange={() => {
setContactSearch(!contactSearch);
setAllsearch(false);
}}
/>
}
label="Contacts"
/>
<FormControlLabel
control={
Expand Down
8 changes: 2 additions & 6 deletions app/caseflow_web/src/components/Cases/Cases.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,15 @@ const Cases = () => {
);
let searchResultCases = searchResult.Cases?.map((element) => {
return {
title: element.id + " - " + element.name,
content: element.desc,
title: element.id + " - " + element.issuetype,
content: element.individualid,
subtitle: GENERIC_NAME,
link: "/private/cases/" + element.id + "/details",
imgIcon: require("../../assets/CasesIcon.png"),
};
});

if (searchResultCases) {
console.log({
searchResultCases: searchResultCases,
totalCount: searchResult.totalCount,
});
dispatch(
setsearchCaseResult({
searchResult: searchResultCases,
Expand Down
Loading

0 comments on commit 2c6e9cf

Please sign in to comment.