commit after pull

This commit is contained in:
annampak 2017-11-02 17:00:53 +02:00
commit ec3ae4c441
24 changed files with 145 additions and 102 deletions

View File

@ -102,11 +102,11 @@
<!-- new profile editor -->
<!--
<div [ngClass]="{true:'visible', false:'invisible'}[viewingComponent==2]">
<dataset-profile-gui-editor [profile]=profile (notifyClick)="goToMain()" ></dataset-profile-gui-editor>
</div>
-->
<!-- end of new profile editor -->
@ -118,7 +118,7 @@
<!-- OLD Profile Editor -->
<!--
<div [ngClass]="{true:'visible', false:'invisible'}[viewingComponent==2]">
<div class="panel panel-default margin10">
<div class="panel-heading">
@ -189,6 +189,6 @@
</div>
</div>
</div>
-->
<!-- End of OLD Profile Editor -->

View File

@ -15,10 +15,6 @@ public interface DMPDao extends Dao<DMP, UUID> {
List<IDLabelPair> listAllIDsLabels();
List<DMP> listUserDMPs(String userID);
// public boolean createFromForm();
}

View File

@ -41,29 +41,6 @@ public class DMPDaoImpl extends JpaDao<DMP, UUID> implements DMPDao {
.collect(Collectors.toList());
}
@Override
public List<DMP> listUserDMPs(String userID) {
// String queryString = "select ui from UserInfo ui join UserAuth ui.authentication ua where ua.username=:username";
String queryString = "select ui from UserInfo ui join Project ui.pro.authentication ua where ua.username=:username";
// TypedQuery<UserInfo> typedQuery = entityManager.createQuery(queryString, UserInfo.class);
// typedQuery.setParameter("username", username);
return null;
}
// @Override
// public boolean createFromForm(Map<String,String> keyVals) {
// String query = "insert into DMP () values"
// return false;
// }
}

View File

@ -14,5 +14,6 @@ public interface DatasetDao extends Dao<Dataset, UUID> {
List<IDLabelPair> listAllIDsLabels();
List<Dataset> getDatasetsOfDmp(UUID dmpID);
}

View File

@ -1,6 +1,7 @@
package dao.entities;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
@ -38,5 +39,14 @@ public class DatasetDaoImpl extends JpaDao<Dataset, UUID> implements DatasetDao
.collect(Collectors.toList());
}
@Override
public List<Dataset> getDatasetsOfDmp(UUID dmpID) {
String queryString = "FROM Dataset dataset where dataset.dmp.id=:dmpID";
Query query = (Query) entityManager.createQuery(queryString);
query.setParameter("dmpID", dmpID);
List<Dataset> datasets = (List<Dataset>) query.getResultList();
return datasets;
}
}

View File

@ -191,7 +191,7 @@ public class DMP implements Serializable {
/*
public String toString() {
try {
return new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT).writeValueAsString(this);
@ -200,4 +200,6 @@ public class DMP implements Serializable {
}
}
*/
}

View File

