Project

General

Profile

« Previous | Next » 

Revision 49965

implemented update method for field registeredBy, implemented search by registeredBy, updated urls for update methods

View differences:

modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/model/datasource/db/Datasource.java
11 11
 * Datasource
12 12
 */
13 13
@Entity
14
@Table(name = "dsm_datasources")
14
@Table(
15
	name = "dsm_datasources",
16
	indexes = {
17
		@Index(name = "dsm_datasources_contactemail_idx", columnList = "contactemail"),
18
		@Index(name = "dsm_datasources_englishname_idx", columnList = "englishname"),
19
		@Index(name = "dsm_datasources_officialname_idx", columnList = "officialname"),
20
		@Index(name = "dsm_datasources_registeredby_idx", columnList = "registeredby")
21
	})
15 22
@ApiModel(value = "Datasource model", description = "provides datasource details")
16 23
public class Datasource {
17 24

  
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/datasource/repository/DatasourceRepository.java
32 32
	@Async
33 33
	ListenableFuture<Slice<Datasource>> findDistinctByOrganizationsCountryIgnoreCase(String country, Pageable pageable);
34 34

  
35
	@Async
36
	ListenableFuture<Slice<Datasource>> findDistinctByRegisteredbyIgnoreCase(String registeredby, Pageable pageable);
37

  
35 38
	@Modifying
36 39
	@Transactional
37 40
	@Query("update Datasource d set d.managed = ?2 where d.id = ?1")
......
72 75
	@Query("update Datasource d set d.typology = ?2 where d.id = ?1")
73 76
	void setTypology(String id, String typology);
74 77

  
78
	@Modifying
79
	@Transactional
80
	@Query("update Datasource d set d.registeredby = ?2 where d.id = ?1")
81
	void setRegisteringUser(String id, String registeredby);
75 82

  
76 83
}
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/datasource/clients/DatasourceDao.java
130 130
		return new Response().setDatasourceResponse(datasourceResponse).setHeader(new Header().setErrors(errors));
131 131
	}
132 132

  
133
	public Response searchByRegisteringUser(final String registeredBy, final Pageable pageable) {
134

  
135
		final List<DatasourceResponse> datasourceResponse = Lists.newArrayList();
136

  
137
		final CountDownLatch outerLatch = new CountDownLatch(3);
138
		final Queue<Throwable> errors = new ConcurrentLinkedQueue<>();
139

  
140
		log.debug(String.format("search ds by registeredBy '%s'", registeredBy));
141
		dsRepository.findDistinctByRegisteredbyIgnoreCase(registeredBy, pageable).addCallback(getSearchCallback(outerLatch, errors, datasourceResponse));
142

  
143
		waitLatch(outerLatch, errors, config.getRequestTimeout());
144

  
145
		return new Response().setDatasourceResponse(datasourceResponse).setHeader(new Header().setErrors(errors));
146
	}
147

  
133 148
	public Response searchByContactemail(final String email, final Pageable pageable) {
134 149
		final List<DatasourceResponse> datasourceResponse = Lists.newArrayList();
135 150

  
......
345 360
		log.info(String.format("updated datasource '%s' with timezone '%s'", dsId, typology));
346 361
	}
347 362

  
363
	public void updateDatasourceRegisteringUser(final String dsId, final String registeredBy) {
364
		dsRepository.setRegisteringUser(dsId, registeredBy);
365
		log.info(String.format("updated datasource '%s' with registeredby '%s'", dsId, registeredBy));
366
	}
367

  
348 368
	public void dropCaches() {
349 369
		mongoLoggerClient.dropCache();
350 370
		isLookupClient.dropCache();
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/datasource/DatasourcesApi.java
46 46
            @ApiResponse(code = 500, message = "unexpected error", response = Response.class) })
47 47
    List<DatasourceResponse> searchByCountry(String country, int page, int size);
48 48

  
49
    @ApiOperation(value = "search datasources by registering user", notes = "Returns list of Datasource details.", response = DatasourceResponse[].class)
50
    @ApiResponses(value = {
51
            @ApiResponse(code = 200, message = "OK", response = DatasourceResponse[].class),
52
            @ApiResponse(code = 500, message = "unexpected error", response = Response.class) })
53
    List<DatasourceResponse> searchByRegisteringUser(String registeredBy, int page, int size);
54

  
49 55
    @ApiOperation(value = "search among datasource APIs", notes = "Returns Datasource Api details.", response = SearchInterfacesEntry[].class)
50 56
    @ApiResponses(value = {
51 57
            @ApiResponse(code = 200, message = "OK", response = SearchInterfacesEntry[].class),
......
144 150
            @ApiResponse(code = 400, message = "unexpected typology code")})
145 151
    void updateTypology(String dsId, String typology) throws ApiException;
146 152

  
153
    @ApiOperation(value = "updates a datasource registering user", notes = "updates a datasource registering user", httpMethod = "POST")
154
    @ApiResponses(value = {
155
            @ApiResponse(code = 200, message = "OK"),
156
            @ApiResponse(code = 500, message = "unexpected error"),
157
            @ApiResponse(code = 400, message = "unexpected typology code")})
158
    void updateRegisteringUser(String dsId, String registeredBy) throws ApiException;
