Skip to content

Commit

Permalink
Merge pull request #25 from AMOSTeam1/archivedProject
Browse files Browse the repository at this point in the history
Added archived Project View
  • Loading branch information
maimoustafa24 authored May 16, 2018
2 parents ad32132 + 56f4f26 commit 08893be
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 18 deletions.
11 changes: 11 additions & 0 deletions nfabackend/src/main/java/com/msg/nfabackend/entities/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public Project() {}
@Column(name="ID")
private Long id;

@Column(name="IS_ARCHIVED")
private boolean isArchived;

@Column(name="NFA_PROJECT_NUMBER")
private String nfaProjectNumber;

Expand Down Expand Up @@ -73,6 +76,14 @@ public void setId(Long id) {
this.id = id;
}

public boolean isArchived() {
return isArchived;
}

public void setArchived(boolean isArchived) {
this.isArchived = isArchived;
}

/**
* @return the nfaProjectNumber
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* Entity-Mapping for the table 'ProjectTypes'.
*
*/

@Entity (name="Types")
@Table(name="Types")
public class Type {
Expand Down Expand Up @@ -83,8 +84,8 @@ public void setEnglishName(String englishName) {
* relation between projects and projec Type
*/

@ManyToMany(mappedBy = "types")
private List<Project> projects = new ArrayList<>();
@ManyToMany(mappedBy = "types")
private List<Project> projects = new ArrayList<>();


public List<Project> getProjects() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ public void updateProject(Project editedProject) {
tx.begin();

Project project = em.find(Project.class, editedProject.getId());


project.setArchived(editedProject.isArchived());
project.setCustomerName(editedProject.getCustomerName());
project.setBranch(editedProject.getBranch());
project.setContactPersCustomer(editedProject.getContactPersCustomer());
Expand Down
12 changes: 6 additions & 6 deletions nfabackend/src/main/resources-filtered/META-INF/persistence.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd" version="2.1">

<persistence-unit name="msg-nfa">
<persistence-unit name="msg-nfa" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.msg.nfabackend.entities.Project</class>
<class>com.msg.nfabackend.entities.Nfa</class>
<class>com.msg.nfabackend.entities.Type</class>
<properties>
<property name="javax.persistence.jdbc.user" value="${jdbc.user}"/>
<property name="javax.persistence.jdbc.password" value="${jdbc.password}"/>
<property name="javax.persistence.jdbc.url" value="${jdbc.url}"/>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.SunOneJtaPlatform"/>


<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/NFA"/>
<property name="javax.persistence.jdbc.user" value="postgres"/>
<property name="javax.persistence.jdbc.password" value="amos18"/>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
</properties>
</persistence-unit>
</persistence>
1 change: 1 addition & 0 deletions nfabackend/src/main/resources/ddl/nfa_projekt.ddl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CREATE TABLE NFA_PROJECT
(
ID bigint PRIMARY KEY,
IS_ARCHIVED boolean,
NFA_PROJECT_NUMBER character varying(40),
CUSTOMER_NAME character varying(40),
CONTACT_PERS_CUSTOMER character varying(40),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<div class="row">
<div class="col-md-5">
<app-project-list></app-project-list>

<hr>

<app-project-list
[archivedView]="true"></app-project-list>
</div>

<div class="col-md-7">
<router-outlet></router-outlet>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ export class CurrentProjectService {
private projects: Project[];


// getProjects(archived = false) {
// return this.projects.slice().filter(
//
// value => value.isArchived === archived
// );
// }

getProjects() {
return this.projects.slice();
}
Expand All @@ -19,7 +26,7 @@ export class CurrentProjectService {
this.projects[index] = newProject;
this.projectsChanged.next(this.projects.slice());
}

deleteProject(index: number) {
this.projects.splice(index,1);
this.projectsChanged.next(this.projects.slice());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class ProjectEditComponent implements OnInit {

private copy(toEdit: Project) {
return new Project(toEdit.id,
toEdit.archived,
toEdit.customerName,
toEdit.contactPersCustomer,
toEdit.contactPersMsg,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="row">
<div class="col-xs-12" style="text-align: center">
<span class="label label-default">Current-Projects</span>
<span class="label label-default">{{ viewname }}</span>
</div>
</div>
<hr>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import {Component, Input, OnInit} from '@angular/core';
import {DataStorageService} from '../../shared/data-storage.service';
import {Project} from '../../shared/project.model';
import {Response} from '@angular/http';
Expand All @@ -11,6 +11,10 @@ import {CurrentProjectService} from '../current-project.service';
})
export class ProjectListComponent implements OnInit {

@Input() archivedView = false;

viewname : string;

projects: Project[];
constructor(private currentProjectService: CurrentProjectService,
private dataStorageService: DataStorageService) { }
Expand All @@ -20,17 +24,23 @@ export class ProjectListComponent implements OnInit {
this.dataStorageService.getCurrentProjects()
.subscribe(
(response: Response) => {
const projects: Project[] = response.json();
this.currentProjectService.setProjects(projects);
this.projects = projects;
const projects: Project[] = response.json().filter(
value => value.archived == this.archivedView
);
this.currentProjectService.setProjects(projects);
this.projects = projects;

this.viewname = (!this.archivedView) ? "Current-Projects" : "Archived-Projects" ;
}
);
}

onSearch(frominput: HTMLInputElement) {
this.dataStorageService.getProjectByName(frominput.value).subscribe(
(response: Response) => {
const projects: Project[] = response.json();
const projects: Project[] = response.json().filter(
value => value.archived == this.archivedView
);
this.currentProjectService.setProjects(projects);
this.projects = projects;
}
Expand Down
3 changes: 1 addition & 2 deletions nfafrontend/src/app/newproject/newproject.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ export class NewprojectComponent implements OnInit {
}



private initProject() {
return new Project(null, null, null, null, null, null, null, null, null);
return new Project(null, null, null, null, null, null, null, null, null, null);
}


Expand Down
1 change: 1 addition & 0 deletions nfafrontend/src/app/shared/project.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export class Project {

constructor(
public id: string,
public archived: boolean,
public customerName: string,
public contactPersCustomer: string,
public contactPersMsg: string,
Expand Down

0 comments on commit 08893be

Please sign in to comment.