Skip to content

Commit

Permalink
automatic project update
Browse files Browse the repository at this point in the history
  • Loading branch information
jdubois committed Oct 16, 2015
1 parent bf5240c commit e0bd8b8
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 30 deletions.
26 changes: 8 additions & 18 deletions src/main/java/com/mycompany/myapp/domain/Operation.java
@@ -1,13 +1,8 @@
package com.mycompany.myapp.domain;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.mycompany.myapp.domain.util.CustomDateTimeDeserializer;
import com.mycompany.myapp.domain.util.CustomDateTimeSerializer;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Type;
import org.joda.time.DateTime;
import java.time.ZonedDateTime;

import javax.persistence.*;
import javax.validation.constraints.*;
Expand All @@ -29,26 +24,21 @@ public class Operation implements Serializable {
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;


@NotNull
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
@JsonSerialize(using = CustomDateTimeSerializer.class)
@JsonDeserialize(using = CustomDateTimeDeserializer.class)
@NotNull
@Column(name = "date", nullable = false)
private DateTime date;
private ZonedDateTime date;

@Column(name = "description")
private String description;

@NotNull
@NotNull
@Column(name = "amount", precision=10, scale=2, nullable = false)
private BigDecimal amount;

@ManyToOne
private BankAccount bankAccount;

@ManyToMany
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@ManyToMany @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@JoinTable(name = "operation_label",
joinColumns = @JoinColumn(name="operations_id", referencedColumnName="ID"),
inverseJoinColumns = @JoinColumn(name="labels_id", referencedColumnName="ID"))
Expand All @@ -62,11 +52,11 @@ public void setId(Long id) {
this.id = id;
}

public DateTime getDate() {
public ZonedDateTime getDate() {
return date;
}

public void setDate(DateTime date) {
public void setDate(ZonedDateTime date) {
this.date = date;
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config/liquibase/master.xml
Expand Up @@ -7,5 +7,6 @@
<include file="classpath:config/liquibase/changelog/00000000000000_initial_schema.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20150805124838_added_entity_BankAccount.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20150805124936_added_entity_Label.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20150805125054_added_entity_Operation.xml" relativeToChangelogFile="false"/>
<!-- JHipster will add liquibase changelogs here -->
</databaseChangeLog>
1 change: 1 addition & 0 deletions src/main/webapp/i18n/en/global.json
Expand Up @@ -8,6 +8,7 @@
"main": "Entities",
"bankAccount": "BankAccount",
"label": "Label",
"operation": "Operation",
"additionalEntity": "JHipster will add additional entities here (do not translate!)"
},
"account": {
Expand Down
1 change: 1 addition & 0 deletions src/main/webapp/i18n/fr/global.json
Expand Up @@ -8,6 +8,7 @@
"main": "Entités",
"bankAccount": "BankAccount",
"label": "Label",
"operation": "Operation",
"additionalEntity": "JHipster will add additional entities here (do not translate!)"
},
"account": {
Expand Down
5 changes: 5 additions & 0 deletions src/main/webapp/index.html
Expand Up @@ -154,6 +154,11 @@
<script src="scripts/app/entities/label/label-dialog.controller.js"></script>
<script src="scripts/app/entities/label/label-detail.controller.js"></script>
<script src="scripts/components/entities/label/label.service.js"></script>
<script src="scripts/app/entities/operation/operation.js"></script>
<script src="scripts/app/entities/operation/operation.controller.js"></script>
<script src="scripts/app/entities/operation/operation-dialog.controller.js"></script>
<script src="scripts/app/entities/operation/operation-detail.controller.js"></script>
<script src="scripts/components/entities/operation/operation.service.js"></script>
<!-- endbuild -->
</body>
</html>
Expand Up @@ -8,7 +8,9 @@ angular.module('sampleapplicationApp')
$scope.operation = result;
});
};
$rootScope.$on('sampleapplicationApp:operationUpdate', function(event, result) {
var unsubscribe = $rootScope.$on('sampleapplicationApp:operationUpdate', function(event, result) {
$scope.operation = result;
});
$scope.$on('$destroy', unsubscribe);

});
Expand Up @@ -24,7 +24,7 @@ <h4 class="modal-title" id="myOperationLabel" translate="sampleapplicationApp.op
This field is required.
</p>
<p class="help-block"
ng-show="editForm.date.$error.datetimelocal" translate="entity.validation.datetimelocal">
ng-show="editForm.date.$error.ZonedDateTimelocal" translate="entity.validation.ZonedDateTimelocal">
This field should be a date and time.
</p>
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/main/webapp/scripts/components/navbar/navbar.html
Expand Up @@ -32,6 +32,8 @@
&#xA0;<span translate="global.menu.entities.bankAccount">bankAccount</span></a></li>
<li ui-sref-active="active" ><a ui-sref="label" data-toggle="collapse" data-target=".navbar-collapse.in"><span class="glyphicon glyphicon-asterisk"></span>
&#xA0;<span translate="global.menu.entities.label">label</span></a></li>
<li ui-sref-active="active" ><a ui-sref="operation" data-toggle="collapse" data-target=".navbar-collapse.in"><span class="glyphicon glyphicon-asterisk"></span>
&#xA0;<span translate="global.menu.entities.operation">operation</span></a></li>
<!-- JHipster will add entities to the menu here -->
</ul>
</li>
Expand Down
Expand Up @@ -23,10 +23,10 @@

import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.math.BigDecimal;
import java.util.List;

Expand All @@ -46,12 +46,12 @@
@IntegrationTest
public class OperationResourceTest {

private static final DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'");
private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME.withZone(ZoneId.of("Z"));


private static final DateTime DEFAULT_DATE = new DateTime(0L, DateTimeZone.UTC);
private static final DateTime UPDATED_DATE = new DateTime(DateTimeZone.UTC).withMillisOfSecond(0);
private static final String DEFAULT_DATE_STR = dateTimeFormatter.print(DEFAULT_DATE);
private static final ZonedDateTime DEFAULT_DATE = ZonedDateTime.ofInstant(Instant.ofEpochMilli(0L), ZoneId.systemDefault());
private static final ZonedDateTime UPDATED_DATE = ZonedDateTime.now(ZoneId.systemDefault()).withNano(0);
private static final String DEFAULT_DATE_STR = dateTimeFormatter.format(DEFAULT_DATE);
private static final String DEFAULT_DESCRIPTION = "AAAAA";
private static final String UPDATED_DESCRIPTION = "BBBBB";

Expand Down Expand Up @@ -105,7 +105,7 @@ public void createOperation() throws Exception {
List<Operation> operations = operationRepository.findAll();
assertThat(operations).hasSize(databaseSizeBeforeCreate + 1);
Operation testOperation = operations.get(operations.size() - 1);
assertThat(testOperation.getDate().toDateTime(DateTimeZone.UTC)).isEqualTo(DEFAULT_DATE);
assertThat(testOperation.getDate()).isEqualTo(DEFAULT_DATE);
assertThat(testOperation.getDescription()).isEqualTo(DEFAULT_DESCRIPTION);
assertThat(testOperation.getAmount()).isEqualTo(DEFAULT_AMOUNT);
}
Expand Down Expand Up @@ -208,7 +208,7 @@ public void updateOperation() throws Exception {
List<Operation> operations = operationRepository.findAll();
assertThat(operations).hasSize(databaseSizeBeforeUpdate);
Operation testOperation = operations.get(operations.size() - 1);
assertThat(testOperation.getDate().toDateTime(DateTimeZone.UTC)).isEqualTo(UPDATED_DATE);
assertThat(testOperation.getDate()).isEqualTo(UPDATED_DATE);
assertThat(testOperation.getDescription()).isEqualTo(UPDATED_DESCRIPTION);
assertThat(testOperation.getAmount()).isEqualTo(UPDATED_AMOUNT);
}
Expand Down
@@ -0,0 +1,37 @@
'use strict';

describe('Operation Detail Controller', function() {
var scope, rootScope, entity, createController;

beforeEach(module('sampleapplicationApp'));
beforeEach(inject(function($rootScope, $controller) {
rootScope = $rootScope;
scope = rootScope.$new();
entity = jasmine.createSpyObj('entity', ['unused']);

createController = function() {
return $controller("OperationDetailController", {
'$scope': scope,
'$rootScope': rootScope,
'entity': null,
'Operation' : null,
'BankAccount' : null,
'Label' : null
});
};
}));


describe('Root Scope Listening', function() {
it('Unregisters root scope listener upon scope destruction',
function() {
var eventType = 'sampleapplicationApp:operationUpdate';

createController();
expect(rootScope.$$listenerCount[eventType]).toEqual(1);

scope.$destroy();
expect(rootScope.$$listenerCount[eventType]).toBeUndefined();
});
});
});

0 comments on commit e0bd8b8

Please sign in to comment.