Commit 530877a8 authored by Hellmich, Christoph's avatar Hellmich, Christoph
Browse files

Rename Guard entity to Conditional

Rename destination attribute to nextStep
parent d9b1ae96
......@@ -7,11 +7,11 @@
"relationshipType": "one-to-one",
"otherEntityField": "id",
"ownerSide": true,
"otherEntityRelationshipName": "guard"
"otherEntityRelationshipName": "conditional"
},
{
"relationshipId": 2,
"relationshipName": "destination",
"relationshipName": "nextStep",
"otherEntityName": "step",
"relationshipType": "many-to-one",
"otherEntityField": "id"
......
......@@ -16,10 +16,10 @@
},
{
"relationshipId": 3,
"relationshipName": "guard",
"otherEntityName": "guard",
"relationshipName": "conditional",
"otherEntityName": "conditional",
"relationshipType": "one-to-many",
"otherEntityRelationshipName": "destination"
"otherEntityRelationshipName": "nextStep"
}
],
"fields": [
......
doc/entities.gif

17.4 KB | W: | H:

doc/entities.gif

17.4 KB | W: | H:

doc/entities.gif
doc/entities.gif
doc/entities.gif
doc/entities.gif
  • 2-up
  • Swipe
  • Onion skin
......@@ -378,12 +378,12 @@ public interface StatementRepository extends ElementBaseRepository<Statement> {
referencedTableName="element"/>
```
**Bearbeite** die Datei `src\main\resources\config\liquibase\changelog\20160317131754_added_entity_Guard.xml`:
**Bearbeite** die Datei `src\main\resources\config\liquibase\changelog\20160317131754_added_entity_Conditional.xml`:
```xml
<addForeignKeyConstraint baseColumnNames="statement_id"
baseTableName="guard"
constraintName="fk_guard_statement_id"
baseTableName="conditional"
constraintName="fk_conditional_statement_id"
referencedColumnNames="id"
referencedTableName="element"/>
```
......
......@@ -32,7 +32,7 @@ enum FileType {
IMAGE, CSV, PDF, VIDEO
}
entity Guard {
entity Conditional {
}
entity Statement {
......@@ -86,11 +86,11 @@ relationship OneToMany {
}
relationship OneToMany {
Step{guard} to Guard{destination}
Step{conditional} to Conditional{nextStep}
}
relationship OneToOne {
Guard{statement} to Statement
Conditional{statement} to Statement
}
relationship ManyToOne {
......
......@@ -10,12 +10,12 @@ import java.util.Set;
import java.util.Objects;
/**
* A Guard.
* A Conditional.
*/
@Entity
@Table(name = "guard")
@Table(name = "conditional")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Guard implements Serializable {
public class Conditional implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
......@@ -25,8 +25,8 @@ public class Guard implements Serializable {
private Statement statement;
@ManyToOne
@JoinColumn(name = "destination_id")
private Step destination;
@JoinColumn(name = "next_step_id")
private Step nextStep;
public Long getId() {
return id;
......@@ -44,12 +44,12 @@ public class Guard implements Serializable {
this.statement = statement;
}
public Step getDestination() {
return destination;
public Step getNextStep() {
return nextStep;
}
public void setDestination(Step step) {
this.destination = step;
public void setNextStep(Step step) {
this.nextStep = step;
}
@Override
......@@ -60,11 +60,11 @@ public class Guard implements Serializable {
if (o == null || getClass() != o.getClass()) {
return false;
}
Guard guard = (Guard) o;
if(guard.id == null || id == null) {
Conditional conditional = (Conditional) o;
if(conditional.id == null || id == null) {
return false;
}
return Objects.equals(id, guard.id);
return Objects.equals(id, conditional.id);
}
@Override
......@@ -74,7 +74,7 @@ public class Guard implements Serializable {
@Override
public String toString() {
return "Guard{" +
return "Conditional{" +
"id=" + id +
'}';
}
......
......@@ -42,10 +42,10 @@ public class Step implements Serializable {
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<Element> elements = new HashSet<>();
@OneToMany(mappedBy = "destination")
@OneToMany(mappedBy = "nextStep")
@JsonIgnore
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<Guard> guards = new HashSet<>();
private Set<Conditional> conditionals = new HashSet<>();
public Long getId() {
return id;
......@@ -95,12 +95,12 @@ public class Step implements Serializable {
this.elements = elements;
}
public Set<Guard> getGuards() {
return guards;
public Set<Conditional> getConditionals() {
return conditionals;
}
public void setGuards(Set<Guard> guards) {
this.guards = guards;
public void setConditionals(Set<Conditional> conditionals) {
this.conditionals = conditionals;
}
@Override
......
package org.gesis.dda.wizard.repository;
import org.gesis.dda.wizard.domain.Guard;
import org.gesis.dda.wizard.domain.Conditional;
import org.springframework.data.jpa.repository.*;
import java.util.List;
/**
* Spring Data JPA repository for the Guard entity.
* Spring Data JPA repository for the Conditional entity.
*/
public interface GuardRepository extends JpaRepository<Guard,Long> {
public interface ConditionalRepository extends JpaRepository<Conditional,Long> {
}
package org.gesis.dda.wizard.web.rest;
import com.codahale.metrics.annotation.Timed;
import org.gesis.dda.wizard.domain.Guard;
import org.gesis.dda.wizard.repository.GuardRepository;
import org.gesis.dda.wizard.domain.Conditional;
import org.gesis.dda.wizard.repository.ConditionalRepository;
import org.gesis.dda.wizard.web.rest.util.HeaderUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -19,76 +19,76 @@ import java.util.List;
import java.util.Optional;
/**
* REST controller for managing Guard.
* REST controller for managing Conditional.
*/
@RestController
@RequestMapping("/api")
public class GuardResource {
public class ConditionalResource {
private final Logger log = LoggerFactory.getLogger(GuardResource.class);
private final Logger log = LoggerFactory.getLogger(ConditionalResource.class);
@Inject
private GuardRepository guardRepository;
private ConditionalRepository conditionalRepository;
/**
* POST /guards -> Create a new guard.
* POST /conditionals -> Create a new conditional.
*/
@RequestMapping(value = "/guards",
@RequestMapping(value = "/conditionals",
method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public ResponseEntity<Guard> createGuard(@RequestBody Guard guard) throws URISyntaxException {
log.debug("REST request to save Guard : {}", guard);
if (guard.getId() != null) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert("guard", "idexists", "A new guard cannot already have an ID")).body(null);
public ResponseEntity<Conditional> createConditional(@RequestBody Conditional conditional) throws URISyntaxException {
log.debug("REST request to save Conditional : {}", conditional);
if (conditional.getId() != null) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert("conditional", "idexists", "A new conditional cannot already have an ID")).body(null);
}
Guard result = guardRepository.save(guard);
return ResponseEntity.created(new URI("/api/guards/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert("guard", result.getId().toString()))
Conditional result = conditionalRepository.save(conditional);
return ResponseEntity.created(new URI("/api/conditionals/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert("conditional", result.getId().toString()))
.body(result);
}
/**
* PUT /guards -> Updates an existing guard.
* PUT /conditionals -> Updates an existing conditional.
*/
@RequestMapping(value = "/guards",
@RequestMapping(value = "/conditionals",
method = RequestMethod.PUT,
produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public ResponseEntity<Guard> updateGuard(@RequestBody Guard guard) throws URISyntaxException {
log.debug("REST request to update Guard : {}", guard);
if (guard.getId() == null) {
return createGuard(guard);
public ResponseEntity<Conditional> updateConditional(@RequestBody Conditional conditional) throws URISyntaxException {
log.debug("REST request to update Conditional : {}", conditional);
if (conditional.getId() == null) {
return createConditional(conditional);
}
Guard result = guardRepository.save(guard);
Conditional result = conditionalRepository.save(conditional);
return ResponseEntity.ok()
.headers(HeaderUtil.createEntityUpdateAlert("guard", guard.getId().toString()))
.headers(HeaderUtil.createEntityUpdateAlert("conditional", conditional.getId().toString()))
.body(result);
}
/**
* GET /guards -> get all the guards.
* GET /conditionals -> get all the conditionals.
*/
@RequestMapping(value = "/guards",
@RequestMapping(value = "/conditionals",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public List<Guard> getAllGuards() {
log.debug("REST request to get all Guards");
return guardRepository.findAll();
public List<Conditional> getAllConditionals() {
log.debug("REST request to get all Conditionals");
return conditionalRepository.findAll();
}
/**
* GET /guards/:id -> get the "id" guard.
* GET /conditionals/:id -> get the "id" conditional.
*/
@RequestMapping(value = "/guards/{id}",
@RequestMapping(value = "/conditionals/{id}",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public ResponseEntity<Guard> getGuard(@PathVariable Long id) {
log.debug("REST request to get Guard : {}", id);
Guard guard = guardRepository.findOne(id);
return Optional.ofNullable(guard)
public ResponseEntity<Conditional> getConditional(@PathVariable Long id) {
log.debug("REST request to get Conditional : {}", id);
Conditional conditional = conditionalRepository.findOne(id);
return Optional.ofNullable(conditional)
.map(result -> new ResponseEntity<>(
result,
HttpStatus.OK))
......@@ -96,15 +96,15 @@ public class GuardResource {
}
/**
* DELETE /guards/:id -> delete the "id" guard.
* DELETE /conditionals/:id -> delete the "id" conditional.
*/
@RequestMapping(value = "/guards/{id}",
@RequestMapping(value = "/conditionals/{id}",
method = RequestMethod.DELETE,
produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public ResponseEntity<Void> deleteGuard(@PathVariable Long id) {
log.debug("REST request to delete Guard : {}", id);
guardRepository.delete(id);
return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert("guard", id.toString())).build();
public ResponseEntity<Void> deleteConditional(@PathVariable Long id) {
log.debug("REST request to delete Conditional : {}", id);
conditionalRepository.delete(id);
return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert("conditional", id.toString())).build();
}
}
......@@ -14,29 +14,29 @@
<property name="floatType" value="float" dbms="mysql, oracle"/>
<!--
Added the entity Guard.
Added the entity Conditional.
-->
<changeSet id="20160321161717" author="jhipster">
<createTable tableName="guard">
<createTable tableName="conditional">
<column name="id" type="bigint" autoIncrement="${autoIncrement}">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="statement_id" type="bigint">
<constraints unique="true"/>
</column>
<column name="destination_id" type="bigint"/>
<column name="next_step_id" type="bigint"/>
<!-- jhipster-needle-liquibase-add-column - Jhipster will add columns here, do not remove-->
</createTable>
<addForeignKeyConstraint baseColumnNames="statement_id"
baseTableName="guard"
constraintName="fk_guard_statement_id"
baseTableName="conditional"
constraintName="fk_conditional_statement_id"
referencedColumnNames="id"
referencedTableName="element"/>
<addForeignKeyConstraint baseColumnNames="destination_id"
baseTableName="guard"
constraintName="fk_guard_destination_id"
<addForeignKeyConstraint baseColumnNames="next_step_id"
baseTableName="conditional"
constraintName="fk_conditional_nextstep_id"
referencedColumnNames="id"
referencedTableName="step"/>
......
......@@ -18,6 +18,6 @@
<include file="classpath:config/liquibase/changelog/20160321161714_added_entity_Element.xml" relativeToChangelogFile="false"/>
<!-- <include file="classpath:config/liquibase/changelog/20160321161718_added_entity_Statement.xml" relativeToChangelogFile="false"/> -->
<!-- <include file="classpath:config/liquibase/changelog/20160321161721_added_entity_CompoundStatement.xml" relativeToChangelogFile="false"/> -->
<include file="classpath:config/liquibase/changelog/20160321161717_added_entity_Guard.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20160321161717_added_entity_Conditional.xml" relativeToChangelogFile="false"/>
<!-- jhipster-needle-liquibase-add-changelog - JHipster will add liquibase changelogs here -->
</databaseChangeLog>
......@@ -231,12 +231,12 @@
<script src="scripts/app/entities/compoundStatement/compoundStatement-delete-dialog.controller.js"></script>
<script src="scripts/app/entities/compoundStatement/compoundStatement-detail.controller.js"></script>
<script src="scripts/components/entities/compoundStatement/compoundStatement.service.js"></script>
<script src="scripts/app/entities/guard/guard.js"></script>
<script src="scripts/app/entities/guard/guard.controller.js"></script>
<script src="scripts/app/entities/guard/guard-dialog.controller.js"></script>
<script src="scripts/app/entities/guard/guard-delete-dialog.controller.js"></script>
<script src="scripts/app/entities/guard/guard-detail.controller.js"></script>
<script src="scripts/components/entities/guard/guard.service.js"></script>
<script src="scripts/app/entities/conditional/conditional.js"></script>
<script src="scripts/app/entities/conditional/conditional.controller.js"></script>
<script src="scripts/app/entities/conditional/conditional-dialog.controller.js"></script>
<script src="scripts/app/entities/conditional/conditional-delete-dialog.controller.js"></script>
<script src="scripts/app/entities/conditional/conditional-detail.controller.js"></script>
<script src="scripts/components/entities/conditional/conditional.service.js"></script>
<!-- endbuild -->
</body>
</html>
'use strict';
angular.module('ddaApp')
.controller('GuardDeleteController', function($scope, $uibModalInstance, entity, Guard) {
.controller('ConditionalDeleteController', function($scope, $uibModalInstance, entity, Conditional) {
$scope.guard = entity;
$scope.conditional = entity;
$scope.clear = function() {
$uibModalInstance.dismiss('cancel');
};
$scope.confirmDelete = function (id) {
Guard.delete({id: id},
Conditional.delete({id: id},
function () {
$uibModalInstance.close(true);
});
......
<form name="deleteForm" ng-submit="confirmDelete(guard.id)">
<form name="deleteForm" ng-submit="confirmDelete(conditional.id)">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
ng-click="clear()">&times;</button>
......@@ -6,7 +6,7 @@
</div>
<div class="modal-body">
<jh-alert-error></jh-alert-error>
<p>Are you sure you want to delete this Guard?</p>
<p>Are you sure you want to delete this Conditional?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="clear()">
......
'use strict';
angular.module('ddaApp')
.controller('ConditionalDetailController', function ($scope, $rootScope, $stateParams, entity, Conditional, Statement, Step) {
$scope.conditional = entity;
$scope.load = function (id) {
Conditional.get({id: id}, function(result) {
$scope.conditional = result;
});
};
var unsubscribe = $rootScope.$on('ddaApp:conditionalUpdate', function(event, result) {
$scope.conditional = result;
});
$scope.$on('$destroy', unsubscribe);
});
<div>
<h2><span>Guard</span> {{guard.id}}</h2>
<h2><span>Conditional</span> {{conditional.id}}</h2>
<div class="table-responsive">
<table class="table table-striped">
<thead>
......@@ -15,15 +15,15 @@
<span>statement</span>
</td>
<td>
<a class="form-control-static" ui-sref="statement.detail({id:guard.statement.id})">{{guard.statement.id}}</a>
<a class="form-control-static" ui-sref="statement.detail({id:conditional.statement.id})">{{conditional.statement.id}}</a>
</td>
</tr>
<tr>
<td>
<span>destination</span>
<span>nextStep</span>
</td>
<td>
<a class="form-control-static" ui-sref="step.detail({id:guard.destination.id})">{{guard.destination.id}}</a>
<a class="form-control-static" ui-sref="step.detail({id:conditional.nextStep.id})">{{conditional.nextStep.id}}</a>
</td>
</tr>
</tbody>
......
'use strict';
angular.module('ddaApp').controller('GuardDialogController',
['$scope', '$stateParams', '$uibModalInstance', '$q', 'entity', 'Guard', 'Statement', 'Step',
function($scope, $stateParams, $uibModalInstance, $q, entity, Guard, Statement, Step) {
angular.module('ddaApp').controller('ConditionalDialogController',
['$scope', '$stateParams', '$uibModalInstance', '$q', 'entity', 'Conditional', 'Statement', 'Step',
function($scope, $stateParams, $uibModalInstance, $q, entity, Conditional, Statement, Step) {
$scope.guard = entity;
$scope.statements = Statement.query({filter: 'guard-is-null'});
$q.all([$scope.guard.$promise, $scope.statements.$promise]).then(function() {
if (!$scope.guard.statement || !$scope.guard.statement.id) {
$scope.conditional = entity;
$scope.statements = Statement.query({filter: 'conditional-is-null'});
$q.all([$scope.conditional.$promise, $scope.statements.$promise]).then(function() {
if (!$scope.conditional.statement || !$scope.conditional.statement.id) {
return $q.reject();
}
return Statement.get({id : $scope.guard.statement.id}).$promise;
return Statement.get({id : $scope.conditional.statement.id}).$promise;
}).then(function(statement) {
$scope.statements.push(statement);
});
$scope.steps = Step.query();
$scope.load = function(id) {
Guard.get({id : id}, function(result) {
$scope.guard = result;
Conditional.get({id : id}, function(result) {
$scope.conditional = result;
});
};
var onSaveSuccess = function (result) {
$scope.$emit('ddaApp:guardUpdate', result);
$scope.$emit('ddaApp:conditionalUpdate', result);
$uibModalInstance.close(result);
$scope.isSaving = false;
};
......@@ -33,10 +33,10 @@ angular.module('ddaApp').controller('GuardDialogController',
$scope.save = function () {
$scope.isSaving = true;
if ($scope.guard.id != null) {
Guard.update($scope.guard, onSaveSuccess, onSaveError);
if ($scope.conditional.id != null) {
Conditional.update($scope.conditional, onSaveSuccess, onSaveError);
} else {
Guard.save($scope.guard, onSaveSuccess, onSaveError);
Conditional.save($scope.conditional, onSaveSuccess, onSaveError);
}
};
......
......@@ -4,25 +4,25 @@
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
ng-click="clear()">&times;</button>
<h4 class="modal-title" id="myGuardLabel">Create or edit a Guard</h4>
<h4 class="modal-title" id="myConditionalLabel">Create or edit a Conditional</h4>
</div>
<div class="modal-body">
<jh-alert-error></jh-alert-error>
<div class="form-group">
<label for="id">ID</label>
<input type="text" class="form-control" id="id" name="id"
ng-model="guard.id" readonly />
ng-model="conditional.id" readonly />
</div>
<div class="form-group">
<label for="field_statement">Statement</label>
<select class="form-control" id="field_statement" name="statement" ng-model="guard.statement" ng-options="statement as statement.name for statement in statements | orderBy:'id' track by statement.id">
<label for="field_statement">statement</label>
<select class="form-control" id="field_statement" name="statement" ng-model="conditional.statement" ng-options="statement as statement.id for statement in statements | orderBy:'id' track by statement.id">
<option value=""></option>
</select>
</div>
<div class="form-group">
<label for="field_destination">Destination</label>
<select class="form-control" id="field_destination" name="destination" ng-model="guard.destination" ng-options="step as step.name for step in steps track by step.id">
<label for="field_nextStep">nextStep</label>
<select class="form-control" id="field_nextStep" name="nextStep" ng-model="conditional.nextStep" ng-options="step as step.id for step in steps track by step.id">
<option value=""></option>
</select>
</div>
......