Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Add location while creating thing (#1765)
Browse files Browse the repository at this point in the history
Signed-off-by: Aoun Bukhari <[email protected]>
  • Loading branch information
aounhaider1 authored and maggu2810 committed Jun 29, 2016
1 parent 42ab1e8 commit 3d99d66
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ public interface ThingRegistry extends Registry<Thing, ThingUID> {
* the configuration
* @return the created thing
*/
Thing createThingOfType(ThingTypeUID thingTypeUID, ThingUID thingUIDObject, ThingUID bridgeUID, String label,
Configuration configuration);
Thing createThingOfType(ThingTypeUID thingTypeUID, ThingUID thingUIDObject, ThingUID bridgeUID, String label,
String location, Configuration configuration);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* @author Chris Jackson - ensure thing added event is sent before linked events
* @auther Thomas Höfer - Added config description validation exception to updateConfiguration operation
*/
public class ThingRegistryImpl extends AbstractRegistry<Thing, ThingUID>implements ThingRegistry {
public class ThingRegistryImpl extends AbstractRegistry<Thing, ThingUID> implements ThingRegistry {

private Logger logger = LoggerFactory.getLogger(ThingRegistryImpl.class.getName());

Expand Down Expand Up @@ -241,11 +241,14 @@ private void notifyTrackerAboutAllThingsRemoved(ThingTracker thingTracker) {

@Override
public Thing createThingOfType(ThingTypeUID thingTypeUID, ThingUID thingUID, ThingUID bridgeUID, String label,
Configuration configuration) {
String location, Configuration configuration) {
logger.debug("Creating thing for type '{}'.", thingTypeUID);
for (ThingHandlerFactory thingHandlerFactory : thingHandlerFactories) {
if (thingHandlerFactory.supportsThingType(thingTypeUID)) {
Thing thing = thingHandlerFactory.createThing(thingTypeUID, configuration, thingUID, bridgeUID);
if (location != null) {
thing.setLocation(location);
}
thing.setLabel(label);
return thing;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public EnrichedThingDTO(ThingDTO thingDTO, ThingStatusInfo statusInfo, Map<Strin
if (thingDTO.label != null) {
this.label = thingDTO.label;
}
this.location = thingDTO.location;
this.thingTypeUID = thingDTO.thingTypeUID;
this.bridgeUID = thingDTO.bridgeUID;
this.channels = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public Response create(@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value
Configuration configuration = new Configuration(normalizeConfiguration(thingBean.configuration, thingTypeUID));

Thing thing = thingRegistry.createThingOfType(thingTypeUID, thingUID, bridgeUID, thingBean.label,
configuration);
thingBean.location, configuration);

if (thing != null) {
if (thingBean.properties != null) {
Expand Down Expand Up @@ -418,7 +418,7 @@ public Response update(@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value
public Response updateConfiguration(@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) String language,
@PathParam("thingUID") @ApiParam(value = "thing") String thingUID,
@ApiParam(value = "configuration parameters") Map<String, Object> configurationParameters)
throws IOException {
throws IOException {
final Locale locale = LocaleUtil.getLocale(language);

ThingUID thingUIDObject = new ThingUID(thingUID);
Expand Down

0 comments on commit 3d99d66

Please sign in to comment.