Project

General

Profile

« Previous | Next » 

Revision 55761

reintegrated branch solr75 -r53793:HEAD

View differences:

modules/dnet-directindex-api/trunk/src/test/java/eu/dnetlib/msro/openaireplus/api/objects/ResultEntryTest.java
1 1
package eu.dnetlib.msro.openaireplus.api.objects;
2 2

  
3
import java.io.InputStreamReader;
4
import java.io.StringReader;
5
import java.util.ArrayList;
6
import java.util.Arrays;
7
import java.util.Properties;
8

  
9 3
import com.google.gson.Gson;
10 4
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
11 5
import eu.dnetlib.openaire.directindex.api.DirecIndexApiException;
......
23 17
import org.mockito.Mock;
24 18
import org.mockito.runners.MockitoJUnitRunner;
25 19

  
20
import java.io.InputStreamReader;
21
import java.io.StringReader;
22
import java.util.ArrayList;
23
import java.util.Arrays;
24
import java.util.Properties;
25

  
26 26
import static org.mockito.Matchers.anyString;
27 27
import static org.mockito.Mockito.when;
28 28

  
......
186 186

  
187 187
	}
188 188

  
189

  
190 189
	@Test
191 190
	public void testAsIndexRecord_json() throws Exception {
192 191
		testAsIndexRecord_json("test_record.json");
......
246 245
		final ResultEntry pub =
247 246
				new Gson().fromJson(new InputStreamReader(getClass().getResourceAsStream(filename)), ResultEntry.class);
248 247

  
248

  
249 249
		final String xml = pub.asOafRecord(ve, lookUpService, "http://oaf/oaf.xsd");
250 250
		//System.out.println(xml);
251 251

  
......
261 261
	}
262 262

  
263 263
	@Test
264
	public void testAsIndexRecord_json_zenodoProblems()throws Exception{
265
		testAsIndexRecord_json("test_zenodo_problems.json");
264
	public void testAsIndexRecord_json_zenodocommunities()throws Exception{
265
		testAsIndexRecord_json("test_zenodo_community.json");
266 266
	}
267 267

  
268 268
	@Test
......
272 272
		System.out.println(StringEscapeUtils.escapeXml11(unicodeTxt));
273 273
	}
274 274

  
275

  
276
	@Test
277
	public void testAsIndexRecord_json_zenodocommunities()throws Exception{
278
		testAsIndexRecord_json("test_zenodo_community.json");
279
	}
280

  
281 275
}
modules/dnet-directindex-api/trunk/src/main/java/eu/dnetlib/openaire/directindex/api/OpenAIRESubmitterUtils.java
1 1
package eu.dnetlib.openaire.directindex.api;
2 2

  
3 3
import java.io.StringWriter;
4
import java.util.ArrayList;
5
import java.util.HashMap;
6
import java.util.List;
7
import java.util.Map;
4
import java.util.*;
8 5
import java.util.stream.Collectors;
6
import java.util.stream.Collectors;
9 7

  
10 8
import com.google.common.base.Function;
11 9
import com.google.common.collect.Lists;
12 10
import eu.dnetlib.miscutils.functional.hash.Hashing;
11
import eu.dnetlib.openaire.directindex.objects.ZenodoContextList;
13 12
import org.apache.commons.lang.StringUtils;
13
import org.springframework.web.client.RestTemplate;
14 14

  
15 15
/**
16 16
 * Created by michele on 15/01/16.
......
18 18
public class OpenAIRESubmitterUtils {
19 19

  
20 20
	private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(OpenAIRESubmitterUtils.class);
21

  
21
	private static final String ZENODO_COMMUNITY = "zenodo.org/communities/";
22 22
	public Map<String, String> calculateProjectInfo(final String link) {
23 23
		final Map<String, String> info = new HashMap<String, String>();
24 24
		final String[] arr = link.split("/");
......
142 142
	}
143 143

  
144 144
	private List<String> filterContexts(List<String> contexts){
145
		return contexts.stream().filter(c -> !c.contains("zenodo.org/communities/")).collect(Collectors.toList());
145

  
146
		List<String> zenodoContexts
147
				= contexts.stream()
148
				.map(c -> {
149
					if(c.contains(ZENODO_COMMUNITY))
150
						return c.substring(c.lastIndexOf("/")+1);
151
					return null;
152
				}).collect(Collectors.toList());
153

  
154
//		for(String c:contexts){
155
//			if(c.contains(ZENODO_COMMUNITY)){
156
//				zenodoContexts.add(c.substring(c.lastIndexOf("/")+1));
157
//			}
158
//		}
159
		if (zenodoContexts.size()>0){
160
			contexts = contexts.stream().filter(c -> !c.contains("https://zenodo.org/communities/")).collect(Collectors.toList());
161
			RestTemplate rt = new RestTemplate();
162
			Set<String> zenodoOpenAIRE = new HashSet<>();
163
			for (String context: zenodoContexts){
164
				//String ct = context.substring(context.lastIndexOf("/")+1);
165
				zenodoOpenAIRE.addAll(rt.getForObject("http://beta.services.openaire.eu/openaire/community/"+context+"/openairecommunities", ZenodoContextList.class).getOpenAirecommunitylist());
166

  
167
			}
168
			contexts.addAll(zenodoOpenAIRE);
169
		}
170

  
171
		return contexts;
172

  
146 173
	}
147

  
148 174
	public List<ContextInfo> processContexts(final List<String> list) {
175
		filterContexts(list);
149 176
		return Lists.newArrayList(Lists.transform(filterContexts(list), new Function<String, ContextInfo>() {
150 177

  
151 178
			@Override
modules/dnet-directindex-api/trunk/src/main/java/eu/dnetlib/openaire/directindex/objects/ZenodoContextList.java
1
package eu.dnetlib.openaire.directindex.objects;
2

  
3
import java.util.ArrayList;
4
import java.util.List;
5
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
6

  
7
@JsonIgnoreProperties(ignoreUnknown = true)
8
public class ZenodoContextList {
9

  
10

  
11
        private String zenodoid;
12

  
13

  
14
        private List<String> openAirecommunitylist;
15

  
16

  
17

  
18
        public List<String> getOpenAirecommunitylist() {
19
            return openAirecommunitylist;
20
        }
21

  
22
        public void setOpenAirecommunitylist(List<String> openAirecommunitylist) {
23
            this.openAirecommunitylist = openAirecommunitylist;
24

  
25
        }
26

  
27
        public String getZenodoid() {
28
            return zenodoid;
29
        }
30

  
31
        public void setZenodoid(String zenodoid) {
32
            this.zenodoid = zenodoid;
33

  
34
        }
35

  
36

  
37

  
38
    }
39

  
40

  
41

  
modules/dnet-directindex-api/trunk/src/main/java/eu/dnetlib/openaire/directindex/objects/ResultEntry.java
1 1
package eu.dnetlib.openaire.directindex.objects;
2 2

  
3 3
import java.text.SimpleDateFormat;
4
import java.util.ArrayList;
5
import java.util.Date;
6
import java.util.HashMap;
7
import java.util.List;
8
import java.util.Map;
4
import java.util.*;
9 5
import java.util.concurrent.TimeUnit;
6
import java.util.stream.Collector;
10 7
import java.util.stream.Collectors;
11
import java.util.stream.Stream;
12 8

  
13 9
import org.apache.commons.lang.StringUtils;
14 10
import org.apache.commons.logging.Log;
......
26 22
import eu.dnetlib.openaire.directindex.api.DirecIndexApiException;
27 23
import eu.dnetlib.openaire.directindex.api.OpenAIRESubmitterUtils;
28 24
import io.swagger.annotations.ApiModelProperty;
25
import org.springframework.web.client.RestTemplate;
29 26

  
30 27
/**
31 28
 * Created by michele on 02/12/15.
32 29
 */