159

  
160

  
147 161
}
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/datasource/DatasourcesApiController.java
95 95
	}
96 96

  
97 97
	@Override
98
	@RequestMapping(value = "/ds/search/registeredby/{page}/{size}", produces = { "application/json" }, method = RequestMethod.GET)
99
	public List<DatasourceResponse> searchByRegisteringUser(final String registeredBy, final int page, final int size) {
100
		final StopWatch stop = StopWatch.createStarted();
101
		final Response rsp = dsDao.searchByRegisteringUser(registeredBy, new PageRequest(page, size));
102
		rsp.getHeader().setTime(stop.getTime());
103
		if (log.isDebugEnabled()) {
104
			log.debug("searchByRegisteringUser: " + rsp.getHeader().toJson());
105
		}
106
		return rsp.getDatasourceResponse();
107
	}
108

  
109
	@Override
98 110
	@RequestMapping(value = "/api/search/{field}", produces = { "application/json" }, method = RequestMethod.GET)
99 111
	public List<SearchInterfacesEntry> searchInterface(@PathVariable final String field, @RequestParam final String value) {
100 112
		return dsDao.searchInterface(field, value);
......
168 180
	}
169 181

  
170 182
	@Override
171
	@RequestMapping(value = "/ds/update/officialname", method = RequestMethod.POST)
183
	@RequestMapping(value = "/ds/officialname", method = RequestMethod.POST)
172 184
	public void updateOfficialname(@RequestParam final String dsId, @RequestParam final String officialname) throws ApiException {
173 185
		dsDao.updateOfficialName(dsId, officialname);
174 186
	}
175 187

  
176 188
	@Override
177
	@RequestMapping(value = "/ds/update/englishname", method = RequestMethod.POST)
189
	@RequestMapping(value = "/ds/englishname", method = RequestMethod.POST)
178 190
	public void updateEnglishname(@RequestParam final String dsId, @RequestParam final String englishname) throws ApiException {
179 191
		dsDao.updateEnglishName(dsId, englishname);
180 192
	}
181 193

  
182 194
	@Override
183
	@RequestMapping(value = "/ds/update/latitude", method = RequestMethod.POST)
195
	@RequestMapping(value = "/ds/latitude", method = RequestMethod.POST)
184 196
	public void updateLatitude(final String dsId, final Double latitude) throws ApiException {
185 197
		dsDao.updateLatitude(dsId, latitude);
186 198
	}
187 199

  
188 200
	@Override
189
	@RequestMapping(value = "/ds/update/longitude", method = RequestMethod.POST)
201
	@RequestMapping(value = "/ds/longitude", method = RequestMethod.POST)
190 202
	public void updateLongitude(final String dsId, final Double longitude) throws ApiException {
191 203
		dsDao.updateLongitude(dsId, longitude);
192 204
	}
193 205

  
194 206
	@Override
195
	@RequestMapping(value = "/ds/update/logourl", method = RequestMethod.POST)
207
	@RequestMapping(value = "/ds/logourl", method = RequestMethod.POST)
196 208
	public void updateLogourl(final String dsId, final String logourl) throws ApiException {
197 209
		dsDao.updateLogourl(dsId, logourl);
198 210
	}
199 211

  
200 212
	@Override
201
	@RequestMapping(value = "/ds/update/timezone", method = RequestMethod.POST)
213
	@RequestMapping(value = "/ds/timezone", method = RequestMethod.POST)
202 214
	public void updateTimezone(final String dsId, final String timezone) throws ApiException {
203 215
		dsDao.updateTimezone(dsId, timezone);
204 216
	}
205 217

  
206 218
	@Override
207
	@RequestMapping(value = "/ds/update/typology", method = RequestMethod.POST)
219
	@RequestMapping(value = "/ds/typology", method = RequestMethod.POST)
208 220
	public void updateTypology(final String dsId, final String typology) throws ApiException {
209 221
		dsDao.updateDatasourceTypology(dsId, typology);
210 222
	}
211 223

  
224
	@Override
225
	@RequestMapping(value = "/ds/registeredby", method = RequestMethod.POST)
226
	public void updateRegisteringUser(final String dsId, final String registeredBy) throws ApiException {
227
		dsDao.updateDatasourceRegisteringUser(dsId, registeredBy);
228
	}
229

  
212 230
	@ApiOperation(value = "drop the datasource manager caches", notes = "drop the datasource manager caches", httpMethod = "GET")
213 231
	@ApiResponses(value = {
214 232
			@ApiResponse(code = 200, message = "OK"),
modules/dnet-openaire-exporter/trunk/src/main/resources/dnet_dsm.sql
164 164
CREATE INDEX dsm_datasources_contactemail_idx ON dsm_datasources (contactemail);
165 165
CREATE INDEX dsm_datasources_englishname_idx ON dsm_datasources (englishname);
166 166
CREATE INDEX dsm_datasources_officialname_idx ON dsm_datasources (officialname);
167
CREATE INDEX dsm_datasources_registeredby_idx ON dsm_datasources (registeredby);
167 168

  
168 169
ALTER TABLE dsm_datasources OWNER TO dnetapi;
169 170

  

Also available in: Unified diff