├── AirbusInventory ├── .browserslistrc ├── .editorconfig ├── .gitignore ├── README.md ├── angular.json ├── karma.conf.js ├── package-lock.json ├── package.json ├── src │ ├── app │ │ ├── LoginFormClass.ts │ │ ├── Product.ts │ │ ├── add-product │ │ │ ├── add-product.component.css │ │ │ ├── add-product.component.html │ │ │ ├── add-product.component.spec.ts │ │ │ └── add-product.component.ts │ │ ├── app.component.css │ │ ├── app.component.html │ │ ├── app.component.spec.ts │ │ ├── app.component.ts │ │ ├── app.module.ts │ │ ├── can-activate-guard.ts │ │ ├── dashboard │ │ │ ├── dashboard.component.css │ │ │ ├── dashboard.component.html │ │ │ ├── dashboard.component.spec.ts │ │ │ └── dashboard.component.ts │ │ ├── get-all-products │ │ │ ├── get-all-products.component.css │ │ │ ├── get-all-products.component.html │ │ │ ├── get-all-products.component.spec.ts │ │ │ └── get-all-products.component.ts │ │ ├── get-product-by-category │ │ │ ├── get-product-by-category.component.css │ │ │ ├── get-product-by-category.component.html │ │ │ ├── get-product-by-category.component.spec.ts │ │ │ └── get-product-by-category.component.ts │ │ ├── login-page │ │ │ ├── login-page.component.css │ │ │ ├── login-page.component.html │ │ │ ├── login-page.component.spec.ts │ │ │ └── login-page.component.ts │ │ ├── main-nav │ │ │ ├── main-nav.component.css │ │ │ ├── main-nav.component.html │ │ │ ├── main-nav.component.spec.ts │ │ │ └── main-nav.component.ts │ │ ├── services │ │ │ ├── authentication-service.service.spec.ts │ │ │ ├── authentication-service.service.ts │ │ │ ├── product.service.spec.ts │ │ │ ├── product.service.ts │ │ │ ├── router.service.spec.ts │ │ │ ├── router.service.ts │ │ │ ├── shared-service.service.spec.ts │ │ │ └── shared-service.service.ts │ │ ├── successful-dialog │ │ │ ├── successful-dialog.component.css │ │ │ ├── successful-dialog.component.html │ │ │ ├── successful-dialog.component.spec.ts │ │ │ └── successful-dialog.component.ts │ │ ├── un-successful-dialog │ │ │ ├── un-successful-dialog.component.css │ │ │ ├── un-successful-dialog.component.html │ │ │ ├── un-successful-dialog.component.spec.ts │ │ │ └── un-successful-dialog.component.ts │ │ └── update-product │ │ │ ├── update-product.component.css │ │ │ ├── update-product.component.html │ │ │ ├── update-product.component.spec.ts │ │ │ └── update-product.component.ts │ ├── assets │ │ └── airbus.webp │ ├── environments │ │ ├── environment.prod.ts │ │ └── environment.ts │ ├── favicon.ico │ ├── index.html │ ├── main.ts │ ├── polyfills.ts │ ├── styles.css │ └── test.ts ├── tsconfig.app.json ├── tsconfig.json └── tsconfig.spec.json ├── Problem Statement.PNG ├── README.md └── airbus-management-spring ├── .gitignore ├── .mvn └── wrapper │ ├── MavenWrapperDownloader.java │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── airbus │ │ └── management │ │ ├── AirbusManagementSpringApplication.java │ │ ├── config │ │ ├── JwtAuthenticationEntryPoint.java │ │ ├── JwtRequestFilter.java │ │ ├── JwtTokenUtil.java │ │ └── WebSecurityConfig.java │ │ ├── controller │ │ ├── JwtAuthenticationController.java │ │ └── MainController.java │ │ ├── exception │ │ └── ProductAlreadyExistsException.java │ │ ├── model │ │ ├── JwtResponse.java │ │ ├── Product.java │ │ └── User.java │ │ ├── repository │ │ └── ProductServiceRepository.java │ │ └── service │ │ ├── JwtUserDetailsService.java │ │ ├── ProductService.java │ │ └── ProductServiceImpl.java └── resources │ ├── application.properties │ └── templates │ └── schema.sql └── test └── java └── com └── airbus └── management ├── AirbusManagementSpringApplicationTests.java └── controller └── TestMainController.java /AirbusInventory/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. 18 | -------------------------------------------------------------------------------- /AirbusInventory/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /AirbusInventory/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | # Only exists if Bazel was run 8 | /bazel-out 9 | 10 | # dependencies 11 | /node_modules 12 | 13 | # profiling files 14 | chrome-profiler-events*.json 15 | 16 | # IDEs and editors 17 | /.idea 18 | .project 19 | .classpath 20 | .c9/ 21 | *.launch 22 | .settings/ 23 | *.sublime-workspace 24 | 25 | # IDE - VSCode 26 | .vscode/* 27 | !.vscode/settings.json 28 | !.vscode/tasks.json 29 | !.vscode/launch.json 30 | !.vscode/extensions.json 31 | .history/* 32 | 33 | # misc 34 | /.sass-cache 35 | /connect.lock 36 | /coverage 37 | /libpeerconnection.log 38 | npm-debug.log 39 | yarn-error.log 40 | testem.log 41 | /typings 42 | 43 | # System Files 44 | .DS_Store 45 | Thumbs.db 46 | -------------------------------------------------------------------------------- /AirbusInventory/README.md: -------------------------------------------------------------------------------- 1 | # AirbusInventory 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 12.2.3. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. 28 | -------------------------------------------------------------------------------- /AirbusInventory/angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "AirbusInventory": { 7 | "projectType": "application", 8 | "schematics": { 9 | "@schematics/angular:application": { 10 | "strict": true 11 | } 12 | }, 13 | "root": "", 14 | "sourceRoot": "src", 15 | "prefix": "app", 16 | "architect": { 17 | "build": { 18 | "builder": "@angular-devkit/build-angular:browser", 19 | "options": { 20 | "outputPath": "dist/AirbusInventory", 21 | "index": "src/index.html", 22 | "main": "src/main.ts", 23 | "polyfills": "src/polyfills.ts", 24 | "tsConfig": "tsconfig.app.json", 25 | "assets": [ 26 | "src/favicon.ico", 27 | "src/assets" 28 | ], 29 | "styles": [ 30 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", 31 | "src/styles.css" 32 | ], 33 | "scripts": [] 34 | }, 35 | "configurations": { 36 | "production": { 37 | "budgets": [ 38 | { 39 | "type": "initial", 40 | "maximumWarning": "500kb", 41 | "maximumError": "1mb" 42 | }, 43 | { 44 | "type": "anyComponentStyle", 45 | "maximumWarning": "2kb", 46 | "maximumError": "4kb" 47 | } 48 | ], 49 | "fileReplacements": [ 50 | { 51 | "replace": "src/environments/environment.ts", 52 | "with": "src/environments/environment.prod.ts" 53 | } 54 | ], 55 | "outputHashing": "all" 56 | }, 57 | "development": { 58 | "buildOptimizer": false, 59 | "optimization": false, 60 | "vendorChunk": true, 61 | "extractLicenses": false, 62 | "sourceMap": true, 63 | "namedChunks": true 64 | } 65 | }, 66 | "defaultConfiguration": "production" 67 | }, 68 | "serve": { 69 | "builder": "@angular-devkit/build-angular:dev-server", 70 | "configurations": { 71 | "production": { 72 | "browserTarget": "AirbusInventory:build:production" 73 | }, 74 | "development": { 75 | "browserTarget": "AirbusInventory:build:development" 76 | } 77 | }, 78 | "defaultConfiguration": "development" 79 | }, 80 | "extract-i18n": { 81 | "builder": "@angular-devkit/build-angular:extract-i18n", 82 | "options": { 83 | "browserTarget": "AirbusInventory:build" 84 | } 85 | }, 86 | "test": { 87 | "builder": "@angular-devkit/build-angular:karma", 88 | "options": { 89 | "main": "src/test.ts", 90 | "polyfills": "src/polyfills.ts", 91 | "tsConfig": "tsconfig.spec.json", 92 | "karmaConfig": "karma.conf.js", 93 | "assets": [ 94 | "src/favicon.ico", 95 | "src/assets" 96 | ], 97 | "styles": [ 98 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", 99 | "src/styles.css" 100 | ], 101 | "scripts": [] 102 | } 103 | } 104 | } 105 | } 106 | }, 107 | "defaultProject": "AirbusInventory" 108 | } 109 | -------------------------------------------------------------------------------- /AirbusInventory/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | jasmine: { 17 | // you can add configuration options for Jasmine here 18 | // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html 19 | // for example, you can disable the random execution with `random: false` 20 | // or set a specific seed with `seed: 4321` 21 | }, 22 | clearContext: false // leave Jasmine Spec Runner output visible in browser 23 | }, 24 | jasmineHtmlReporter: { 25 | suppressAll: true // removes the duplicated traces 26 | }, 27 | coverageReporter: { 28 | dir: require('path').join(__dirname, './coverage/AirbusInventory'), 29 | subdir: '.', 30 | reporters: [ 31 | { type: 'html' }, 32 | { type: 'text-summary' } 33 | ] 34 | }, 35 | reporters: ['progress', 'kjhtml'], 36 | port: 9876, 37 | colors: true, 38 | logLevel: config.LOG_INFO, 39 | autoWatch: true, 40 | browsers: ['Chrome'], 41 | singleRun: false, 42 | restartOnFileChange: true 43 | }); 44 | }; 45 | -------------------------------------------------------------------------------- /AirbusInventory/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "airbus-inventory", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "watch": "ng build --watch --configuration development", 9 | "test": "ng test", 10 | "lint": "ng lint", 11 | "e2e": "ng e2e" 12 | }, 13 | "private": true, 14 | "dependencies": { 15 | "@angular/animations": "~12.2.0", 16 | "@angular/cdk": "^12.2.6", 17 | "@angular/common": "~12.2.0", 18 | "@angular/compiler": "~12.2.0", 19 | "@angular/core": "~12.2.0", 20 | "@angular/flex-layout": "^12.0.0-beta.35", 21 | "@angular/forms": "~12.2.0", 22 | "@angular/material": "^12.2.6", 23 | "@angular/platform-browser": "~12.2.0", 24 | "@angular/platform-browser-dynamic": "~12.2.0", 25 | "@angular/router": "~12.2.0", 26 | "ng2-order-pipe": "^0.1.5", 27 | "ng2-search-filter": "^0.5.1", 28 | "rxjs": "~6.6.0", 29 | "tslib": "^2.3.0", 30 | "zone.js": "~0.11.4" 31 | }, 32 | "devDependencies": { 33 | "@angular-devkit/build-angular": "~12.2.3", 34 | "@angular/cli": "~12.2.3", 35 | "@angular/compiler-cli": "~12.2.0", 36 | "@types/jasmine": "~3.8.0", 37 | "@types/node": "^12.11.1", 38 | "jasmine-core": "~3.8.0", 39 | "karma": "~6.3.0", 40 | "karma-chrome-launcher": "~3.1.0", 41 | "karma-coverage": "~2.0.3", 42 | "karma-jasmine": "~4.0.0", 43 | "karma-jasmine-html-reporter": "~1.7.0", 44 | "typescript": "~4.3.5" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/LoginFormClass.ts: -------------------------------------------------------------------------------- 1 | export class LoginFormClass{ 2 | username:string; 3 | password:string; 4 | 5 | constructor(){ 6 | this.username=""; 7 | this.password=""; 8 | } 9 | } -------------------------------------------------------------------------------- /AirbusInventory/src/app/Product.ts: -------------------------------------------------------------------------------- 1 | export class Product{ 2 | productId:string; 3 | productName:string; 4 | productDescription:string; 5 | productCategory:string; 6 | units:number; 7 | 8 | constructor(){ 9 | this.productId=""; 10 | this.productName=""; 11 | this.productDescription=""; 12 | this.productCategory=""; 13 | this.units=0; 14 | } 15 | } -------------------------------------------------------------------------------- /AirbusInventory/src/app/add-product/add-product.component.css: -------------------------------------------------------------------------------- 1 | h1{ 2 | margin-top: 20px; 3 | text-align: center; 4 | color: black; 5 | } 6 | 7 | * { 8 | box-sizing: border-box; 9 | } 10 | 11 | input[type=text], select, textarea { 12 | width: 100%; 13 | padding: 12px; 14 | border: 1px solid #ccc; 15 | border-radius: 4px; 16 | resize: vertical; 17 | } 18 | 19 | input[type=number]{ 20 | width: 100%; 21 | padding: 12px; 22 | border: 1px solid #ccc; 23 | border-radius: 4px; 24 | resize: vertical; 25 | } 26 | 27 | label { 28 | padding: 12px 12px 12px 0; 29 | display: inline-block; 30 | } 31 | 32 | input[type=submit] { 33 | background-color: #3f51b5; 34 | color: white; 35 | padding: 12px 20px; 36 | border: none; 37 | border-radius: 4px; 38 | cursor: pointer; 39 | width: 100%; 40 | } 41 | 42 | input[type=submit]:hover { 43 | background-color: rgb(84, 129, 218); 44 | } 45 | 46 | .container { 47 | border-radius: 5px; 48 | background-color: #f2f2f2; 49 | padding: 20px; 50 | } 51 | 52 | .col-25 { 53 | float: left; 54 | width: 25%; 55 | margin-top: 6px; 56 | } 57 | 58 | .col-75 { 59 | float: left; 60 | width: 75%; 61 | margin-top: 6px; 62 | } 63 | 64 | /* Clear floats after the columns */ 65 | .row:after { 66 | content: ""; 67 | display: table; 68 | clear: both; 69 | } 70 | 71 | .error-message{ 72 | padding: 20px; 73 | background-color: white; 74 | color: #D32F2F; 75 | opacity: 1; 76 | transition: opacity 0.6s; 77 | margin-bottom: 15px; 78 | font-size: 15px; 79 | width: 100%; 80 | 81 | } 82 | .successMessage{ 83 | 84 | padding: 20px; 85 | background-color: white; 86 | color: #4CAF50; 87 | font-size: 15px; 88 | opacity: 1; 89 | transition: opacity 0.6s; 90 | margin-bottom: 15px; 91 | width: 100%; 92 | } 93 | 94 | /* Responsive layout - when the screen is less than 600px wide, make the two columns stack on top of each other instead of next to each other */ 95 | @media screen and (max-width: 600px) { 96 | .col-25, .col-75, input[type=submit] { 97 | width: 100%; 98 | margin-top: 0; 99 | } 100 | } -------------------------------------------------------------------------------- /AirbusInventory/src/app/add-product/add-product.component.html: -------------------------------------------------------------------------------- 1 | 2 |