33 30
public class ResultEntry {
34 31

  
32

  
35 33
	private String openaireId;
36 34
	private String originalId;
37 35
	private String title;
......
150 148

  
151 149
	/**
152 150
	 * Set required = true when the deprecated licenseCode is not used anymore by our client and it is removed
153
	 * @return
151
	 * @return access rights code
154 152
	 */
155 153
	@ApiModelProperty(required = false, allowableValues = "OPEN, CLOSED, RESTRICTED, EMBARGO, UNKNOWN, OTHER, OPEN SOURCE")
156 154
	public String getAccessRightCode() {
......
205 203
		this.contexts = contexts;
206 204
	}
207 205

  
206

  
207

  
208 208
	@ApiModelProperty(value = "E.g. info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus")
209 209
	public List<String> getLinksToProjects() {
210 210
		return linksToProjects;
modules/dnet-directindex-api/trunk/src/main/resources/eu/dnetlib/openaire/directindex/indexRecord.xml.vm
84 84
					</datainfo>
85 85

  
86 86
					<rels>
87

  
88 87
						#foreach($link in $!pub.linksToProjects)
89 88

  
90 89
							#set( $info = $!util.calculateProjectInfo($!link) )
modules/dnet-directindex-api/trunk/pom.xml
10 10
	<groupId>eu.dnetlib</groupId>
11 11
	<artifactId>dnet-directindex-api</artifactId>
12 12
	<packaging>jar</packaging>
13
	<version>1.1.15-SNAPSHOT</version>
13
	<version>2.1.13-SNAPSHOT</version>
14 14

  
15 15
	<scm>
16 16
		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-directindex-api/trunk</developerConnection>
......
19 19
		<dependency>
20 20
			<groupId>eu.dnetlib</groupId>
21 21
			<artifactId>dnet-openaireplus-mapping-utils</artifactId>
22
			<version>[6.0.0,7.0.0)</version>
22
			<version>[6.2.21-solr75]</version>
23 23
			<exclusions>
24 24
				<exclusion>
25 25
					<groupId>eu.dnetlib</groupId>
......
29 29
		</dependency>
30 30
		<dependency>
31 31
			<groupId>eu.dnetlib</groupId>
32
			<artifactId>dnet-index-solr-client</artifactId>
33
			<version>[2.4.2]</version>
32
			<artifactId>dnet-index-client</artifactId>
33
			<version>[2.3.3-solr75]</version>
34 34
		</dependency>
35 35
		<dependency>
36 36
			<groupId>junit</groupId>
......
75 75
			<artifactId>spring-context-support</artifactId>
76 76
			<version>${spring.version}</version>
77 77
		</dependency>
78
		<dependency>
79
			<groupId>com.fasterxml.jackson.core</groupId>
80
			<artifactId>jackson-annotations</artifactId>
81
			<version>2.9.4</version>
82
		</dependency>
78 83
	</dependencies>
79 84

  
80 85
	<properties>

Also available in: Unified diff