@ -28,14 +28,14 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@Entity(name = "Dataset")
@Entity
@Table(name="\"Dataset\"")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
public class Dataset implements Serializable {
private static final long serialVersionUID = 3575723814399553259L;
//public Dataset () {}
public Dataset () {}
@Id
@ -67,7 +67,9 @@ public class Dataset implements Serializable {
@JoinColumn(name = "\"Profile\"", nullable = true)
private DatasetProfile profile;
@Type(type="typedefinition.XMLType")
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
private String reference;
@OneToMany(fetch = FetchType.LAZY)
@JoinTable(name="\"DatasetDataRepository\"",
@ -182,5 +184,19 @@ public class Dataset implements Serializable {
public void setDataRepositories(Set<DataRepository> dataRepositories) {
this.dataRepositories = dataRepositories;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
}

View File

@ -0,0 +1,18 @@
package helpers;
import entities.DMP;
import entities.Dataset;
public class SafeCleanAttribs {
public static void clean(Dataset dataset) {
DMP dmp = dataset.getDmp();
if(dmp!=null) {
DMP newdmp = new DMP();
newdmp.setId(dmp.getId());
dataset.setDmp(newdmp);
}
}
}

View File

@ -7,9 +7,11 @@ import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -30,11 +32,11 @@ public class SerializerProvider {
public static void initialize() {
Hibernate5Module module = new Hibernate5Module();
module.enable(Feature.SERIALIZE_IDENTIFIER_FOR_LAZY_NOT_LOADED_OBJECTS);
//module.enable(Feature.SERIALIZE_IDENTIFIER_FOR_LAZY_NOT_LOADED_OBJECTS);
objectMapper = new ObjectMapper()
// .setSerializationInclusion(Include.NON_NULL)
// .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.registerModule(new Hibernate5Module())
//.setSerializationInclusion(Include.NON_NULL)
//.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.registerModule(module)
;
}

View File

@ -147,6 +147,10 @@ public class DMPs {
@Transactional
@RequestMapping(method = RequestMethod.POST, value = { "/dmp/update" }, consumes = "application/json", produces="application/json")
public @ResponseBody ResponseEntity<Object> updateDMP(@RequestBody DMP dmp) {
DMP previousDmp = dMPDao.read(dmp.getId());
addForeignElems(previousDmp, dmp);
try {
DMP updatedDMP = dMPDao.update(dmp);
return ResponseEntity.status(HttpStatus.CREATED).body(SerializerProvider.toJson(updatedDMP));
@ -250,7 +254,7 @@ public class DMPs {
@RequestMapping(method = RequestMethod.POST, value = { "/dmp/getdatasets" }, consumes = "application/json", produces="application/json")
public @ResponseBody ResponseEntity<Object> getDatasetsOfDMP(@RequestBody DMP dmp) {
try {
Set<Dataset> datasets = dMPDao.read(dmp.getId()).getDataset();
List<Dataset> datasets = datasetDao.getDatasetsOfDmp(dmp.getId());
return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(datasets));
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not get datasets of DMP!\"");
@ -306,7 +310,7 @@ public class DMPs {
}
@RequestMapping(method = RequestMethod.POST, value = { "/dmp/createofuser" }, produces="text/plain")
@RequestMapping(method = RequestMethod.POST, value = { "/dmp/createofuser" }, produces="text/plain", consumes = "application/json")
public @ResponseBody ResponseEntity<Object> createDmpOfUser(@RequestBody DMP dmp){
@ -382,5 +386,13 @@ public class DMPs {
private static void addForeignElems(DMP existing, DMP newone) {
newone.setDataset(existing.getDataset());
newone.setOrganisations(existing.getOrganisations());
newone.setResearchers(existing.getResearchers());
newone.setUsers(existing.getUsers());
}
}

View File

@ -1,10 +1,6 @@
package rest.entities;
import java.io.IOException;
import java.io.PrintStream;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;

View File

@ -50,6 +50,7 @@ import entities.DatasetProfileRuleset;
import entities.DatasetProfileViewstyle;
import entities.Organisation;
import entities.Project;
import helpers.SafeCleanAttribs;
import helpers.SerializerProvider;
import helpers.Transformers;
import responses.RestResponse;
@ -92,6 +93,7 @@ public class Datasets {
public @ResponseBody ResponseEntity<Object> getDataset(@PathVariable("id") String id) {
try {
Dataset ds = datasetDao.read(UUID.fromString(id));
ds.setDmp(ds.getDmp());
return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(ds));
}
catch(Exception ex) {
@ -118,7 +120,7 @@ public class Datasets {
}
@RequestMapping(method = RequestMethod.POST, value = { "/dataset/create" }, consumes = "application/json")
@RequestMapping(method = RequestMethod.POST, value = { "/dataset/create" }, consumes = "application/json", produces="application/json")
public @ResponseBody ResponseEntity<Object> createDataset(@RequestBody Dataset dataset) {
dataset.setId(null);
@ -133,13 +135,21 @@ public class Datasets {
}
@RequestMapping(method = RequestMethod.POST, value = { "/dataset/update" }, consumes = "application/json")
public @ResponseBody ResponseEntity<Object> updateDataset(@RequestBody Dataset dataset) {
@RequestMapping(method = RequestMethod.POST, value = { "/dataset/update" }, consumes = "application/json", produces="application/json")
public @ResponseBody ResponseEntity<Object> updateDataset(@RequestBody String datasetJson) {
Dataset dataset;
try {
dataset = SerializerProvider.fromJson(datasetJson, Dataset.class);
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Could not create or update Dataset! Reason: " + e.getMessage());
}
SafeCleanAttribs.clean(dataset);
try {
dataset = datasetDao.update(dataset);
RestResponse rr = new RestResponse("Updated dataset with id: "+dataset.toString(), dataset.getId().toString());
return ResponseEntity.status(HttpStatus.CREATED).body(rr.toString());
return ResponseEntity.status(HttpStatus.CREATED).body(SerializerProvider.toJson(dataset));
}
catch(Exception ex) {
ex.printStackTrace();
@ -149,8 +159,6 @@ public class Datasets {
}
@RequestMapping(method = RequestMethod.POST, value = { "/dataset/delete" }, consumes = "application/json")
public @ResponseBody ResponseEntity<Object> deleteDataset(@RequestBody Dataset dataset) {
@ -208,5 +216,8 @@ public class Datasets {
}

View File

@ -210,7 +210,7 @@ public class Projects {
}
@Transactional
@RequestMapping(method = RequestMethod.POST, value = { "/project/createofuser" }, produces="text/plain")
@RequestMapping(method = RequestMethod.POST, value = { "/project/createofuser" }, produces="text/plain", consumes = "application/json")
public @ResponseBody ResponseEntity<Object> createProjectOfUser(@RequestBody Project project){

View File

@ -36,6 +36,7 @@ import dao.entities.RegistryDao;
import dao.entities.ResearcherDao;
import dao.entities.ServiceDao;
import dao.entities.UserInfoDao;
import entities.DMP;
import entities.DatasetProfile;
import entities.DatasetProfileRuleset;
import entities.DatasetProfileViewstyle;
@ -160,7 +161,7 @@ public class TestRest {
@Test
//@Test
public void testUserProject() {
// System.out.println(projectsService.listProjects().getBody());
@ -186,15 +187,33 @@ public class TestRest {
}
// @Test
//@Test
public void testDmpUser() {
System.out.println(dmpsService.getDmpsOfUser().getBody());
// System.out.println(dmpsService.getDmpsOfUser());
DMP dmp = new DMP();
dmp.setId(UUID.fromString("52239f0e-4460-4459-a393-bffcb833f39d"));
System.out.println(dmpsService.getDatasetsOfDMP(dmp).getBody());
assertEquals("aaa", "aaa");
}
@Test
public void testDataset() {
System.out.println(datasetsService.getAllDatasets().getBody());
// System.out.println(dmpsService.getDatasetsOfDMP(dmp).getBody());
assertEquals("aaa", "aaa");
}
}

View File

@ -38,19 +38,18 @@
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<!--
-->
<router-outlet ></router-outlet>
<router-outlet [ngClass]="{true:'visible'}[tokenService.isLoggedIn() == true]" ></router-outlet>
<!--
<main-window [ngClass]="{false:'invisible'}[tokenService.isLoggedIn() == true]"></main-window>
-->
<!--
<app-main-sign-in [ngClass]="{true:'invisible'}[tokenService.isLoggedIn() == true]"></app-main-sign-in>
-->
<!--this should be invisible -->
<app-main-sign-in [ngClass]="'invisible'"></app-main-sign-in>
<!--
<router-outlet></router-outlet>
-->
</div>

View File

@ -1,4 +1,4 @@
import { Component } from '@angular/core';
import { Component, OnInit} from '@angular/core';
import { ServerService } from './services/server.service';
import { FieldBase } from '../app/form/fields/field-base';
import { JsonObjest } from '../app/entities/JsonObject.class';
@ -12,7 +12,7 @@ import { MainSignInComponent } from './login/main-sign-in/main-sign-in.component
styleUrls: ['./app.component.css'],
providers: []
})
export class AppComponent {
export class AppComponent implements OnInit {
fields: any[];
@ -21,6 +21,12 @@ export class AppComponent {
}
ngOnInit() {
}
//loggedInAs : string = null;

View File

@ -92,10 +92,10 @@ export class DatasetsComponent implements OnInit {
}
ngOnInit() { debugger;
ngOnInit() {
//this.projects = this.serverService.getDummyProjects();
this.datasets = [];
console.log(this.dmpIdforDatasets);debugger;
console.log(this.dmpIdforDatasets);
this.serverService.getDatasetForDmp({ "id": this.dmpIdforDatasets }).subscribe(
response => {
this.tableData = response;

View File

@ -93,19 +93,12 @@ export class DmpComponent implements OnInit{
ngOnInit() {
//this.projects = this.serverService.getDummyProjects();
gapi.load('auth2', function() {
gapi.auth2.init({});
});
this.serverService.getDmpOfUser().subscribe(
response => {
this.tableData = response;
},
(err: HttpErrorResponse) => {
if (err.error instanceof Error) {
console.log("An error occurred:", err.error.message);
} else {
console.log("Backend returned code ${err.status}, body was: ${err.error}");
}
}
);
@ -135,11 +128,7 @@ getDmps(){
this.tableData = response;
},
(err: HttpErrorResponse) => {
if (err.error instanceof Error) {
console.log("An error occurred:", err.error.message);
} else {
console.log("Backend returned code ${err.status}, body was: ${err.error}");
}
}
);
}
@ -169,8 +158,7 @@ updateDMP(){
this.serverService.updateDmp(this.dmp)
.subscribe(
response =>{
console.log("response");
console.log(response);
this.getDmps();
}
);
$("#newDmpModal").modal("hide");

View File

@ -195,6 +195,3 @@
<!--DATASET TABLE-->
<datasets-table *ngIf="dataSetVisibe" [dmpIdforDatasets]="dmpIdforDatasets" [dmpLabelforDatasets]="dmpLabelforDatasets" [(dataSetVisibe)]="dataSetVisibe"></datasets-table>
<a href="#" (click)="signOut();" #isignOutBtn>Sign out</a>
<router-outlet></router-outlet>

View File

@ -60,7 +60,7 @@ export class GooggleSignInComponent implements OnInit, AfterViewInit {
this.router.navigate(['/dmps'], { queryParams: { /*returnUrl: this.state.url*/ }});
},
function (error) {
simple_notifier("danger",null,"Failed to login");
//simple_notifier("danger",null,"Failed to login");
console.log(JSON.stringify(error, undefined, 2));
});

View File

@ -125,6 +125,3 @@
<!--DATASET TABLE-->
<datasets-table *ngIf="dataSetVisibe" [(dataSetVisibe)]="dataSetVisibe"></datasets-table> <!--*ngIf="dataSetVisibe == true"-->
<a href="#" (click)="signOut();" #isignOutBtn >Sign out</a>
<router-outlet></router-outlet>

View File

@ -83,17 +83,13 @@ export class ProjectsComponent implements OnInit{
ngOnInit() {
gapi.load('auth2', function() {
gapi.auth2.init({});
});
this.getProjects();
//this.projects = this.serverService.getDummyProjects();
this.projects = [];
this.getProjects();
}
getProjects(){
this.serverService.getProjectOfUer().subscribe( //getProjects()
this.serverService.getProjectOfUer().subscribe(
response => {
this.tableData = response;
@ -191,10 +187,6 @@ editRow(item, event){
}
signOut() {
    this.serverService.logOut();
}
}

View File

@ -20,6 +20,7 @@ export class GlobalInterceptor implements HttpInterceptor {
}, (err: any) => {
if (err instanceof HttpErrorResponse) {
if (err.status === 401) {
console.log("Received an unauthorized... redirecting to login page");
this.tokenService.logout();
this.router.navigate(['/login'], { queryParams: { /*returnUrl: this.state.url*/ }});
}

View File

@ -17,6 +17,7 @@ export class RestBase {
protocol: string = "http";
hostname: string ="dl010.madgik.di.uoa.gr" ;//"localhost";//"dl010.madgik.di.uoa.gr";//
@ -25,10 +26,12 @@ export class RestBase {
/*protocol: string = "http";
/* protocol: string = "http";
hostname: string = "dionysus.di.uoa.gr" ;
port: number = 7070;
webappname: string = "dmp-backend";*/
proxyPath : string = this.protocol+"://"+this.hostname+":"+this.port+"/"+this.webappname+"/proxy/";