Add Product

3 | 4 |
5 | 6 |
7 |
8 | 9 |
10 |
11 | 12 |
13 |
14 | 15 |
16 |
17 | 18 |
19 |
20 | 21 |
22 |
23 | 24 |
25 |
26 |
27 |
28 | 29 |
30 |
31 | 36 |
37 |
38 |
39 |
40 | 41 |
42 |
43 | 44 |
45 |
46 |
47 |
48 | 49 |
50 |
51 | 52 |
53 |
54 |
55 |
56 | 57 | 58 |
59 |
60 | 61 | 62 |
63 |
64 | 65 | 66 | 67 |
68 |
69 |
70 |
-------------------------------------------------------------------------------- /AirbusInventory/src/app/add-product/add-product.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { AddProductComponent } from './add-product.component'; 4 | 5 | describe('AddProductComponent', () => { 6 | let component: AddProductComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ AddProductComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(AddProductComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/add-product/add-product.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { FormControl, FormGroup, Validators } from '@angular/forms'; 3 | import { Product } from '../Product'; 4 | import { ProductService } from '../services/product.service'; 5 | import { SharedServiceService } from '../services/shared-service.service'; 6 | 7 | @Component({ 8 | selector: 'app-add-product', 9 | templateUrl: './add-product.component.html', 10 | styleUrls: ['./add-product.component.css'] 11 | }) 12 | export class AddProductComponent implements OnInit { 13 | 14 | product: Product = new Product(); 15 | 16 | successMessage:string =""; 17 | errMessage: string =""; 18 | 19 | constructor(private productService:ProductService, private sharedServiceService:SharedServiceService) { 20 | 21 | } 22 | 23 | 24 | ngOnInit(): void { 25 | } 26 | 27 | addProductForm=new FormGroup({ 28 | 29 | productid:new FormControl('',[Validators.required]), 30 | productname:new FormControl('',[Validators.required]), 31 | units: new FormControl('',[Validators.required]), 32 | category: new FormControl('',[Validators.required]), 33 | description: new FormControl('',[Validators.required]), 34 | }) 35 | 36 | get productid(){ 37 | return this.addProductForm.get('productid'); 38 | } 39 | 40 | get productname(){ 41 | return this.addProductForm.get('productname'); 42 | } 43 | 44 | get units(){ 45 | return this.addProductForm.get('units'); 46 | } 47 | 48 | get category(){ 49 | return this.addProductForm.get('category'); 50 | } 51 | 52 | get description(){ 53 | return this.addProductForm.get('description'); 54 | } 55 | 56 | addProduct(){ 57 | 58 | this.product.productId=this.productid?.value; 59 | this.product.productName=this.productname?.value; 60 | this.product.units=this.units?.value; 61 | this.product.productCategory=this.category?.value; 62 | this.product.productDescription=this.description?.value; 63 | 64 | console.log(this.product); 65 | 66 | 67 | if(this.product.productId=="") 68 | { 69 | this.errMessage="Product could not be Added to the catalog : Product Id is required"; 70 | } 71 | else if(this.product.productName=="") 72 | { 73 | this.errMessage="Product could not be Added to the catalog : Product Name is required"; 74 | } 75 | else if(this.product.productCategory=="") 76 | { 77 | this.errMessage="Product could not be Added to the catalog : Product Category is required"; 78 | } 79 | else if(this.product.units==0 || this.product.units==null) 80 | { 81 | this.errMessage="Product could not be Added to the catalog : Product Units can not be 0"; 82 | } 83 | else if(this.product.productDescription=="") 84 | { 85 | this.errMessage="Product could not be Added to the catalog : Product Description is required"; 86 | } 87 | else{ 88 | 89 | this.productService.addProduct(this.product).subscribe(data => { 90 | 91 | if(data) 92 | { 93 | this.errMessage=""; 94 | this.successMessage="Product successfully added to the catalog"; 95 | } 96 | else{ 97 | this.successMessage=""; 98 | this.errMessage="Product could not be Added to the catalog : Check Specification of your product"; 99 | } 100 | 101 | }) 102 | 103 | } 104 | 105 | 106 | } 107 | 108 | 109 | } 110 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/app.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Akash-goyal-github/Inventory-Management-System/256ebe9d834c690e2d1c639dfefd00df6f3c408b/AirbusInventory/src/app/app.component.css -------------------------------------------------------------------------------- /AirbusInventory/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { AppComponent } from './app.component'; 3 | 4 | describe('AppComponent', () => { 5 | beforeEach(async () => { 6 | await TestBed.configureTestingModule({ 7 | declarations: [ 8 | AppComponent 9 | ], 10 | }).compileComponents(); 11 | }); 12 | 13 | it('should create the app', () => { 14 | const fixture = TestBed.createComponent(AppComponent); 15 | const app = fixture.componentInstance; 16 | expect(app).toBeTruthy(); 17 | }); 18 | 19 | it(`should have as title 'AirbusInventory'`, () => { 20 | const fixture = TestBed.createComponent(AppComponent); 21 | const app = fixture.componentInstance; 22 | expect(app.title).toEqual('AirbusInventory'); 23 | }); 24 | 25 | it('should render title', () => { 26 | const fixture = TestBed.createComponent(AppComponent); 27 | fixture.detectChanges(); 28 | const compiled = fixture.nativeElement as HTMLElement; 29 | expect(compiled.querySelector('.content span')?.textContent).toContain('AirbusInventory app is running!'); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.css'] 7 | }) 8 | export class AppComponent { 9 | title = 'AirbusInventory'; 10 | } 11 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | 4 | import { AppComponent } from './app.component'; 5 | import { LoginPageComponent } from './login-page/login-page.component'; 6 | import { DashboardComponent } from './dashboard/dashboard.component'; 7 | import { FlexLayoutModule } from '@angular/flex-layout'; 8 | import {MatToolbarModule} from '@angular/material/toolbar'; 9 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 10 | import {MatSidenavModule} from '@angular/material/sidenav'; 11 | import {MatIconModule} from '@angular/material/icon'; 12 | import { GetProductByCategoryComponent } from './get-product-by-category/get-product-by-category.component'; 13 | import { GetAllProductsComponent } from './get-all-products/get-all-products.component'; 14 | import { AddProductComponent } from './add-product/add-product.component'; 15 | import { UpdateProductComponent } from './update-product/update-product.component'; 16 | import {RouterModule, Routes} from '@angular/router'; 17 | import { MainNavComponent } from './main-nav/main-nav.component'; 18 | import { LayoutModule } from '@angular/cdk/layout'; 19 | import { MatButtonModule } from '@angular/material/button'; 20 | import { MatListModule } from '@angular/material/list'; 21 | import {MatFormFieldModule} from '@angular/material/form-field'; 22 | import {MatSelectModule} from '@angular/material/select'; 23 | import { MatInputModule } from '@angular/material/input'; 24 | import { MatCardModule } from '@angular/material/card'; 25 | import { ProductService } from './services/product.service'; 26 | import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'; 27 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; 28 | import { Ng2SearchPipeModule } from 'ng2-search-filter'; 29 | import { SuccessfulDialogComponent } from './successful-dialog/successful-dialog.component'; 30 | import { UnSuccessfulDialogComponent } from './un-successful-dialog/un-successful-dialog.component'; 31 | import {MatDialogModule} from '@angular/material/dialog'; 32 | import { AuthenticationServiceService } from './services/authentication-service.service'; 33 | import { RouterService } from './services/router.service'; 34 | import { CanActivateRouteGuard} from './can-activate-guard'; 35 | 36 | import { Ng2OrderModule } from 'ng2-order-pipe'; 37 | 38 | const routes: Routes=[ 39 | { 40 | path:'login',//path is http:localhost:4200/login 41 | component:LoginPageComponent 42 | }, 43 | { 44 | path:'dashboard', 45 | component: GetAllProductsComponent, 46 | canActivate:[CanActivateRouteGuard] 47 | }, 48 | { 49 | path:'productByCategory',//path is http:localhost:4200/productByCategory 50 | component:GetProductByCategoryComponent, 51 | canActivate:[CanActivateRouteGuard] 52 | }, 53 | { 54 | path:'getAllProducts',//path is http:localhost:4200/getAllProducts 55 | component:GetAllProductsComponent, 56 | canActivate:[CanActivateRouteGuard] 57 | }, 58 | { 59 | path:'add',//path is http:localhost:4200/add 60 | component:AddProductComponent, 61 | canActivate:[CanActivateRouteGuard] 62 | }, 63 | { 64 | path:'update',//path is http:localhost:4200/update 65 | component:UpdateProductComponent, 66 | canActivate:[CanActivateRouteGuard] 67 | }, 68 | { 69 | //by default we are opening login 70 | path:'', 71 | redirectTo:'login', 72 | pathMatch:'full' 73 | } 74 | ] 75 | 76 | 77 | 78 | @NgModule({ 79 | declarations: [ 80 | AppComponent, 81 | LoginPageComponent, 82 | DashboardComponent, 83 | GetProductByCategoryComponent, 84 | GetAllProductsComponent, 85 | AddProductComponent, 86 | UpdateProductComponent, 87 | MainNavComponent, 88 | SuccessfulDialogComponent, 89 | UnSuccessfulDialogComponent 90 | ], 91 | imports: [ 92 | BrowserModule, 93 | FlexLayoutModule, 94 | MatToolbarModule, 95 | BrowserAnimationsModule, 96 | MatSidenavModule, 97 | MatIconModule, 98 | RouterModule.forRoot(routes), 99 | LayoutModule, 100 | MatButtonModule, 101 | MatListModule, 102 | MatFormFieldModule, 103 | MatSelectModule, 104 | MatInputModule, 105 | MatCardModule, 106 | HttpClientModule, 107 | FormsModule, 108 | ReactiveFormsModule, 109 | Ng2SearchPipeModule, 110 | MatDialogModule, 111 | Ng2OrderModule 112 | ], 113 | providers: [ProductService,AuthenticationServiceService,AuthenticationServiceService,RouterService], 114 | bootstrap: [AppComponent] 115 | }) 116 | export class AppModule { } 117 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/can-activate-guard.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; 3 | import { Observable } from 'rxjs'; 4 | import { AuthenticationServiceService} from './services/authentication-service.service'; 5 | import { RouterService } from './services/router.service'; 6 | 7 | @Injectable({ 8 | providedIn: 'root' 9 | }) 10 | export class CanActivateRouteGuard { 11 | 12 | constructor(private authService:AuthenticationServiceService,private routerService:RouterService) {} 13 | 14 | canActivate( 15 | next: ActivatedRouteSnapshot, 16 | state: RouterStateSnapshot): Observable | Promise | boolean { 17 | if(!this.authService.isUserLoggedIn()) 18 | { 19 | this.routerService.routeToLogin(); 20 | } 21 | return this.authService.isUserLoggedIn(); 22 | } 23 | } 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/dashboard/dashboard.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Akash-goyal-github/Inventory-Management-System/256ebe9d834c690e2d1c639dfefd00df6f3c408b/AirbusInventory/src/app/dashboard/dashboard.component.css -------------------------------------------------------------------------------- /AirbusInventory/src/app/dashboard/dashboard.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/dashboard/dashboard.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { DashboardComponent } from './dashboard.component'; 4 | 5 | describe('DashboardComponent', () => { 6 | let component: DashboardComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ DashboardComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(DashboardComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/dashboard/dashboard.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-dashboard', 5 | templateUrl: './dashboard.component.html', 6 | styleUrls: ['./dashboard.component.css'] 7 | }) 8 | export class DashboardComponent implements OnInit { 9 | 10 | title = 'app'; 11 | constructor() { } 12 | 13 | ngOnInit(): void { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/get-all-products/get-all-products.component.css: -------------------------------------------------------------------------------- 1 | .search-container { 2 | margin: 20px auto; 3 | width: 100%; 4 | } 5 | 6 | h1{ 7 | margin-top: 20px; 8 | text-align: center; 9 | color: black; 10 | } 11 | 12 | .form-control{ 13 | color: cornsilk; 14 | padding: 10px; 15 | margin: 20px; 16 | width:25vw; 17 | color:black; 18 | float: right; 19 | box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); 20 | } 21 | 22 | h1 23 | { 24 | text-align: center; 25 | color: #3f51b5;; 26 | } 27 | 28 | 29 | #product { 30 | font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; 31 | border-collapse: collapse; 32 | width: 90%; 33 | margin: 7vh; 34 | } 35 | 36 | #product td, #users th { 37 | border: 1px solid #ddd; 38 | padding: 8px; 39 | text-align: center; 40 | } 41 | 42 | #product tr:nth-child(even){background-color: #f2f2f2;} 43 | 44 | #product tr:hover {background-color: #ddd;font-size: large;} 45 | 46 | #product th { 47 | padding-top: 12px; 48 | padding-bottom: 12px; 49 | text-align: center; 50 | background-color: #3f51b5;; 51 | color: white; 52 | font-size: large; 53 | } 54 | 55 | .material-icons.white{ 56 | color: white; 57 | padding-top: 12px; 58 | padding-bottom: 12px; 59 | cursor: pointer; 60 | } 61 | 62 | .material-icons.delete, .material-icons.edit{ 63 | color: #3f51b5; 64 | padding-top: 12px; 65 | padding-bottom: 12px; 66 | cursor: pointer; 67 | } 68 | 69 | @media only screen and (max-width:750px) 70 | { 71 | .form-control{ 72 | color: cornsilk; 73 | padding: 10px; 74 | margin: 10px; 75 | width:50vw; 76 | color:black; 77 | float: right; 78 | box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); 79 | } 80 | #product { 81 | font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; 82 | border-collapse: collapse; 83 | width: 100%; 84 | margin: 0px; 85 | } 86 | #product th { 87 | padding-top: 12px; 88 | padding-bottom: 12px; 89 | text-align: center; 90 | background-color: #3f51b5;; 91 | color: white; 92 | } 93 | 94 | .material-icons.white{ 95 | color: white; 96 | padding-top: 12px; 97 | padding-bottom: 12px; 98 | cursor: pointer; 99 | } 100 | 101 | .material-icons.delete, .material-icons.edit{ 102 | color: #3f51b5; 103 | padding-top: 12px; 104 | padding-bottom: 12px; 105 | cursor: pointer; 106 | } 107 | 108 | } -------------------------------------------------------------------------------- /AirbusInventory/src/app/get-all-products/get-all-products.component.html: -------------------------------------------------------------------------------- 1 | 2 |

Get All Products

3 | 4 |
5 | 6 | 7 | 12 | 13 | 18 | 23 | 28 | 33 | 36 | 39 | 40 | 41 | 42 | 43 | 46 | 49 | 52 | 55 | 58 | 59 | 64 | 65 | 71 | 72 | 73 | 74 | 75 | 76 |
8 | ID  9 | unfold_more 10 | 11 | 14 | Product Name  15 | unfold_more 16 | 17 | 19 | Product Description  20 | unfold_more 21 | 22 | 24 | Category  25 | unfold_more 26 | 27 | 29 | Units  30 | unfold_more 31 | 32 | 34 | Update 35 | 37 | Delete 38 |
44 | {{product.productId}} 45 | 47 | {{product.productName}} 48 | 50 | {{product.productDescription}} 51 | 53 | {{product.productCategory}} 54 | 56 | {{product.units}} 57 | 60 | 61 | border_color 62 | 63 | 66 | 67 | delete 68 | 69 | 70 |
77 | 78 |
-------------------------------------------------------------------------------- /AirbusInventory/src/app/get-all-products/get-all-products.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { GetAllProductsComponent } from './get-all-products.component'; 4 | 5 | describe('GetAllProductsComponent', () => { 6 | let component: GetAllProductsComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ GetAllProductsComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(GetAllProductsComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/get-all-products/get-all-products.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { FormControl, FormGroup } from '@angular/forms'; 3 | import { MatDialog } from '@angular/material/dialog'; 4 | import { Product} from '../Product'; 5 | import { ProductService } from '../services/product.service'; 6 | import { RouterService } from '../services/router.service'; 7 | import { SharedServiceService } from '../services/shared-service.service'; 8 | import { SuccessfulDialogComponent } from '../successful-dialog/successful-dialog.component'; 9 | import { UnSuccessfulDialogComponent } from '../un-successful-dialog/un-successful-dialog.component'; 10 | 11 | @Component({ 12 | selector: 'app-get-all-products', 13 | templateUrl: './get-all-products.component.html', 14 | styleUrls: ['./get-all-products.component.css'] 15 | }) 16 | export class GetAllProductsComponent implements OnInit { 17 | 18 | productList:any; 19 | product:any; 20 | 21 | constructor(private productService: ProductService,public dialog: MatDialog, private sharedServices: SharedServiceService, private routerService:RouterService) { } 22 | 23 | ngOnInit(): void { 24 | this.productService.getAllProducts().subscribe(data => { 25 | this.productList = data; 26 | 27 | }); 28 | } 29 | 30 | deleteProduct(productId: string){ 31 | 32 | this.productService.deleteProduct(productId).subscribe(data => { 33 | 34 | if(data) 35 | { 36 | this.openSuccessfulDialog(); 37 | this.ngOnInit(); 38 | } 39 | else{ 40 | this.openunSuccessfulDialog(); 41 | this.ngOnInit(); 42 | } 43 | 44 | }); 45 | } 46 | 47 | updateProduct(product: Product){ 48 | 49 | this.sharedServices.setProduct(product); 50 | this.routerService.routeToUpdateProduct(); 51 | } 52 | 53 | 54 | openSuccessfulDialog() { 55 | this.sharedServices.setdialogtitle("Successfull"); 56 | this.sharedServices.setdialogcontent("Product Deleted Successfully !!"); 57 | this.dialog.open(SuccessfulDialogComponent); 58 | } 59 | 60 | openunSuccessfulDialog() { 61 | this.sharedServices.setdialogtitle("Unsuccessfull"); 62 | this.sharedServices.setdialogcontent("Product could not be Deleted !!"); 63 | this.dialog.open(UnSuccessfulDialogComponent); 64 | } 65 | 66 | key: string ='id'; 67 | reverse: boolean=false; 68 | sort(key:string) 69 | { 70 | this.key=key; 71 | this.reverse=!this.reverse; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/get-product-by-category/get-product-by-category.component.css: -------------------------------------------------------------------------------- 1 | 2 | h1{ 3 | margin-top: 20px; 4 | text-align: center; 5 | color: black; 6 | } 7 | 8 | .form-control{ 9 | color: cornsilk; 10 | padding: 10px; 11 | margin: 20px; 12 | height: 150px; 13 | width:25vw; 14 | color:black; 15 | float: right; 16 | box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); 17 | } 18 | 19 | .drop{ 20 | margin-right: 20px; 21 | background-color: white ; 22 | padding: 10px; 23 | color: #3f51b5; 24 | width: 100%; 25 | text-align: center; 26 | } 27 | 28 | .submit{ 29 | margin-right: 20px; 30 | background-color: #3f51b5 ; 31 | padding: 10px; 32 | color: white; 33 | width: 100%; 34 | text-align: center; 35 | } 36 | 37 | .submit:hover{ 38 | background-color: #7183ec ; 39 | color: black; 40 | 41 | } 42 | 43 | .search-container { 44 | margin: 20px auto; 45 | width: 100%; 46 | } 47 | 48 | h1{ 49 | margin-top: 20px; 50 | text-align: center; 51 | color: black; 52 | } 53 | 54 | .form-control{ 55 | color: cornsilk; 56 | padding: 10px; 57 | margin: 20px; 58 | width:25vw; 59 | color:black; 60 | float: right; 61 | box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); 62 | } 63 | 64 | h1 65 | { 66 | text-align: center; 67 | color: #3f51b5;; 68 | } 69 | 70 | 71 | #product { 72 | font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; 73 | border-collapse: collapse; 74 | width: 90%; 75 | margin: 7vh; 76 | } 77 | 78 | #product td, #users th { 79 | border: 1px solid #ddd; 80 | padding: 8px; 81 | text-align: center; 82 | } 83 | 84 | #product tr:nth-child(even){background-color: #f2f2f2;} 85 | 86 | #product tr:hover {background-color: #ddd;font-size: large;} 87 | 88 | #product th { 89 | padding-top: 12px; 90 | padding-bottom: 12px; 91 | text-align: center; 92 | background-color: #3f51b5;; 93 | color: white; 94 | font-size: large; 95 | } 96 | 97 | .material-icons{ 98 | color: #3f51b5; 99 | cursor: pointer; 100 | } 101 | 102 | 103 | @media only screen and (max-width:750px) 104 | { 105 | .form-control{ 106 | color: cornsilk; 107 | padding: 10px; 108 | margin: 10px; 109 | width:50vw; 110 | color:black; 111 | float: right; 112 | box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); 113 | } 114 | #product { 115 | font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; 116 | border-collapse: collapse; 117 | width: 100%; 118 | margin: 0px; 119 | } 120 | #product th { 121 | padding-top: 12px; 122 | padding-bottom: 12px; 123 | text-align: center; 124 | background-color: #3f51b5;; 125 | color: white; 126 | } 127 | 128 | } -------------------------------------------------------------------------------- /AirbusInventory/src/app/get-product-by-category/get-product-by-category.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Show Products By Category

4 | 5 |
6 |
7 |
8 |
9 | 14 |
15 |
16 | 17 | 18 | 19 |
20 |
21 | 22 | 23 | 24 | 27 | 28 | 29 | 30 | 33 | 36 | 39 | 42 | 45 | 46 | 47 | 48 | 49 |
25 | {{column}} 26 |
31 | {{product.productId}} 32 | 34 | {{product.productName}} 35 | 37 | {{product.productDescription}} 38 | 40 | {{product.productCategory}} 41 | 43 | {{product.units}} 44 |
50 | 51 |
-------------------------------------------------------------------------------- /AirbusInventory/src/app/get-product-by-category/get-product-by-category.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { GetProductByCategoryComponent } from './get-product-by-category.component'; 4 | 5 | describe('GetProductByCategoryComponent', () => { 6 | let component: GetProductByCategoryComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ GetProductByCategoryComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(GetProductByCategoryComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/get-product-by-category/get-product-by-category.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { FormControl, FormGroup, Validators } from '@angular/forms'; 3 | import { ProductService } from '../services/product.service'; 4 | 5 | @Component({ 6 | selector: 'app-get-product-by-category', 7 | templateUrl: './get-product-by-category.component.html', 8 | styleUrls: ['./get-product-by-category.component.css'] 9 | }) 10 | export class GetProductByCategoryComponent implements OnInit { 11 | 12 | productList:any; 13 | product:any; 14 | key:any=""; 15 | headers = ["Id", "Product Name", "Product Description", "Category", "Units"]; 16 | 17 | 18 | constructor(private productService: ProductService) { } 19 | 20 | 21 | ngOnInit(): void { 22 | 23 | } 24 | 25 | 26 | categoryForm=new FormGroup({ 27 | 28 | category: new FormControl('',[Validators.required]) 29 | }) 30 | 31 | get category(){ 32 | return this.categoryForm.get('category'); 33 | } 34 | 35 | getProductByCategory(){ 36 | 37 | this.key=this.categoryForm.value; 38 | 39 | this.productService.getAllProductsByCategory(this.key).subscribe(data => { 40 | this.productList = data; 41 | }); 42 | 43 | } 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/login-page/login-page.component.css: -------------------------------------------------------------------------------- 1 | 2 | .login, 3 | .image { 4 | min-height: 100vh; 5 | } 6 | .bg-image { 7 | background-image: url('../../assets/airbus.webp'); 8 | background-size:cover; 9 | background-position: center center; 10 | 11 | } 12 | #inputEmail, #inputPassword, #submit{ 13 | font-size: large; 14 | } 15 | .error-message{ 16 | padding: 20px; 17 | background-color: white; 18 | color: #D32F2F; 19 | opacity: 1; 20 | transition: opacity 0.6s; 21 | margin-bottom: 15px; 22 | width: 100%; 23 | font-size: 15px; 24 | 25 | } 26 | .successMessage{ 27 | 28 | padding: 20px; 29 | background-color: white; 30 | color: #4CAF50; 31 | opacity: 1; 32 | transition: opacity 0.6s; 33 | margin-bottom: 15px; 34 | width: 100%; 35 | font-size: 15px; 36 | } -------------------------------------------------------------------------------- /AirbusInventory/src/app/login-page/login-page.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 | 6 |
7 | 39 |
40 |
41 |
42 | 43 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/login-page/login-page.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { HttpClientModule } from '@angular/common/http'; 2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 3 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; 4 | import { RouterModule, Routes } from '@angular/router'; 5 | import { CanActivateRouteGuard } from '../can-activate-guard'; 6 | import { GetAllProductsComponent } from '../get-all-products/get-all-products.component'; 7 | import { AuthenticationServiceService } from '../services/authentication-service.service'; 8 | import { RouterService } from '../services/router.service'; 9 | 10 | import { LoginPageComponent } from './login-page.component'; 11 | 12 | 13 | const routes: Routes=[ 14 | { 15 | path:'login',//path is http:localhost:4200/login 16 | component:LoginPageComponent 17 | }, 18 | { 19 | path:'dashboard', 20 | component: GetAllProductsComponent, 21 | canActivate:[CanActivateRouteGuard] 22 | } 23 | ] 24 | 25 | describe('LoginPageComponent', () => { 26 | let component: LoginPageComponent; 27 | let fixture: ComponentFixture; 28 | 29 | beforeEach(async () => { 30 | await TestBed.configureTestingModule({ 31 | declarations: [ LoginPageComponent ], 32 | imports:[ 33 | HttpClientModule, 34 | FormsModule, 35 | ReactiveFormsModule, 36 | RouterModule.forRoot(routes), 37 | ], 38 | providers:[RouterService,AuthenticationServiceService] 39 | }) 40 | .compileComponents(); 41 | }); 42 | 43 | it(`form should be invalid`, async(() => { 44 | component.loginForm.controls['emailid'].setValue(''); 45 | component.loginForm.controls['password'].setValue(''); 46 | 47 | expect(component.loginForm.valid).toBeFalsy(); 48 | 49 | })); 50 | 51 | it(`form should be Valid`, async(() => { 52 | component.loginForm.controls['emailid'].setValue('airbus02@gmail.com'); 53 | component.loginForm.controls['password'].setValue('1234'); 54 | 55 | expect(component.loginForm.valid).toBeTruthy(); 56 | 57 | })); 58 | 59 | beforeEach(() => { 60 | fixture = TestBed.createComponent(LoginPageComponent); 61 | component = fixture.componentInstance; 62 | fixture.detectChanges(); 63 | }); 64 | 65 | it('should create', () => { 66 | expect(component).toBeTruthy(); 67 | }); 68 | }); 69 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/login-page/login-page.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { FormControl, FormGroup, Validators } from '@angular/forms'; 3 | import { LoginFormClass } from '../LoginFormClass'; 4 | import { AuthenticationServiceService } from '../services/authentication-service.service'; 5 | import { RouterService } from '../services/router.service'; 6 | 7 | @Component({ 8 | selector: 'app-login-page', 9 | templateUrl: './login-page.component.html', 10 | styleUrls: ['./login-page.component.css'] 11 | }) 12 | export class LoginPageComponent implements OnInit { 13 | 14 | 15 | successMessage:string =""; 16 | errMessage: string =""; 17 | 18 | loginFormClass: LoginFormClass = new LoginFormClass(); 19 | constructor(private authenticateService: AuthenticationServiceService, private routerService:RouterService) { } 20 | 21 | ngOnInit(): void { 22 | } 23 | 24 | 25 | loginForm=new FormGroup({ 26 | 27 | emailid:new FormControl('',[Validators.required,Validators.email]), 28 | password:new FormControl('',[Validators.required]) 29 | }) 30 | 31 | get emailid(){ 32 | return this.loginForm.get('emailid'); 33 | } 34 | 35 | get password(){ 36 | return this.loginForm.get('password'); 37 | } 38 | 39 | login(){ 40 | 41 | 42 | this.loginFormClass.username=this.emailid?.value; 43 | this.loginFormClass.password=this.password?.value; 44 | 45 | 46 | if(this.loginFormClass.username=="") 47 | { 48 | this.errMessage="Email Id is required"; 49 | } 50 | else if(this.loginFormClass.password=="") 51 | { 52 | this.errMessage="Password is required"; 53 | } 54 | else{ 55 | if(this.loginForm.valid) 56 | { 57 | this.authenticateService.authenticate(this.loginFormClass).subscribe(data => { 58 | 59 | localStorage.setItem('token',data.token); 60 | if (localStorage.getItem('token') !== null) { 61 | 62 | 63 | this.routerService.routeToDashboard(); 64 | } 65 | }); 66 | } 67 | else{ 68 | this.errMessage="UserName should be your Email Id"; 69 | } 70 | } 71 | 72 | } 73 | 74 | } -------------------------------------------------------------------------------- /AirbusInventory/src/app/main-nav/main-nav.component.css: -------------------------------------------------------------------------------- 1 | .sidenav-container { 2 | height: 100%; 3 | } 4 | 5 | .nav2{ 6 | font-size: large; 7 | font-weight: bold; 8 | } 9 | 10 | .sidenav { 11 | width: 250px; 12 | box-shadow: 3px 0 6px grey; 13 | } 14 | 15 | .sidenav .mat-toolbar { 16 | background: inherit; 17 | } 18 | 19 | .mat-toolbar.mat-primary { 20 | position: sticky; 21 | top: 0; 22 | z-index: 1; 23 | } 24 | .menu-bar{ 25 | color: indigo; 26 | } 27 | .material-icons.home:focus{ 28 | 29 | flex: 1 1 auto; 30 | text-align: end; 31 | outline: none; 32 | } 33 | 34 | .material-icons.home{ 35 | 36 | flex: 1 1 auto; 37 | text-align: end; 38 | } 39 | 40 | li{ 41 | cursor: pointer; 42 | } 43 | 44 | .material-icons, .musix{ 45 | cursor: pointer; 46 | font-size: xx-large; 47 | } 48 | 49 | 50 | .home:hover + .hide { 51 | display: block; 52 | color: white; 53 | } 54 | 55 | .home{ 56 | width: 15vw; 57 | } 58 | .but2{ 59 | padding-left: 20px; 60 | padding-right: 20px; 61 | padding-top: 10px; 62 | padding-bottom: 10px; 63 | background-color: white; 64 | font-size: large; 65 | box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); 66 | display: flex; 67 | flex-direction: column; 68 | align-items: flex-end; 69 | } 70 | 71 | .hide { 72 | display: block; 73 | cursor: pointer; 74 | 75 | } 76 | 77 | .myDIV:hover + .hide { 78 | display: block; 79 | color: white; 80 | cursor: pointer; 81 | } -------------------------------------------------------------------------------- /AirbusInventory/src/app/main-nav/main-nav.component.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | Menu 9 | 10 | 11 | Get Products by Category 12 | 13 | category 14 | 15 | 16 | 17 | 18 |
19 | Get All Products 20 | 21 | visibility 22 | 23 | 24 | 25 |
26 | Add Product 27 | 28 | add 29 | 30 | 31 |
32 | 33 | 34 |
35 | 36 |
37 | 38 | 39 | 47 | 48 | Airbus Inventory 49 | 50 | 51 | 52 | logout 53 |
Logout
54 |
55 | 56 | 57 |
58 |
59 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/main-nav/main-nav.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { LayoutModule } from '@angular/cdk/layout'; 2 | import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; 3 | import { NoopAnimationsModule } from '@angular/platform-browser/animations'; 4 | import { MatButtonModule } from '@angular/material/button'; 5 | import { MatIconModule } from '@angular/material/icon'; 6 | import { MatListModule } from '@angular/material/list'; 7 | import { MatSidenavModule } from '@angular/material/sidenav'; 8 | import { MatToolbarModule } from '@angular/material/toolbar'; 9 | 10 | import { MainNavComponent } from './main-nav.component'; 11 | 12 | describe('MainNavComponent', () => { 13 | let component: MainNavComponent; 14 | let fixture: ComponentFixture; 15 | 16 | beforeEach(waitForAsync(() => { 17 | TestBed.configureTestingModule({ 18 | declarations: [MainNavComponent], 19 | imports: [ 20 | NoopAnimationsModule, 21 | LayoutModule, 22 | MatButtonModule, 23 | MatIconModule, 24 | MatListModule, 25 | MatSidenavModule, 26 | MatToolbarModule, 27 | ] 28 | }).compileComponents(); 29 | })); 30 | 31 | beforeEach(() => { 32 | fixture = TestBed.createComponent(MainNavComponent); 33 | component = fixture.componentInstance; 34 | fixture.detectChanges(); 35 | }); 36 | 37 | it('should compile', () => { 38 | expect(component).toBeTruthy(); 39 | }); 40 | }); 41 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/main-nav/main-nav.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout'; 3 | import { Observable } from 'rxjs'; 4 | import { map, shareReplay } from 'rxjs/operators'; 5 | 6 | @Component({ 7 | selector: 'app-main-nav', 8 | templateUrl: './main-nav.component.html', 9 | styleUrls: ['./main-nav.component.css'] 10 | }) 11 | export class MainNavComponent { 12 | 13 | isHandset$: Observable = this.breakpointObserver.observe(Breakpoints.Handset) 14 | .pipe( 15 | map(result => result.matches), 16 | shareReplay() 17 | ); 18 | 19 | constructor(private breakpointObserver: BreakpointObserver) {} 20 | 21 | logout(){ 22 | localStorage.removeItem('token'); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/services/authentication-service.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { AuthenticationServiceService } from './authentication-service.service'; 4 | 5 | describe('AuthenticationServiceService', () => { 6 | let service: AuthenticationServiceService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(AuthenticationServiceService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/services/authentication-service.service.ts: -------------------------------------------------------------------------------- 1 | import { HttpClient, HttpHeaders } from '@angular/common/http'; 2 | import { Injectable, SystemJsNgModuleLoader } from '@angular/core'; 3 | import { Observable } from 'rxjs'; 4 | import { map } from 'rxjs/operators'; 5 | import { LoginFormClass } from '../LoginFormClass'; 6 | 7 | @Injectable({ 8 | providedIn: 'root' 9 | }) 10 | export class AuthenticationServiceService { 11 | 12 | 13 | constructor(private httpClient: HttpClient) { } 14 | 15 | authenticate(userObj:LoginFormClass): Observable { 16 | return this.httpClient.post('http://localhost:8080/airbusManagement/JWT/authenticateUser',userObj); 17 | } 18 | 19 | isUserLoggedIn() { 20 | let user = localStorage.getItem('token'); 21 | return !(user === null); 22 | } 23 | 24 | } 25 | 26 | // .pipe( 27 | // map( 28 | // userData => { 29 | // console.log("authenticatio done"); 30 | // sessionStorage.setItem('username',userObj.username); 31 | // let tokenStr= 'Bearer '+userData.token; 32 | // sessionStorage.setItem('token', tokenStr); 33 | // return userData; 34 | // } 35 | // ) 36 | 37 | // ); -------------------------------------------------------------------------------- /AirbusInventory/src/app/services/product.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { ProductService } from './product.service'; 4 | 5 | describe('ProductService', () => { 6 | let service: ProductService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(ProductService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/services/product.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { HttpClient, HttpHeaders } from '@angular/common/http'; 3 | import { Observable } from 'rxjs'; 4 | import { Product } from '../Product'; 5 | import { SharedServiceService } from './shared-service.service'; 6 | 7 | @Injectable({ 8 | providedIn: 'root' 9 | }) 10 | export class ProductService { 11 | 12 | constructor(private httpClient: HttpClient, private sharedServiceService:SharedServiceService) { } 13 | 14 | 15 | getAllProducts(): Observable { 16 | 17 | return this.httpClient.get('http://localhost:8080/airbusManagement/getAllProducts',{ 18 | headers:new HttpHeaders( 19 | { 20 | 'Authorization' : `Bearer ${localStorage.getItem('token')}` 21 | } 22 | ) 23 | }); 24 | } 25 | 26 | addProduct(product:Product): Observable{ 27 | return this.httpClient.post('http://localhost:8080/airbusManagement/addProduct',product,{ 28 | headers:new HttpHeaders( 29 | { 30 | 'Authorization' : `Bearer ${localStorage.getItem('token')}` 31 | } 32 | ) 33 | }); 34 | } 35 | 36 | getAllProductsByCategory(category: any): Observable { 37 | return this.httpClient.get(`http://localhost:8080/airbusManagement/getProductsByCategory/${category['category']}`,{ 38 | headers:new HttpHeaders( 39 | { 40 | 'Authorization' : `Bearer ${localStorage.getItem('token')}` 41 | } 42 | ) 43 | }); 44 | } 45 | 46 | deleteProduct(productId: any): Observable { 47 | return this.httpClient.delete(`http://localhost:8080/airbusManagement/deleteProduct/${productId}`,{ 48 | headers:new HttpHeaders( 49 | { 50 | 'Authorization' : `Bearer ${localStorage.getItem('token')}` 51 | } 52 | ) 53 | }); 54 | } 55 | 56 | updateProduct(product:Product,productId: any): Observable{ 57 | return this.httpClient.post(`http://localhost:8080/airbusManagement/updateProduct/${productId}`,product,{ 58 | headers:new HttpHeaders( 59 | { 60 | 'Authorization' : `Bearer ${localStorage.getItem('token')}` 61 | } 62 | ) 63 | }); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/services/router.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { RouterService } from './router.service'; 4 | 5 | describe('RouterService', () => { 6 | let service: RouterService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(RouterService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/services/router.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { Router } from '@angular/router'; 3 | 4 | @Injectable({ 5 | providedIn: 'root' 6 | }) 7 | export class RouterService { 8 | 9 | constructor(private router:Router) { } 10 | 11 | routeToLogin(){ 12 | this.router.navigate(['login']); 13 | } 14 | 15 | routeToDashboard(){ 16 | this.router.navigate(['dashboard']); 17 | } 18 | 19 | routeToAllProduct(){ 20 | this.router.navigate(['getAllProducts']); 21 | } 22 | 23 | routeToUpdateProduct(){ 24 | this.router.navigate(['update']); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/services/shared-service.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { SharedServiceService } from './shared-service.service'; 4 | 5 | describe('SharedServiceService', () => { 6 | let service: SharedServiceService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(SharedServiceService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/services/shared-service.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | 3 | @Injectable({ 4 | providedIn: 'root' 5 | }) 6 | export class SharedServiceService { 7 | 8 | title:string=""; 9 | content:string=""; 10 | product:any; 11 | 12 | constructor() { } 13 | 14 | setdialogtitle(title:string){ 15 | this.title=title; 16 | } 17 | 18 | setdialogcontent(content:string){ 19 | this.content=content; 20 | 21 | } 22 | 23 | getdialogtitle(){ 24 | return this.title; 25 | } 26 | getdialogcontent(){ 27 | return this.content; 28 | 29 | } 30 | 31 | setProduct(product:any){ 32 | this.product=product; 33 | } 34 | 35 | getProduct(){ 36 | return this.product; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/successful-dialog/successful-dialog.component.css: -------------------------------------------------------------------------------- 1 | .box{ 2 | background-color: green; 3 | color: white; 4 | text-align: center; 5 | padding: 10px; 6 | } -------------------------------------------------------------------------------- /AirbusInventory/src/app/successful-dialog/successful-dialog.component.html: -------------------------------------------------------------------------------- 1 | 2 |

{{title}}

3 |
{{content}}
4 |
5 | 6 |
7 | 8 | 9 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/successful-dialog/successful-dialog.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { SuccessfulDialogComponent } from './successful-dialog.component'; 4 | 5 | describe('SuccessfulDialogComponent', () => { 6 | let component: SuccessfulDialogComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ SuccessfulDialogComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(SuccessfulDialogComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/successful-dialog/successful-dialog.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { RouterService } from '../services/router.service'; 3 | import { SharedServiceService } from '../services/shared-service.service'; 4 | 5 | @Component({ 6 | selector: 'app-successful-dialog', 7 | templateUrl: './successful-dialog.component.html', 8 | styleUrls: ['./successful-dialog.component.css'] 9 | }) 10 | export class SuccessfulDialogComponent implements OnInit { 11 | 12 | title:string=""; 13 | content:string=""; 14 | 15 | constructor(private sharedservice:SharedServiceService,private routerService: RouterService) { } 16 | 17 | ngOnInit(): void { 18 | 19 | this.title=this.sharedservice.getdialogtitle(); 20 | this.content=this.sharedservice.getdialogcontent(); 21 | } 22 | 23 | 24 | refreshPage(){ 25 | this.routerService.routeToAllProduct(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/un-successful-dialog/un-successful-dialog.component.css: -------------------------------------------------------------------------------- 1 | .box{ 2 | background-color: rgb(220, 90, 90); 3 | color: white; 4 | text-align: center; 5 | padding: 10px; 6 | } -------------------------------------------------------------------------------- /AirbusInventory/src/app/un-successful-dialog/un-successful-dialog.component.html: -------------------------------------------------------------------------------- 1 | 2 |

{{title}}

3 |
{{content}}
4 |
5 | 6 |
7 | 8 | 9 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/un-successful-dialog/un-successful-dialog.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { UnSuccessfulDialogComponent } from './un-successful-dialog.component'; 4 | 5 | describe('UnSuccessfulDialogComponent', () => { 6 | let component: UnSuccessfulDialogComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ UnSuccessfulDialogComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(UnSuccessfulDialogComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/un-successful-dialog/un-successful-dialog.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { RouterService } from '../services/router.service'; 3 | import { SharedServiceService } from '../services/shared-service.service'; 4 | 5 | @Component({ 6 | selector: 'app-un-successful-dialog', 7 | templateUrl: './un-successful-dialog.component.html', 8 | styleUrls: ['./un-successful-dialog.component.css'] 9 | }) 10 | export class UnSuccessfulDialogComponent implements OnInit { 11 | 12 | 13 | title:string=""; 14 | content:string=""; 15 | constructor(private sharedservice:SharedServiceService,private routerService: RouterService) { } 16 | 17 | ngOnInit(): void { 18 | 19 | this.title=this.sharedservice.getdialogtitle(); 20 | this.content=this.sharedservice.getdialogcontent(); 21 | } 22 | 23 | 24 | refreshPage(){ 25 | this.routerService.routeToAllProduct(); 26 | } 27 | } -------------------------------------------------------------------------------- /AirbusInventory/src/app/update-product/update-product.component.css: -------------------------------------------------------------------------------- 1 | h1{ 2 | margin-top: 20px; 3 | text-align: center; 4 | color: black; 5 | } 6 | 7 | * { 8 | box-sizing: border-box; 9 | } 10 | 11 | input[type=text], select, textarea { 12 | width: 100%; 13 | padding: 12px; 14 | border: 1px solid #ccc; 15 | border-radius: 4px; 16 | resize: vertical; 17 | } 18 | 19 | input[type=number]{ 20 | width: 100%; 21 | padding: 12px; 22 | border: 1px solid #ccc; 23 | border-radius: 4px; 24 | resize: vertical; 25 | } 26 | 27 | label { 28 | padding: 12px 12px 12px 0; 29 | display: inline-block; 30 | } 31 | 32 | input[type=submit] { 33 | background-color: #3f51b5; 34 | color: white; 35 | padding: 12px 20px; 36 | border: none; 37 | border-radius: 4px; 38 | cursor: pointer; 39 | width: 100%; 40 | } 41 | 42 | input[type=submit]:hover { 43 | background-color: rgb(84, 129, 218); 44 | } 45 | 46 | .container { 47 | border-radius: 5px; 48 | background-color: #f2f2f2; 49 | padding: 20px; 50 | } 51 | 52 | .col-25 { 53 | float: left; 54 | width: 25%; 55 | margin-top: 6px; 56 | } 57 | 58 | .col-75 { 59 | float: left; 60 | width: 75%; 61 | margin-top: 6px; 62 | } 63 | 64 | /* Clear floats after the columns */ 65 | .row:after { 66 | content: ""; 67 | display: table; 68 | clear: both; 69 | } 70 | 71 | 72 | .error-message{ 73 | padding: 20px; 74 | background-color: white; 75 | color: #D32F2F; 76 | opacity: 1; 77 | transition: opacity 0.6s; 78 | margin-bottom: 15px; 79 | width: 100%; 80 | font-size: 15px; 81 | 82 | } 83 | .successMessage{ 84 | 85 | padding: 20px; 86 | background-color: white; 87 | color: #4CAF50; 88 | opacity: 1; 89 | transition: opacity 0.6s; 90 | margin-bottom: 15px; 91 | width: 100%; 92 | font-size: 15px; 93 | } 94 | 95 | 96 | /* Responsive layout - when the screen is less than 600px wide, make the two columns stack on top of each other instead of next to each other */ 97 | @media screen and (max-width: 600px) { 98 | .col-25, .col-75, input[type=submit] { 99 | width: 100%; 100 | margin-top: 0; 101 | } 102 | } -------------------------------------------------------------------------------- /AirbusInventory/src/app/update-product/update-product.component.html: -------------------------------------------------------------------------------- 1 | 2 |

Update Product

3 | 4 | 5 |
6 |
7 |
8 |
9 | 10 |
11 |
12 | 13 |
14 |
15 |
16 |
17 | 18 |
19 |
20 | 25 |
26 |
27 |
28 |
29 | 30 |
31 |
32 | 33 |
34 |
35 |
36 |
37 | 38 |
39 |
40 | 41 |
42 |
43 |
44 |
45 | 46 | 47 |
48 | 49 |
50 |
51 | 52 | 53 |
54 |
55 |
56 |
-------------------------------------------------------------------------------- /AirbusInventory/src/app/update-product/update-product.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { UpdateProductComponent } from './update-product.component'; 4 | 5 | describe('UpdateProductComponent', () => { 6 | let component: UpdateProductComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ UpdateProductComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(UpdateProductComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /AirbusInventory/src/app/update-product/update-product.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { FormControl, FormGroup, Validators } from '@angular/forms'; 3 | import { MatDialog } from '@angular/material/dialog'; 4 | import { Product } from '../Product'; 5 | import { ProductService } from '../services/product.service'; 6 | import { SharedServiceService } from '../services/shared-service.service'; 7 | import { SuccessfulDialogComponent } from '../successful-dialog/successful-dialog.component'; 8 | import { UnSuccessfulDialogComponent } from '../un-successful-dialog/un-successful-dialog.component'; 9 | 10 | @Component({ 11 | selector: 'app-update-product', 12 | templateUrl: './update-product.component.html', 13 | styleUrls: ['./update-product.component.css'] 14 | }) 15 | export class UpdateProductComponent implements OnInit { 16 | 17 | product:Product = new Product(); 18 | 19 | successMessage:string =""; 20 | errMessage: string =""; 21 | 22 | constructor(private productService: ProductService, private dialog:MatDialog, private sharedServices:SharedServiceService) { 23 | } 24 | 25 | ngOnInit(): void { 26 | 27 | this.product=this.sharedServices.getProduct(); 28 | } 29 | 30 | 31 | updateProductForm=new FormGroup({ 32 | productname:new FormControl('',[Validators.required]), 33 | units: new FormControl('',[Validators.required]), 34 | category: new FormControl('',[Validators.required]), 35 | description: new FormControl('',[Validators.required]), 36 | }) 37 | 38 | get productname(){ 39 | return this.updateProductForm.get('productname'); 40 | } 41 | 42 | get units(){ 43 | return this.updateProductForm.get('units'); 44 | } 45 | 46 | get category(){ 47 | return this.updateProductForm.get('category'); 48 | } 49 | 50 | get description(){ 51 | return this.updateProductForm.get('description'); 52 | } 53 | 54 | updateProduct(){ 55 | 56 | this.product.productName=this.productname?.value; 57 | this.product.units=this.units?.value; 58 | this.product.productCategory=this.category?.value; 59 | this.product.productDescription=this.description?.value; 60 | 61 | 62 | 63 | if(this.product.productId=="") 64 | { 65 | this.errMessage="Product could not be Added to the catalog : Product Id is required"; 66 | } 67 | else if(this.product.productName=="") 68 | { 69 | this.errMessage="Product could not be Added to the catalog : Product Name is required"; 70 | } 71 | else if(this.product.productCategory=="") 72 | { 73 | this.errMessage="Product could not be Added to the catalog : Product Category is required"; 74 | } 75 | else if(this.product.units==0 || this.product.units==null) 76 | { 77 | this.errMessage="Product could not be Added to the catalog : Product Units can not be 0"; 78 | } 79 | else if(this.product.productDescription=="") 80 | { 81 | this.errMessage="Product could not be Added to the catalog : Product Description is required"; 82 | } 83 | else{ 84 | this.productService.updateProduct(this.product, this.product.productId).subscribe(data => { 85 | 86 | if(data) 87 | { 88 | this.openSuccessfulDialog(); 89 | } 90 | else{ 91 | this.openunSuccessfulDialog(); 92 | } 93 | 94 | }); 95 | 96 | } 97 | 98 | } 99 | 100 | openSuccessfulDialog() { 101 | this.sharedServices.setdialogtitle("Successfull"); 102 | this.sharedServices.setdialogcontent("Product Updated Successfully !!"); 103 | this.dialog.open(SuccessfulDialogComponent); 104 | } 105 | 106 | openunSuccessfulDialog() { 107 | this.sharedServices.setdialogtitle("Unsuccessfull"); 108 | this.sharedServices.setdialogcontent("Product could not be Updated !!"); 109 | this.dialog.open(UnSuccessfulDialogComponent); 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /AirbusInventory/src/assets/airbus.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Akash-goyal-github/Inventory-Management-System/256ebe9d834c690e2d1c639dfefd00df6f3c408b/AirbusInventory/src/assets/airbus.webp -------------------------------------------------------------------------------- /AirbusInventory/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /AirbusInventory/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/plugins/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /AirbusInventory/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Akash-goyal-github/Inventory-Management-System/256ebe9d834c690e2d1c639dfefd00df6f3c408b/AirbusInventory/src/favicon.ico -------------------------------------------------------------------------------- /AirbusInventory/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AirbusInventory 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /AirbusInventory/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /AirbusInventory/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** 22 | * IE11 requires the following for NgClass support on SVG elements 23 | */ 24 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 25 | 26 | /** 27 | * Web Animations `@angular/platform-browser/animations` 28 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 29 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 30 | */ 31 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 32 | 33 | /** 34 | * By default, zone.js will patch all possible macroTask and DomEvents 35 | * user can disable parts of macroTask/DomEvents patch by setting following flags 36 | * because those flags need to be set before `zone.js` being loaded, and webpack 37 | * will put import in the top of bundle, so user need to create a separate file 38 | * in this directory (for example: zone-flags.ts), and put the following flags 39 | * into that file, and then add the following code before importing zone.js. 40 | * import './zone-flags'; 41 | * 42 | * The flags allowed in zone-flags.ts are listed here. 43 | * 44 | * The following flags will work for all browsers. 45 | * 46 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 47 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 48 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 49 | * 50 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 51 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 52 | * 53 | * (window as any).__Zone_enable_cross_context_check = true; 54 | * 55 | */ 56 | 57 | /*************************************************************************************************** 58 | * Zone JS is required by default for Angular itself. 59 | */ 60 | import 'zone.js'; // Included with Angular CLI. 61 | 62 | 63 | /*************************************************************************************************** 64 | * APPLICATION IMPORTS 65 | */ 66 | -------------------------------------------------------------------------------- /AirbusInventory/src/styles.css: -------------------------------------------------------------------------------- 1 | @import "~@angular/material/prebuilt-themes/indigo-pink.css"; 2 | body, 3 | html { 4 | margin: 0 auto; 5 | height: 100%; 6 | } -------------------------------------------------------------------------------- /AirbusInventory/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: { 11 | context(path: string, deep?: boolean, filter?: RegExp): { 12 | keys(): string[]; 13 | (id: string): T; 14 | }; 15 | }; 16 | 17 | // First, initialize the Angular testing environment. 18 | getTestBed().initTestEnvironment( 19 | BrowserDynamicTestingModule, 20 | platformBrowserDynamicTesting(), 21 | { teardown: { destroyAfterEach: true }}, 22 | ); 23 | 24 | // Then we find all the tests. 25 | const context = require.context('./', true, /\.spec\.ts$/); 26 | // And load the modules. 27 | context.keys().map(context); 28 | -------------------------------------------------------------------------------- /AirbusInventory/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": [ 9 | "src/main.ts", 10 | "src/polyfills.ts" 11 | ], 12 | "include": [ 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /AirbusInventory/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "compileOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": "./", 6 | "outDir": "./dist/out-tsc", 7 | "forceConsistentCasingInFileNames": true, 8 | "strict": true, 9 | "noImplicitReturns": true, 10 | "noFallthroughCasesInSwitch": true, 11 | "sourceMap": true, 12 | "declaration": false, 13 | "downlevelIteration": true, 14 | "experimentalDecorators": true, 15 | "moduleResolution": "node", 16 | "importHelpers": true, 17 | "target": "es2017", 18 | "module": "es2020", 19 | "lib": [ 20 | "es2018", 21 | "dom" 22 | ] 23 | }, 24 | "angularCompilerOptions": { 25 | "enableI18nLegacyMessageIdFormat": false, 26 | "strictInjectionParameters": true, 27 | "strictInputAccessModifiers": true, 28 | "strictTemplates": true 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /AirbusInventory/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/spec", 6 | "types": [ 7 | "jasmine" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /Problem Statement.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Akash-goyal-github/Inventory-Management-System/256ebe9d834c690e2d1c639dfefd00df6f3c408b/Problem Statement.PNG -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Airbus Inventory Management System

2 | 3 | --- 4 | 5 | [Objective:](https://github.com/Akash-goyal-github/Inventory-Management-System/blob/main/Problem%20Statement.PNG) 6 | 7 | 1. Design and implement the REST APIs to integrate with Sql database 8 | 1. GET all products of a given category 9 | 2. GET all products 10 | 3. POST to add new product 11 | 4. PUT to update a existing product 12 | 5. Delete a product 13 | 2. Implement APIs with the best REST Practices. 14 | 3. Implement custom error handling in APIs to gracefully handle all exceptions. 15 | 4. Use JWT Tokens and validate all endpoints for security. 16 | 5. Develop a UI: 17 | 1. Use REST APIs to display all the product names, description and units in a table, 18 | 2. Filters for data. 19 | 3. Add / Update the product. 20 | 4. Search Product based on Category 21 | 22 | 23 | RoadMap: 24 | 25 | 1. Login to the Angular Application. 26 | 27 | Default Login Credentials: 28 | username: airbus02@gmail.com 29 | password:1234 30 | 31 | 2. Perform Any CRUD Operations. 32 | 33 | Actions: 34 | 35 | 1. Fork this repository. 36 | 2. Clone the repository and cd into spring boot files. 37 | 3. Install dependencies through npm install in Angular AirbusInventory. 38 | 5. Create database and tables in your Local System:- 39 | 1. Create a Database in your system: create database Product; 40 | 2. Create Product, User Tables 41 | (commands given below in Road Map Test and also in Spring -> src/main/resources-> schema.sql) 42 | 6. Run the airbus-management-spring as Spring boot App on the server port 8080 and configure the datasource with your mysql user credentials(in Application Properties). 43 | 7. Run the frontend -ng serve which shall run on port:4200. 44 | 45 | --- 46 | 47 | RoadMap to test Inventory Management System project: 48 | ----------------------------------------------------------------------------------------------- 49 | 50 | This project was generated with Angular CLI: 12.2.3. 51 | 52 | Create Tables : Go to 53 | ----------------------------------------------------------------------------------------------- 54 | 55 | Credentials to login to my sql:- (change in application.properties file in Spring Project) 56 | 57 | 1. Creating Product Database- 58 | 59 | create database Product; 60 | 61 | 2. Creating Product Table- 62 | 63 | use Product; 64 | drop table Product; 65 | create table Product( 66 | productId varchar(256) Unique not null, 67 | productName varchar(256), 68 | productDescription varchar(3500), 69 | productCategory varchar(256), 70 | units int 71 | ); 72 | 73 | 3. Creating User Table- 74 | 75 | 76 | drop table User; 77 | create table User( 78 | username varchar(256), 79 | password varchar(256) 80 | ); 81 | 82 | 4. Inserting Manual Data in user Table- 83 | 84 | use Product; 85 | insert into User(username,password) Values("airbus01@gmail.com","$2a$10$slYQmyNdGzTn7ZLBXBChFOC9f6kFjAqPhccnP6DxlWXx2lPk1C3G6"); 86 | insert into User(username,password) Values("airbus02","$2a$10$ZnnAdfh3cc7a/b1aODLeoOjifNPbHL6Vo8kpRJj.muPsVp1697hJO"); 87 | 88 | //These are encrypted password using Bcrypt.( We have used Bcrypt so that no one can access our password from database. 89 | 90 | 1st one means:- username - airbus01@gmail.com, password- password 91 | 2nd one means:- username - airbus02@gmail.com, password- 1234 92 | 93 | 94 | Note:- The same SQL Statements are also present in schema.sql file (Under src/main/resources) 95 | ----------------------------------------------------------------------------------------------- 96 | 97 | 98 | # Know your server: 99 | 100 | 1. Login to the application - 101 | 102 | Post Request - http://localhost:8080/airbusManagement/JWT/authenticateUser 103 | 104 | Expecting Json data-{username, password} 105 | 106 | Assumptions:- 107 | 108 | 1. username should be of Email Id format. 109 | 2. username and password can not be Null. 110 | 111 | Default Login Credentials: 112 | username: airbus02@gmail.com 113 | password:1234 114 | 115 | 2. GET all products - 116 | 117 | Get Request - http://localhost:8080/airbusManagement/getAllProducts 118 | 119 | expecting header - { 'Authorization', Bearer ${token} }. 120 | 121 | 122 | 3. GET all products of a given category - 123 | 124 | Get Request - http://localhost:8080/airbusManagement/getProductsByCategory/{categoryName} 125 | 126 | expecting header - { 'Authorization', Bearer ${token} }. 127 | 128 | 4. Add all products - 129 | 130 | Post Request - http://localhost:8080/airbusManagement/addProduct 131 | 132 | Expecting Json data - {productId,productName,productDescription,productCategory,units} 133 | expecting header - { 'Authorization', Bearer ${token} }. 134 | 135 | 136 | 5. Update product - 137 | 138 | Post Request - http://localhost:8080/airbusManagement/updateProduct/{ProductId} 139 | 140 | Expecting Json data - {productId,productName,productDescription,productCategory,units} 141 | expecting header - { 'Authorization', Bearer ${token} }. 142 | 143 | 144 | 6. Delete product- 145 | 146 | Delete Request - http://localhost:8080/airbusManagement/deleteProduct/{ProductId} 147 | 148 | expecting header - { 'Authorization', Bearer ${token} }. 149 | 150 | 151 | Stack: 152 | 153 | -Spring Boot Application 154 | -Spring MVC 155 | -Spring Jdbc 156 | -Maven 157 | -sql database 158 | -Angular 159 | 160 | 161 | Steps to be followed in running Angular: 162 | 163 | 1.npm install, npm run build, npm serve. 164 | 165 | features used for UI display: 166 | 167 | 1. Angular Material 168 | 2. Responsive Design, Bootstrap, HTML 5.1, CSS 169 | 170 | For further help: 171 | 172 | To get more help on the Angular CLI use ng help or go check out the Angular CLI README. 173 | 174 | ----------------------------------------------------------------------------------------------- 175 | 176 | -------------------------------------------------------------------------------- /airbus-management-spring/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /airbus-management-spring/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /airbus-management-spring/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Akash-goyal-github/Inventory-Management-System/256ebe9d834c690e2d1c639dfefd00df6f3c408b/airbus-management-spring/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /airbus-management-spring/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.2/apache-maven-3.8.2-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /airbus-management-spring/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | -------------------------------------------------------------------------------- /airbus-management-spring/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /airbus-management-spring/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.5.5 9 | 10 | 11 | com.airbus 12 | airbus-management-spring 13 | 0.0.1-SNAPSHOT 14 | airbus-management-spring 15 | Demo project for Spring Boot 16 | 17 | 1.8 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-jdbc 23 | 24 | 25 | 26 | com.h2database 27 | h2 28 | runtime 29 | 30 | 31 | mysql 32 | mysql-connector-java 33 | runtime 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-security 38 | 39 | 40 | io.jsonwebtoken 41 | jjwt 42 | 0.9.1 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-starter-web 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-starter-web-services 51 | 52 | 53 | 54 | org.springframework.boot 55 | spring-boot-devtools 56 | runtime 57 | true 58 | 59 | 60 | org.apache.commons 61 | commons-lang3 62 | 3.0 63 | 64 | 85 | 86 | org.springframework.boot 87 | spring-boot-starter-test 88 | test 89 | 90 | 91 | io.projectreactor 92 | reactor-test 93 | test 94 | 95 | 96 | junit 97 | junit 98 | 4.13.2 99 | test 100 | 101 | 102 | 103 | org.mockito 104 | mockito-all 105 | 1.10.19 106 | test 107 | 108 | 109 | 110 | org.springframework 111 | spring-test 112 | 5.1.18.RELEASE 113 | test 114 | 115 | 116 | org.mockito 117 | mockito-core 118 | 3.12.4 119 | test 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | org.springframework.boot 128 | spring-boot-maven-plugin 129 | 130 | 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /airbus-management-spring/src/main/java/com/airbus/management/AirbusManagementSpringApplication.java: -------------------------------------------------------------------------------- 1 | package com.airbus.management; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class AirbusManagementSpringApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(AirbusManagementSpringApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /airbus-management-spring/src/main/java/com/airbus/management/config/JwtAuthenticationEntryPoint.java: -------------------------------------------------------------------------------- 1 | package com.airbus.management.config; 2 | 3 | import java.io.IOException; 4 | import java.io.Serializable; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | 9 | import org.springframework.security.core.AuthenticationException; 10 | import org.springframework.security.web.AuthenticationEntryPoint; 11 | import org.springframework.stereotype.Component; 12 | 13 | @Component 14 | public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint, Serializable { 15 | 16 | private static final long serialVersionUID = -7858869558953243875L; 17 | 18 | @Override 19 | public void commence(HttpServletRequest request, HttpServletResponse response, 20 | AuthenticationException authException) throws IOException { 21 | 22 | response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); 23 | } 24 | } -------------------------------------------------------------------------------- /airbus-management-spring/src/main/java/com/airbus/management/config/JwtRequestFilter.java: -------------------------------------------------------------------------------- 1 | package com.airbus.management.config; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.servlet.FilterChain; 6 | import javax.servlet.ServletException; 7 | import javax.servlet.http.HttpServletRequest; 8 | import javax.servlet.http.HttpServletResponse; 9 | 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 12 | import org.springframework.security.core.context.SecurityContextHolder; 13 | import org.springframework.security.core.userdetails.UserDetails; 14 | import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; 15 | import org.springframework.stereotype.Component; 16 | import org.springframework.web.bind.annotation.CrossOrigin; 17 | import org.springframework.web.filter.OncePerRequestFilter; 18 | 19 | import com.airbus.management.service.JwtUserDetailsService; 20 | 21 | import io.jsonwebtoken.ExpiredJwtException; 22 | 23 | @Component 24 | public class JwtRequestFilter extends OncePerRequestFilter { 25 | 26 | @Autowired 27 | private JwtUserDetailsService jwtUserDetailsService; 28 | 29 | @Autowired 30 | private JwtTokenUtil jwtTokenUtil; 31 | 32 | @Override 33 | protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) 34 | throws ServletException, IOException { 35 | 36 | final String requestTokenHeader = request.getHeader("Authorization"); 37 | 38 | String username = null; 39 | String jwtToken = null; 40 | // JWT Token is in the form "Bearer token". Remove Bearer word and get 41 | // only the Token 42 | if (requestTokenHeader != null && requestTokenHeader.startsWith("Bearer ")) { 43 | jwtToken = requestTokenHeader.substring(7); 44 | try { 45 | username = jwtTokenUtil.getUsernameFromToken(jwtToken); 46 | } catch (IllegalArgumentException e) { 47 | System.out.println("Unable to get JWT Token"); 48 | } catch (ExpiredJwtException e) { 49 | System.out.println("JWT Token has expired"); 50 | } 51 | } else { 52 | 53 | System.out.println(requestTokenHeader); 54 | logger.warn("JWT Token does not begin with Bearer String"); 55 | } 56 | 57 | // Once we get the token validate it. 58 | if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) { 59 | 60 | UserDetails userDetails = this.jwtUserDetailsService.loadUserByUsername(username); 61 | 62 | // if token is valid configure Spring Security to manually set 63 | // authentication 64 | if (jwtTokenUtil.validateToken(jwtToken, userDetails)) { 65 | 66 | UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken( 67 | userDetails, null, userDetails.getAuthorities()); 68 | usernamePasswordAuthenticationToken 69 | .setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); 70 | // After setting the Authentication in the context, we specify 71 | // that the current user is authenticated. So it passes the 72 | // Spring Security Configurations successfully. 73 | SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken); 74 | } 75 | } 76 | chain.doFilter(request, response); 77 | } 78 | 79 | } -------------------------------------------------------------------------------- /airbus-management-spring/src/main/java/com/airbus/management/config/JwtTokenUtil.java: -------------------------------------------------------------------------------- 1 | package com.airbus.management.config; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | import java.util.function.Function; 8 | 9 | import org.springframework.beans.factory.annotation.Value; 10 | import org.springframework.security.core.userdetails.UserDetails; 11 | import org.springframework.stereotype.Component; 12 | 13 | import io.jsonwebtoken.Claims; 14 | import io.jsonwebtoken.Jwts; 15 | import io.jsonwebtoken.SignatureAlgorithm; 16 | 17 | @Component 18 | public class JwtTokenUtil implements Serializable { 19 | private static final long serialVersionUID = -2550185165626007488L; 20 | 21 | public static final long JWT_TOKEN_VALIDITY = 5 * 60 * 60; 22 | 23 | @Value("${jwt.secret}") 24 | private String secret; 25 | 26 | //retrieve username from jwt token 27 | public String getUsernameFromToken(String token) { 28 | return getClaimFromToken(token, Claims::getSubject); 29 | } 30 | 31 | //retrieve expiration date from jwt token 32 | public Date getExpirationDateFromToken(String token) { 33 | return getClaimFromToken(token, Claims::getExpiration); 34 | } 35 | 36 | public T getClaimFromToken(String token, Function claimsResolver) { 37 | final Claims claims = getAllClaimsFromToken(token); 38 | return claimsResolver.apply(claims); 39 | } 40 | //for retrieveing any information from token we will need the secret key 41 | private Claims getAllClaimsFromToken(String token) { 42 | return Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody(); 43 | } 44 | 45 | //check if the token has expired 46 | private Boolean isTokenExpired(String token) { 47 | final Date expiration = getExpirationDateFromToken(token); 48 | return expiration.before(new Date()); 49 | } 50 | 51 | //generate token for user 52 | public String generateToken(UserDetails userDetails) { 53 | Map claims = new HashMap<>(); 54 | return doGenerateToken(claims, userDetails.getUsername()); 55 | } 56 | 57 | //while creating the token - 58 | //1. Define claims of the token, like Issuer, Expiration, Subject, and the ID 59 | //2. Sign the JWT using the HS512 algorithm and secret key. 60 | //3. According to JWS Compact Serialization(https://tools.ietf.org/html/draft-ietf-jose-json-web-signature-41#section-3.1) 61 | // compaction of the JWT to a URL-safe string 62 | private String doGenerateToken(Map claims, String subject) { 63 | 64 | return Jwts.builder().setClaims(claims).setSubject(subject).setIssuedAt(new Date(System.currentTimeMillis())) 65 | .setExpiration(new Date(System.currentTimeMillis() + JWT_TOKEN_VALIDITY * 1000)) 66 | .signWith(SignatureAlgorithm.HS512, secret).compact(); 67 | } 68 | 69 | //validate token 70 | public Boolean validateToken(String token, UserDetails userDetails) { 71 | final String username = getUsernameFromToken(token); 72 | return (username.equals(userDetails.getUsername()) && !isTokenExpired(token)); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /airbus-management-spring/src/main/java/com/airbus/management/config/WebSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.airbus.management.config; 2 | 3 | 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.security.authentication.AuthenticationManager; 8 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 9 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 10 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 11 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 12 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 13 | import org.springframework.security.config.http.SessionCreationPolicy; 14 | import org.springframework.security.core.userdetails.UserDetailsService; 15 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 16 | import org.springframework.security.crypto.password.PasswordEncoder; 17 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; 18 | 19 | 20 | @Configuration 21 | @EnableWebSecurity 22 | @EnableGlobalMethodSecurity(prePostEnabled = true) 23 | public class WebSecurityConfig extends WebSecurityConfigurerAdapter { 24 | 25 | @Autowired 26 | private JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint; 27 | 28 | @Autowired 29 | private UserDetailsService jwtUserDetailsService; 30 | 31 | @Autowired 32 | private JwtRequestFilter jwtRequestFilter; 33 | 34 | @Autowired 35 | public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { 36 | // configure AuthenticationManager so that it knows from where to load 37 | // user for matching credentials 38 | // Use BCryptPasswordEncoder 39 | auth.userDetailsService(jwtUserDetailsService).passwordEncoder(passwordEncoder()); 40 | } 41 | 42 | @Bean 43 | public PasswordEncoder passwordEncoder() { 44 | return new BCryptPasswordEncoder(); 45 | } 46 | 47 | @Bean 48 | @Override 49 | public AuthenticationManager authenticationManagerBean() throws Exception { 50 | return super.authenticationManagerBean(); 51 | } 52 | 53 | @Override 54 | protected void configure(HttpSecurity httpSecurity) throws Exception { 55 | // We don't need CSRF for this example 56 | httpSecurity.cors().and().csrf().disable() 57 | // dont authenticate this particular request 58 | .authorizeRequests().antMatchers("/airbusManagement/JWT/authenticateUser").permitAll(). 59 | // all other requests need to be authenticated 60 | anyRequest().authenticated().and(). 61 | // make sure we use stateless session; session won't be used to 62 | // store user's state. 63 | exceptionHandling().authenticationEntryPoint(jwtAuthenticationEntryPoint).and().sessionManagement() 64 | .sessionCreationPolicy(SessionCreationPolicy.STATELESS); 65 | 66 | // Add a filter to validate the tokens with every request 67 | httpSecurity.addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class); 68 | } 69 | } -------------------------------------------------------------------------------- /airbus-management-spring/src/main/java/com/airbus/management/controller/JwtAuthenticationController.java: -------------------------------------------------------------------------------- 1 | package com.airbus.management.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.security.authentication.AuthenticationManager; 6 | import org.springframework.security.authentication.BadCredentialsException; 7 | import org.springframework.security.authentication.DisabledException; 8 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 9 | import org.springframework.security.core.userdetails.UserDetails; 10 | import org.springframework.web.bind.annotation.CrossOrigin; 11 | import org.springframework.web.bind.annotation.RequestBody; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RequestMethod; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | import com.airbus.management.config.JwtTokenUtil; 17 | import com.airbus.management.model.JwtResponse; 18 | import com.airbus.management.model.User; 19 | import com.airbus.management.service.JwtUserDetailsService; 20 | 21 | @CrossOrigin(origins = "*", maxAge = 3600) 22 | @RestController 23 | @RequestMapping("/airbusManagement/JWT") 24 | public class JwtAuthenticationController { 25 | 26 | @Autowired 27 | private AuthenticationManager authenticationManager; 28 | 29 | @Autowired 30 | private JwtTokenUtil jwtTokenUtil; 31 | 32 | @Autowired 33 | private JwtUserDetailsService userDetailsService; 34 | 35 | @RequestMapping(value = "/authenticateUser", method = RequestMethod.POST) 36 | public ResponseEntity createAuthenticationToken(@RequestBody User authenticationRequest) throws Exception { 37 | 38 | authenticate(authenticationRequest.getUsername(), authenticationRequest.getPassword()); 39 | 40 | final UserDetails userDetails = userDetailsService 41 | .loadUserByUsername(authenticationRequest.getUsername()); 42 | 43 | final String token = jwtTokenUtil.generateToken(userDetails); 44 | return ResponseEntity.ok(new JwtResponse(token)); 45 | } 46 | 47 | private void authenticate(String username, String password) throws Exception { 48 | try { 49 | authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password)); 50 | } catch (DisabledException e) { 51 | throw new Exception("USER_DISABLED", e); 52 | } catch (BadCredentialsException e) { 53 | throw new Exception("INVALID_CREDENTIALS", e); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /airbus-management-spring/src/main/java/com/airbus/management/controller/MainController.java: -------------------------------------------------------------------------------- 1 | package com.airbus.management.controller; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.CrossOrigin; 7 | import org.springframework.web.bind.annotation.DeleteMapping; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.PostMapping; 11 | import org.springframework.web.bind.annotation.RequestBody; 12 | import org.springframework.web.bind.annotation.RequestHeader; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | import com.airbus.management.exception.ProductAlreadyExistsException; 17 | import com.airbus.management.model.Product; 18 | import com.airbus.management.service.ProductService; 19 | import com.fasterxml.jackson.core.JsonProcessingException; 20 | import com.fasterxml.jackson.databind.ObjectMapper; 21 | import com.fasterxml.jackson.databind.SerializationFeature; 22 | 23 | @CrossOrigin(origins = "*", maxAge = 3600) 24 | @RestController 25 | @RequestMapping("/airbusManagement") 26 | public class MainController { 27 | 28 | @Autowired 29 | ProductService productService; 30 | 31 | ObjectMapper objectMapper = new ObjectMapper().configure(SerializationFeature.INDENT_OUTPUT, true); 32 | 33 | @GetMapping("/getAllProducts") 34 | public Object getAllProducts(){ 35 | List result= productService.getAllProducts(); 36 | return result; 37 | } 38 | 39 | @GetMapping("/getProductsByCategory/{key}") 40 | public Object getProductsByCategory(@PathVariable("key") String categoryName) throws JsonProcessingException{ 41 | 42 | List result= productService.getProductsByCategory(categoryName); 43 | String listToJson = objectMapper.writeValueAsString(result); 44 | return listToJson; 45 | } 46 | 47 | @PostMapping("/addProduct") 48 | public boolean addProduct(@RequestBody Product producDetails) throws JsonProcessingException, ProductAlreadyExistsException{ 49 | 50 | boolean response = productService.addProduct(producDetails); 51 | return response; 52 | } 53 | 54 | @PostMapping("updateProduct/{productId}") 55 | public boolean updateProduct(@RequestBody Product productDetails,@PathVariable("productId") String productId) { 56 | boolean result= productService.updateProduct(productDetails, productId); 57 | return result; 58 | } 59 | 60 | @DeleteMapping("deleteProduct/{productId}") 61 | public boolean deleteProduct(@PathVariable("productId") String productId) { 62 | boolean result= productService.deleteProduct(productId); 63 | return result; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /airbus-management-spring/src/main/java/com/airbus/management/exception/ProductAlreadyExistsException.java: -------------------------------------------------------------------------------- 1 | package com.airbus.management.exception; 2 | 3 | public class ProductAlreadyExistsException extends Exception{ 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | public ProductAlreadyExistsException(String message) { 8 | super(message); 9 | } 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /airbus-management-spring/src/main/java/com/airbus/management/model/JwtResponse.java: -------------------------------------------------------------------------------- 1 | package com.airbus.management.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class JwtResponse implements Serializable { 6 | 7 | private static final long serialVersionUID = -8091879091924046844L; 8 | private final String jwttoken; 9 | 10 | public JwtResponse(String jwttoken) { 11 | this.jwttoken = jwttoken; 12 | } 13 | 14 | public String getToken() { 15 | return this.jwttoken; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /airbus-management-spring/src/main/java/com/airbus/management/model/Product.java: -------------------------------------------------------------------------------- 1 | package com.airbus.management.model; 2 | 3 | public class Product { 4 | 5 | private String productId; 6 | private String productName; 7 | private String productDescription; 8 | private String productCategory; 9 | private int units; 10 | 11 | 12 | public Product() { 13 | super(); 14 | } 15 | 16 | 17 | public Product(String productId, String productName, String productDescription, String productCategory, int units) { 18 | super(); 19 | this.productId = productId; 20 | this.productName = productName; 21 | this.productDescription = productDescription; 22 | this.productCategory = productCategory; 23 | this.units = units; 24 | } 25 | 26 | 27 | public String getProductId() { 28 | return productId; 29 | } 30 | 31 | 32 | public void setProductId(String productId) { 33 | this.productId = productId; 34 | } 35 | 36 | 37 | public String getProductName() { 38 | return productName; 39 | } 40 | 41 | 42 | public void setProductName(String productName) { 43 | this.productName = productName; 44 | } 45 | 46 | 47 | public String getProductDescription() { 48 | return productDescription; 49 | } 50 | 51 | 52 | public void setProductDescription(String productDescription) { 53 | this.productDescription = productDescription; 54 | } 55 | 56 | 57 | public String getProductCategory() { 58 | return productCategory; 59 | } 60 | 61 | 62 | public void setProductCategory(String productCategory) { 63 | this.productCategory = productCategory; 64 | } 65 | 66 | 67 | public int getUnits() { 68 | return units; 69 | } 70 | 71 | 72 | public void setUnits(int units) { 73 | this.units = units; 74 | } 75 | 76 | 77 | @Override 78 | public String toString() { 79 | return "Product [productId=" + productId + ", productName=" + productName + ", productDescription=" 80 | + productDescription + ", productCategory=" + productCategory + ", units=" + units + "]"; 81 | } 82 | 83 | 84 | 85 | } 86 | -------------------------------------------------------------------------------- /airbus-management-spring/src/main/java/com/airbus/management/model/User.java: -------------------------------------------------------------------------------- 1 | package com.airbus.management.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class User implements Serializable{ 6 | 7 | private static final long serialVersionUID = 5926468583005150707L; 8 | 9 | private String username; 10 | private String password; 11 | 12 | 13 | public User() { 14 | super(); 15 | } 16 | 17 | 18 | public User(String username, String password) { 19 | super(); 20 | this.username = username; 21 | this.password = password; 22 | } 23 | 24 | 25 | public String getUsername() { 26 | return username; 27 | } 28 | 29 | 30 | public void setUsername(String username) { 31 | this.username = username; 32 | } 33 | 34 | 35 | public String getPassword() { 36 | return password; 37 | } 38 | 39 | 40 | public void setPassword(String password) { 41 | this.password = password; 42 | } 43 | 44 | 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /airbus-management-spring/src/main/java/com/airbus/management/repository/ProductServiceRepository.java: -------------------------------------------------------------------------------- 1 | package com.airbus.management.repository; 2 | 3 | import java.sql.PreparedStatement; 4 | import java.sql.ResultSet; 5 | import java.sql.SQLException; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.jdbc.core.BatchPreparedStatementSetter; 11 | import org.springframework.jdbc.core.JdbcTemplate; 12 | import org.springframework.jdbc.core.RowMapper; 13 | import org.springframework.stereotype.Repository; 14 | 15 | import com.airbus.management.model.Product; 16 | 17 | @Repository 18 | public class ProductServiceRepository { 19 | 20 | @Autowired 21 | private JdbcTemplate jdbcTemplate; 22 | 23 | 24 | public List getAllProducts() { 25 | 26 | 27 | List productList=new ArrayList<>(); 28 | 29 | productList=jdbcTemplate.query("SELECT *from Product", new RowMapper(){ 30 | 31 | @Override 32 | public Product mapRow(ResultSet rs, int rowNum) throws SQLException { 33 | // TODO Auto-generated method stub 34 | 35 | Product product=new Product(); 36 | product.setProductId(rs.getString("productId")); 37 | product.setProductName(rs.getString("productName")); 38 | product.setProductDescription(rs.getString("productDescription")); 39 | product.setProductCategory(rs.getString("productCategory")); 40 | product.setUnits(rs.getInt("units")); 41 | 42 | 43 | return product; 44 | } 45 | }); 46 | 47 | return productList; 48 | } 49 | 50 | public List getProductsByCategory(String categoryName) { 51 | 52 | List productList=new ArrayList<>(); 53 | 54 | productList=jdbcTemplate.query("SELECT *from Product where lower(productCategory)='"+categoryName.toLowerCase()+"'", new RowMapper(){ 55 | 56 | @Override 57 | public Product mapRow(ResultSet rs, int rowNum) throws SQLException { 58 | // TODO Auto-generated method stub 59 | 60 | Product product=new Product(); 61 | product.setProductId(rs.getString("productId")); 62 | product.setProductName(rs.getString("productName")); 63 | product.setProductDescription(rs.getString("productDescription")); 64 | product.setProductCategory(rs.getString("productCategory")); 65 | product.setUnits(rs.getInt("units")); 66 | 67 | 68 | return product; 69 | } 70 | }); 71 | return productList; 72 | } 73 | 74 | 75 | public void addProduct(Product productDetails) { 76 | 77 | String INSERT_STATEMENT = "INSERT INTO Product(productId,productName,productDescription,productCategory, units) VALUES (?,?,?,?,?)" ; 78 | 79 | jdbcTemplate.batchUpdate(INSERT_STATEMENT, new BatchPreparedStatementSetter() { 80 | 81 | @Override 82 | public void setValues(PreparedStatement ps, int i) throws SQLException { 83 | // TODO Auto-generated method stub 84 | ps.setString(1,productDetails.getProductId()); 85 | ps.setString(2, productDetails.getProductName()); 86 | ps.setString(3, productDetails.getProductDescription()); 87 | ps.setString(4, productDetails.getProductCategory()); 88 | ps.setInt(5, productDetails.getUnits()); 89 | } 90 | 91 | @Override 92 | public int getBatchSize() { 93 | // TODO Auto-generated method stub 94 | return 1; 95 | } 96 | }); 97 | } 98 | 99 | public int updateProduct(Product productDetails, String productId) { 100 | 101 | String query="UPDATE Product set productName='"+productDetails.getProductName()+"',productDescription='"+productDetails.getProductDescription()+"',productCategory='"+productDetails.getProductCategory()+"',units='"+productDetails.getUnits()+"' where productId='"+productId+"' "; 102 | return jdbcTemplate.update(query); 103 | } 104 | 105 | public int deleteProduct(String productId){ 106 | String query="delete from product where productId='"+productId+"' "; 107 | return jdbcTemplate.update(query); 108 | } 109 | 110 | public String fetchPasswordForUserName(String userName) { 111 | 112 | String result=""; 113 | 114 | String query="SELECT password from User where username='"+ userName+"'"; 115 | 116 | result= jdbcTemplate.queryForObject(query,String.class); 117 | 118 | return result; 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /airbus-management-spring/src/main/java/com/airbus/management/service/JwtUserDetailsService.java: -------------------------------------------------------------------------------- 1 | package com.airbus.management.service; 2 | 3 | import java.util.ArrayList; 4 | 5 | import org.apache.commons.lang3.StringUtils; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.security.core.userdetails.User; 8 | import org.springframework.security.core.userdetails.UserDetails; 9 | import org.springframework.security.core.userdetails.UserDetailsService; 10 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 11 | import org.springframework.stereotype.Service; 12 | 13 | import com.airbus.management.repository.ProductServiceRepository; 14 | 15 | @Service 16 | public class JwtUserDetailsService implements UserDetailsService { 17 | 18 | 19 | @Autowired 20 | ProductServiceRepository productServiceRepository; 21 | 22 | 23 | @Override 24 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 25 | // TODO Auto-generated method stub 26 | 27 | String response= productServiceRepository.fetchPasswordForUserName(username); 28 | 29 | System.out.println(response); 30 | if (!response.equals("")) { 31 | return new User(username,response, 32 | new ArrayList<>()); 33 | } else { 34 | throw new UsernameNotFoundException("User not found with username: " + username); 35 | } 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /airbus-management-spring/src/main/java/com/airbus/management/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.airbus.management.service; 2 | 3 | import java.util.List; 4 | 5 | import com.airbus.management.exception.ProductAlreadyExistsException; 6 | import com.airbus.management.model.Product; 7 | 8 | public interface ProductService { 9 | 10 | public List getAllProducts(); 11 | public List getProductsByCategory(String categoryName); 12 | public boolean addProduct(Product productDetails) throws ProductAlreadyExistsException; 13 | public boolean updateProduct(Product productDetails,String productId); 14 | public boolean deleteProduct(String productId); 15 | } 16 | -------------------------------------------------------------------------------- /airbus-management-spring/src/main/java/com/airbus/management/service/ProductServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.airbus.management.service; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import com.airbus.management.exception.ProductAlreadyExistsException; 10 | import com.airbus.management.model.Product; 11 | import com.airbus.management.repository.ProductServiceRepository; 12 | 13 | @Repository 14 | public class ProductServiceImpl implements ProductService { 15 | 16 | @Autowired 17 | ProductServiceRepository productServiceRepository; 18 | 19 | @Override 20 | public List getAllProducts() { 21 | // TODO Auto-generated method stub 22 | 23 | List result=new ArrayList<>(); 24 | 25 | try { 26 | result= productServiceRepository.getAllProducts(); 27 | } 28 | catch(Exception e) 29 | { 30 | e.printStackTrace(); 31 | } 32 | return result; 33 | 34 | } 35 | 36 | @Override 37 | public List getProductsByCategory(String categoryName) { 38 | // TODO Auto-generated method stub 39 | List result=new ArrayList<>(); 40 | 41 | try { 42 | result= productServiceRepository.getProductsByCategory(categoryName); 43 | } 44 | catch(Exception e) 45 | { 46 | e.printStackTrace(); 47 | } 48 | return result; 49 | } 50 | 51 | @Override 52 | public boolean addProduct(Product productDetails) throws ProductAlreadyExistsException { 53 | // TODO Auto-generated method stub 54 | boolean result; 55 | 56 | try { 57 | productServiceRepository.addProduct(productDetails); 58 | result=true; 59 | } 60 | catch(Exception e) 61 | { 62 | e.printStackTrace(); 63 | result=false; 64 | throw new ProductAlreadyExistsException("Product Already Exists!"); 65 | } 66 | 67 | return result; 68 | } 69 | 70 | @Override 71 | public boolean updateProduct(Product productDetails, String productId) { 72 | // TODO Auto-generated method stub 73 | 74 | int result; 75 | 76 | try { 77 | result=productServiceRepository.updateProduct(productDetails,productId); 78 | } 79 | catch(Exception e) 80 | { 81 | e.printStackTrace(); 82 | result=0; 83 | } 84 | 85 | if(result==0) 86 | { 87 | return false; 88 | } 89 | return true; 90 | } 91 | 92 | @Override 93 | public boolean deleteProduct(String productId) { 94 | // TODO Auto-generated method stub 95 | int result; 96 | 97 | try { 98 | result=productServiceRepository.deleteProduct(productId); 99 | } 100 | catch(Exception e) 101 | { 102 | e.printStackTrace(); 103 | result=0; 104 | } 105 | 106 | if(result==0) 107 | { 108 | return false; 109 | } 110 | return true; 111 | } 112 | 113 | 114 | } 115 | -------------------------------------------------------------------------------- /airbus-management-spring/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #spring.datasource.url=jdbc:h2:~/test 2 | #spring.datasource.driver-class-name=org.h2.Driver 3 | #spring.datasource.username=sa 4 | #spring.datasource.password=sa 5 | #spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 6 | 7 | 8 | #dev.datasoure.url= 9 | server.port=8080 10 | spring.datasource.url=jdbc:mysql://localhost:3306/Product 11 | spring.datasource.username=root 12 | spring.datasource.password=password 13 | jwt.secret=airbus 14 | -------------------------------------------------------------------------------- /airbus-management-spring/src/main/resources/templates/schema.sql: -------------------------------------------------------------------------------- 1 | use Product; 2 | 3 | drop table Product; 4 | create table Product( 5 | productId varchar(256) Unique not null, 6 | productName varchar(256), 7 | productDescription varchar(3500), 8 | productCategory varchar(256), 9 | units int 10 | ); 11 | 12 | drop table User; 13 | create table User( 14 | username varchar(256), 15 | password varchar(256) 16 | ); 17 | 18 | 19 | use Product; 20 | insert into User(username,password) Values("airbus01","$2a$10$slYQmyNdGzTn7ZLBXBChFOC9f6kFjAqPhccnP6DxlWXx2lPk1C3G6"); 21 | insert into User(username,password) Values("airbus02","$2a$10$ZnnAdfh3cc7a/b1aODLeoOjifNPbHL6Vo8kpRJj.muPsVp1697hJO"); 22 | -------------------------------------------------------------------------------- /airbus-management-spring/src/test/java/com/airbus/management/AirbusManagementSpringApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.airbus.management; 2 | 3 | 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | 9 | @RunWith(SpringRunner.class) 10 | @SpringBootTest 11 | class AirbusManagementSpringApplicationTests { 12 | 13 | @Test 14 | void contextLoads() { 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /airbus-management-spring/src/test/java/com/airbus/management/controller/TestMainController.java: -------------------------------------------------------------------------------- 1 | package com.airbus.management.controller; 2 | 3 | import static org.junit.Assert.assertNotNull; 4 | import static org.mockito.Mockito.when; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.mockito.InjectMocks; 12 | import org.mockito.Mock; 13 | import org.mockito.runners.MockitoJUnitRunner; 14 | import org.springframework.boot.test.context.SpringBootTest; 15 | 16 | import com.airbus.management.model.Product; 17 | import com.airbus.management.service.ProductService; 18 | 19 | @RunWith(MockitoJUnitRunner.class) 20 | public class TestMainController { 21 | 22 | @InjectMocks 23 | private MainController mainController; 24 | 25 | @Mock 26 | private ProductService productService; 27 | 28 | @Test 29 | public void testGetAllProducts() { 30 | Product product =new Product(); 31 | 32 | product.setProductId("A01"); 33 | product.setProductName("Airport_test"); 34 | 35 | List productList=new ArrayList<>(); 36 | 37 | productList.add(product); 38 | 39 | when(productService.getAllProducts()).thenReturn(productList); 40 | 41 | Object result=mainController.getAllProducts(); 42 | 43 | assertNotNull(result); 44 | } 45 | 46 | } 47 | --------------------------------------------------------------------------------