dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21329
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10056: FRED-API: rename id => uuid, url => href. updated UI to use href/uuid
------------------------------------------------------------
revno: 10056
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-03-07 21:52:55 +0300
message:
FRED-API: rename id => uuid, url => href. updated UI to use href/uuid
modified:
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityServiceController.java
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/domain/Facility.java
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/FacilityToOrganisationUnitConverter.java
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/FacilityToSimpleFeature.java
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/OrganisationUnitToFacilityConverter.java
dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/facilities.vm
dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/facility.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java 2013-03-07 15:05:03 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java 2013-03-07 18:52:55 +0000
@@ -173,7 +173,7 @@
// simple field filtering
if ( !strings.contains( "id" ) )
{
- facility.setId( null );
+ facility.setUuid( null );
}
if ( !strings.contains( "name" ) )
@@ -203,7 +203,7 @@
if ( !strings.contains( "url" ) )
{
- facility.setUrl( null );
+ facility.setHref( null );
}
if ( !strings.contains( "identifiers" ) )
@@ -447,9 +447,9 @@
@PreAuthorize( "hasRole('F_FRED_CREATE') or hasRole('ALL')" )
public ResponseEntity<String> createFacility( @RequestBody Facility facility ) throws Exception
{
- if ( facility.getId() == null )
+ if ( facility.getUuid() == null )
{
- facility.setId( UUID.randomUUID().toString() );
+ facility.setUuid( UUID.randomUUID().toString() );
}
Set<ConstraintViolation<Facility>> constraintViolations = validator.validate( facility, Default.class, Create.class );
@@ -571,9 +571,9 @@
}
// getId == null is not legal, but will be catched by bean validation
- if ( facility.getId() != null )
+ if ( facility.getUuid() != null )
{
- String uuid = facility.getId();
+ String uuid = facility.getUuid();
try
{
=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityServiceController.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityServiceController.java 2013-03-06 09:21:16 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityServiceController.java 2013-03-07 18:52:55 +0000
@@ -175,7 +175,7 @@
if ( constraintViolations.isEmpty() )
{
OrganisationUnit organisationUnit = conversionService.convert( facility, OrganisationUnit.class );
- OrganisationUnit ou = organisationUnitService.getOrganisationUnit( facility.getId() );
+ OrganisationUnit ou = organisationUnitService.getOrganisationUnit( facility.getUuid() );
if ( ou == null )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/domain/Facility.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/domain/Facility.java 2013-03-07 15:41:40 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/domain/Facility.java 2013-03-07 18:52:55 +0000
@@ -46,7 +46,7 @@
// Internal system identifier
@NotNull(groups = Update.class)
@Length(min = 36, max = 36)
- private String id;
+ private String uuid;
// Name of the facility
@NotNull
@@ -57,7 +57,7 @@
private Boolean active = true;
// URL link to the unique ID API resource for the facility
- private String url;
+ private String href;
// ISO 8601 timestamp, including timezone, of when the facility was created
private Date createdAt;
@@ -98,14 +98,14 @@
this.coordinates = coordinates;
}
- public String getId()
+ public String getUuid()
{
- return id;
+ return uuid;
}
- public void setId( String id )
+ public void setUuid( String uuid )
{
- this.id = id;
+ this.uuid = uuid;
}
public String getName()
@@ -128,14 +128,14 @@
this.active = active;
}
- public String getUrl()
+ public String getHref()
{
- return url;
+ return href;
}
- public void setUrl( String url )
+ public void setHref( String href )
{
- this.url = url;
+ this.href = href;
}
public Date getCreatedAt()
@@ -192,10 +192,10 @@
public String toString()
{
return "Facility{" +
- "id='" + id + '\'' +
+ "id='" + uuid + '\'' +
", name='" + name + '\'' +
", active=" + active +
- ", url='" + url + '\'' +
+ ", url='" + href + '\'' +
", createdAt=" + createdAt +
", updatedAt=" + updatedAt +
", coordinates=" + coordinates +
=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/FacilityToOrganisationUnitConverter.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/FacilityToOrganisationUnitConverter.java 2013-03-07 06:24:46 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/FacilityToOrganisationUnitConverter.java 2013-03-07 18:52:55 +0000
@@ -59,7 +59,7 @@
{
OrganisationUnit organisationUnit = new OrganisationUnit();
organisationUnit.setName( facility.getName() );
- organisationUnit.setUuid( facility.getId() );
+ organisationUnit.setUuid( facility.getUuid() );
if ( facility.getName() != null && facility.getName().length() > 49 )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/FacilityToSimpleFeature.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/FacilityToSimpleFeature.java 2012-12-13 17:04:35 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/FacilityToSimpleFeature.java 2013-03-07 18:52:55 +0000
@@ -75,7 +75,7 @@
Point point = geometryFactory.createPoint( coordinate );
featureBuilder.add( point );
- featureBuilder.add( facility.getId() );
+ featureBuilder.add( facility.getUuid() );
featureBuilder.add( facility.getName() );
featureBuilder.add( facility.getActive() );
=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/OrganisationUnitToFacilityConverter.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/OrganisationUnitToFacilityConverter.java 2013-03-06 09:25:29 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/OrganisationUnitToFacilityConverter.java 2013-03-07 18:52:55 +0000
@@ -58,7 +58,7 @@
public Facility convert( OrganisationUnit organisationUnit )
{
Facility facility = new Facility();
- facility.setId( organisationUnit.getUuid() );
+ facility.setUuid( organisationUnit.getUuid() );
facility.setName( organisationUnit.getDisplayName() );
facility.setActive( organisationUnit.isActive() );
facility.setCreatedAt( organisationUnit.getCreated() );
@@ -66,7 +66,7 @@
try
{
- facility.setUrl( linkTo( FacilityController.class ).slash( organisationUnit.getUid() ).toString() );
+ facility.setHref( linkTo( FacilityController.class ).slash( organisationUnit.getUid() ).toString() );
}
catch ( IllegalStateException ignored )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/facilities.vm'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/facilities.vm 2013-02-05 06:57:50 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/facilities.vm 2013-03-07 18:52:55 +0000
@@ -7,8 +7,8 @@
var facilities = [
#foreach( $facility in $entity.facilities )
{
- id: "$facility.id",
- url: "$facility.url",
+ id: "$facility.uuid",
+ url: "$facility.href",
name: "$esc.escapeEcmaScript($facility.name)",
coordinates: "$facility.coordinates"
},
@@ -39,8 +39,8 @@
var coords = JSON.parse(item.coordinates);
var latlng = new google.maps.LatLng(coords[1], coords[0]);
var name = item.name;
- var id = item.id;
- var url = item.url;
+ var id = item.uuid;
+ var href = item.href;
lats += coords[1];
lngs += coords[0];
@@ -55,7 +55,7 @@
var infoWindow= new google.maps.InfoWindow({
content: "<div>" + "<b>" + name + "</b><br/>Latitude " + coords[1] + "<br/> Longitude " + coords[0] +
- "<br/><br/><a href='" + url + "'>More information</a></div>"
+ "<br/><br/><a href='" + href + "'>More information</a></div>"
});
infoWindows.push(infoWindow);
@@ -176,8 +176,8 @@
<tbody>
#foreach( $facility in $entity.facilities )
- <tr data-facility-id='$facility.id'>
- <td class='facility-name'><a href='$facility.url'>$esc.escapeHtml4($facility.name)</a></td>
+ <tr data-facility-id='$facility.uuid'>
+ <td class='facility-name'><a href='$facility.href'>$esc.escapeHtml4($facility.name)</a></td>
<td class='facility-actions' style='width: 1px;'>
<div class='btn-group'>
=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/facility.vm'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/facility.vm 2013-02-03 10:13:17 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/facility.vm 2013-03-07 18:52:55 +0000
@@ -52,16 +52,16 @@
e.preventDefault();
$('#facilitySubmit').attr('disabled', true).text('Saving');
- $.get('$baseUrl/facilities/${entity.id}.json').success(function (data) {
+ $.get('$baseUrl/facilities/${entity.uuid}.json').success(function (data) {
delete data.createdAt;
delete data.updatedAt;
- delete data.url;
+ delete data.href;
data.name = $('#facilityName').val();
data.active = JSON.parse($('#facilityActive').val());
+ var lng = $('#facilityLongitude').val();
var lat = $('#facilityLatitude').val();
- var lng = $('#facilityLongitude').val();
data.coordinates = [ lng, lat ];
@@ -91,7 +91,7 @@
}
$.ajax({
- url: '$baseUrl/facilities/${entity.id}',
+ url: '$baseUrl/facilities/${entity.uuid}',
contentType: 'application/json; charset=UTF-8',
type: 'PUT',
data: JSON.stringify(data),