atiq
(Mohd Atique)
January 19, 2021, 5:52am
1
Hello there, I am trying to add new property called image in location table to give logo to each location. I have added a column in location table and declared it in openmrs api . Data for respective image is coming from database but its not returning the image in response of api. I am new to hibernate ORM i also mapped the property for logo but didn’t getting it in api response.
end point that I am hitting http://localhost:8080/openmrs/ws/rest/v1/location
Thanks in Advance.
mozzy
(Moses Mutesasira)
January 19, 2021, 10:03am
2
@atiq ,
after adjusting the Location Model ,
you would also make a coresponding change in the Location Resource in the Rest API ,
but in the submodule coressponding to the OpenMRS version youre running.
you would have to add the new property in the Location Resource
2 Likes
atiq
(Mohd Atique)
January 19, 2021, 10:09am
3
Hi @mozzy desperately waited for response. Appreciate ! ! I am using core 2.3.2 I will do the changes and revert back the outcome with you Thanks A lot
1 Like
mozzy
(Moses Mutesasira)
January 19, 2021, 10:16am
4
atiq:
I am using core 2.3.2
Actually , simply add your property here , in the Location Resource Class for omod-2.0
this resource class supports up to OpenMRS 2.5
1 Like
atiq
(Mohd Atique)
January 19, 2021, 10:19am
5
Actually I am running 2.29.0 for web rest I couldn’t find Location Resource at there
mozzy
(Moses Mutesasira)
January 19, 2021, 10:21am
6
atiq
(Mohd Atique)
January 19, 2021, 10:24am
7
Ok actually i was searching in 2.29.0 branch in tags. I will follow as you suggest.
Thanks.
mozzy
(Moses Mutesasira)
January 19, 2021, 10:27am
8
well even under the 2.29.0 tag ,
its here
/**
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs2_0;
import org.openmrs.Location;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.Resource;
import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation;
import org.openmrs.module.webservices.rest.web.representation.FullRepresentation;
import org.openmrs.module.webservices.rest.web.representation.Representation;
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription;
import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.LocationResource1_9;
This file has been truncated. show original
1 Like
atiq
(Mohd Atique)
January 19, 2021, 11:12am
9
Hello @mozzy I am getting this error after buid is kind of error related to latitude but i haven’t done any changes in latitude.
here is the error
mozzy
(Moses Mutesasira)
January 19, 2021, 11:17am
10
can i have a look at your changes in github ??
1 Like
mozzy
(Moses Mutesasira)
January 19, 2021, 11:19am
11
can i also look at your property in the Location Class ??
1 Like
mozzy
(Moses Mutesasira)
January 19, 2021, 11:22am
12
from the Logs , Looks like theres a mismatch between the property you added in the Rest Module and what exactly you added in the Location Class
1 Like
atiq
(Mohd Atique)
January 19, 2021, 11:38am
13
Hey @mozzy I just created repo and pushed the code for core only. Please check my changes here
atiq
(Mohd Atique)
January 19, 2021, 11:43am
14
Changes what i did in webrest module.
mozzy
(Moses Mutesasira)
January 19, 2021, 11:48am
15
Better if you had just Forked the source code from OpenMRS repo to Your repo and then add your changes. It becomes easy and direct to track the changes you added
1 Like
atiq
(Mohd Atique)
January 19, 2021, 11:49am
16
Ok will do the same. Thanks
mozzy
(Moses Mutesasira)
January 19, 2021, 11:56am
17
did you add the coresponding column in the hibernate mappings for the property ??
atiq
(Mohd Atique)
January 19, 2021, 12:07pm
18
Yes I did I am sharing direct path to location.hbm
<?xml version="1.0"?>
<!--
This Source Code Form is subject to the terms of the Mozilla Public License,
v. 2.0. If a copy of the MPL was not distributed with this file, You can
obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
graphic logo is a trademark of OpenMRS Inc.
-->
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.openmrs">
<class name="Location" table="location">
<cache usage="read-write"/>
This file has been truncated. show original
please check.
atiq
(Mohd Atique)
January 19, 2021, 12:19pm
19
Hey @mozzy Sorry my bad there will be accidental mistake in locationId replaced with latitude. in hibernate mapping.
mozzy
(Moses Mutesasira)
January 19, 2021, 12:56pm
20
cool , does it work fine now ??
1 Like