Merge branch 'Development' of code-repo.d4science.org:MaDgiK-CITE/argos into Development
This commit is contained in:
commit
ef0816524f
|
@ -35,7 +35,18 @@ public class ManagementController extends BaseController {
|
||||||
public ResponseEntity addSchematicsInDatasetProfiles(@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
|
public ResponseEntity addSchematicsInDatasetProfiles(@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
|
||||||
try {
|
try {
|
||||||
this.datasetProfileManager.addSchematicsInDatasetProfiles();
|
this.datasetProfileManager.addSchematicsInDatasetProfiles();
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(null);
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Void>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||||
|
} catch (Exception exception) {
|
||||||
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Void>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = {"/addRdaInSchematics"})
|
||||||
|
public ResponseEntity addRdaInSchematicsInDatasetProfiles(@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
|
||||||
|
try {
|
||||||
|
this.datasetProfileManager.addRdaInSchematicsInDatasetProfiles();
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Void>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Void>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Void>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -400,30 +400,52 @@ public class DatasetProfileManager {
|
||||||
Node fieldParent = rdaPropertyNode.getParentNode();
|
Node fieldParent = rdaPropertyNode.getParentNode();
|
||||||
if(rdaProperty != null && !rdaProperty.isEmpty()){
|
if(rdaProperty != null && !rdaProperty.isEmpty()){
|
||||||
Element schematic = document.createElement("schematic");
|
Element schematic = document.createElement("schematic");
|
||||||
schematic.setTextContent(rdaProperty);
|
schematic.setTextContent("rda." + rdaProperty);
|
||||||
schematics.appendChild(schematic);
|
schematics.appendChild(schematic);
|
||||||
}
|
}
|
||||||
fieldParent.insertBefore(schematics, rdaPropertyNode);
|
fieldParent.insertBefore(schematics, rdaPropertyNode);
|
||||||
fieldParent.removeChild(rdaPropertyNode);
|
fieldParent.removeChild(rdaPropertyNode);
|
||||||
}
|
}
|
||||||
try {
|
this.updateDatasetProfileXml(document, datasetProfile);
|
||||||
DOMSource domSource = new DOMSource(document);
|
}
|
||||||
StringWriter writer = new StringWriter();
|
}
|
||||||
StreamResult result = new StreamResult(writer);
|
|
||||||
TransformerFactory tf = TransformerFactory.newInstance();
|
|
||||||
Transformer transformer = tf.newTransformer();
|
|
||||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
|
||||||
transformer.transform(domSource, result);
|
|
||||||
String newDefinition = writer.toString();
|
|
||||||
if(newDefinition != null){
|
|
||||||
|
|
||||||
|
public void addRdaInSchematicsInDatasetProfiles() throws XPathExpressionException {
|
||||||
|
List<DatasetProfile> datasetProfiles = this.databaseRepository.getDatasetProfileDao().getAll().toList();
|
||||||
|
for(DatasetProfile datasetProfile: datasetProfiles){
|
||||||
|
Document document = XmlBuilder.fromXml(datasetProfile.getDefinition());
|
||||||
|
XPathFactory xpathFactory = XPathFactory.newInstance();
|
||||||
|
XPath xpath = xpathFactory.newXPath();
|
||||||
|
XPathExpression expr = xpath.compile("//schematic");
|
||||||
|
NodeList schematics = (NodeList) expr.evaluate(document, XPathConstants.NODESET);
|
||||||
|
for (int i = 0; i < schematics.getLength(); i++) {
|
||||||
|
Node schematicNode = schematics.item(i);
|
||||||
|
String schematicRda = schematicNode.getTextContent();
|
||||||
|
if (schematicRda != null && !schematicRda.isEmpty() && !schematicRda.startsWith("rda.")) {
|
||||||
|
schematicNode.setTextContent("rda." + schematicRda);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
this.updateDatasetProfileXml(document, datasetProfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateDatasetProfileXml(Document document, DatasetProfile datasetProfile) {
|
||||||
|
try {
|
||||||
|
DOMSource domSource = new DOMSource(document);
|
||||||
|
StringWriter writer = new StringWriter();
|
||||||
|
StreamResult result = new StreamResult(writer);
|
||||||
|
TransformerFactory tf = TransformerFactory.newInstance();
|
||||||
|
Transformer transformer = tf.newTransformer();
|
||||||
|
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||||
|
transformer.transform(domSource, result);
|
||||||
|
String newDefinition = writer.toString();
|
||||||
|
if(newDefinition != null){
|
||||||
datasetProfile.setDefinition(newDefinition);
|
datasetProfile.setDefinition(newDefinition);
|
||||||
this.databaseRepository.getDatasetProfileDao().createOrUpdate(datasetProfile);
|
this.databaseRepository.getDatasetProfileDao().createOrUpdate(datasetProfile);
|
||||||
}
|
}
|
||||||
catch(TransformerException ex) {
|
}
|
||||||
logger.error(ex.getMessage(), ex);
|
catch(TransformerException ex) {
|
||||||
}
|
logger.error(ex.getMessage(), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,4 +17,8 @@ export class MaintenanceTasksService extends BaseService {
|
||||||
migrateSchematics(): Observable<void> {
|
migrateSchematics(): Observable<void> {
|
||||||
return this.http.post<null>(this.actionUrl + 'addSchematics/', null);
|
return this.http.post<null>(this.actionUrl + 'addSchematics/', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addRdaInSchematics(): Observable<void> {
|
||||||
|
return this.http.post<null>(this.actionUrl + 'addRdaInSchematics/', null);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,9 @@
|
||||||
<div class="row root">
|
<div class="row root">
|
||||||
<mat-card class="col-md-3 offset-md-4">
|
<mat-card class="col-md-3 offset-md-4">
|
||||||
|
<div style="color: red;">Warning: Danger zone. Irreversible actions!</div>
|
||||||
<div>
|
<div>
|
||||||
<div style="color: red;">Warning: Danger zone. Irreversible action!</div>
|
|
||||||
<button mat-raised-button color="primary" (click)="migrateSchematics($event)" class="lightblue-btn button">Migrate schematics</button>
|
<button mat-raised-button color="primary" (click)="migrateSchematics($event)" class="lightblue-btn button">Migrate schematics</button>
|
||||||
|
<button mat-raised-button color="primary" (click)="addRdaInSchematics($event)" class="lightblue-btn button">Add rda in schematics</button>
|
||||||
</div>
|
</div>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -27,16 +27,30 @@ export class MaintenanceTasksComponent extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
migrateSchematics(ev: Event) {
|
migrateSchematics(ev: Event) {
|
||||||
(ev.srcElement as HTMLButtonElement).disabled = true;
|
(ev.srcElement as HTMLButtonElement).disabled = true;
|
||||||
this.maintenanceTasksService.migrateSchematics().pipe(takeUntil(this._destroyed)).subscribe(
|
this.maintenanceTasksService.migrateSchematics().pipe(takeUntil(this._destroyed)).subscribe(
|
||||||
response => {
|
response => {
|
||||||
(ev.srcElement as HTMLButtonElement).disabled = false;
|
(ev.srcElement as HTMLButtonElement).disabled = false;
|
||||||
this.onCallbackSuccess();
|
this.onCallbackSuccess();
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
(ev.srcElement as HTMLButtonElement).disabled = false;
|
(ev.srcElement as HTMLButtonElement).disabled = false;
|
||||||
this.onCallbackError(error);
|
this.onCallbackError(error);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
addRdaInSchematics(ev: Event) {
|
||||||
|
(ev.srcElement as HTMLButtonElement).disabled = true;
|
||||||
|
this.maintenanceTasksService.addRdaInSchematics().pipe(takeUntil(this._destroyed)).subscribe(
|
||||||
|
response => {
|
||||||
|
(ev.srcElement as HTMLButtonElement).disabled = false;
|
||||||
|
this.onCallbackSuccess();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
(ev.srcElement as HTMLButtonElement).disabled = false;
|
||||||
|
this.onCallbackError(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onCallbackSuccess(): void {
|
onCallbackSuccess(): void {
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--primary-color: #129d99;
|
--primary-color: #129d99;
|
||||||
|
--primary-color-1: #129d99;
|
||||||
--primary-color-2: #23bcba;
|
--primary-color-2: #23bcba;
|
||||||
--primary-color-3: #00b29f;
|
--primary-color-3: #00b29f;
|
||||||
--secondary-color: #f7dd72;
|
--secondary-color: #f7dd72;
|
||||||
|
|
Loading…
Reference in New Issue