Project

General

Profile

« Previous | Next » 

Revision 50854

community API, first implementation based on the information system

View differences:

modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/AbstractExporterController.java
37 37
	protected final static String W = "write";
38 38

  
39 39
	protected final static String D = "deprecated";
40

  
41 40
	protected final static String M = "Management";
42 41

  
43 42
	protected final static String DSPACE = "DSpace";
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/community/CommunityConstants.java
10 10

  
11 11
	// id suffixes
12 12
	public final static String PROJECTS_ID_SUFFIX = ID_SEPARATOR + "projects";
13
	public final static String CONTENTPROVIDERS_ID_SUFFIX = ID_SEPARATOR + "dataproviders";
13
	public final static String CONTENTPROVIDERS_ID_SUFFIX = ID_SEPARATOR + "contentproviders";
14 14

  
15 15
	// community summary
16 16
	public final static String CSUMMARY_DESCRIPTION = "description";
......
27 27
	public final static String CPROJECT_FULLNAME = "projectfullname";
28 28
	public final static String CPROJECT_ACRONYM = "projectacronym";
29 29

  
30
	// community dataprovider
31
	public final static String CDATAPROVIDER_NAME = "name";
32
	public final static String CDATAPROVIDER_OFFICIALNAME = "officialname";
30
	// community content provider
31
	public final static String CCONTENTPROVIDER_NAME = "name";
32
	public final static String CCONTENTPROVIDER_OFFICIALNAME = "officialname";
33 33

  
34 34
}
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/community/CommunityMappingUtils.java
72 72
		final Map<String, List<Param>> p = c.getParams();
73 73
		final CommunityContentprovider d = new CommunityContentprovider();
74 74
		d.setOpenaireid(firstValue(p, OPENAIRE_ID));
75
		d.setName(firstValue(p, CDATAPROVIDER_NAME));
76
		d.setOfficialname(firstValue(p, CDATAPROVIDER_OFFICIALNAME));
75
		d.setName(firstValue(p, CCONTENTPROVIDER_NAME));
76
		d.setOfficialname(firstValue(p, CCONTENTPROVIDER_OFFICIALNAME));
77 77

  
78 78
		return d;
79 79
	}
......
95 95
	}
96 96

  
97 97
	public static String asProjectXML(final String contextId, final CommunityProject project) {
98
		/*
99
        <concept claim="true" id="egi::projects::egiengage" label="EGI-ENGAGE">
100
            <param name="projectfullname">Engaging the EGI Community towards an Open Science Commons</param>
101
            <param name="suggestedAcknowledgement">(Acknowledgement)</param>
102
            <param name="rule">The European Grid Initiative (EGI) is partner in EGI-ENGAGE</param>
103
            <param name="CD_PROJECT_NUMBER">654142</param>
104
            <param name="funding">H2020-EU.1.4.1.3.</param>
105
            <param name="url">https://www.egi.eu/about/egi-engage/</param>
106
            <param name="funder">EC</param>
107
        </concept>
108
		 */
109 98
		final Escaper esc = XmlEscapers.xmlAttributeEscaper();
110 99
		final StringBuilder sb = new StringBuilder();
111 100
		sb.append(
112 101
				String.format(
113
						"<concept claim='true' id='%s::projects::%s' label='%s'>\n",
114
						escape(esc, contextId), escape(esc, project.getOpenaireid()), escape(esc, project.getAcronym())));
102
						"<concept claim='true' id='%s%s%s%s' label='%s'>\n",
103
						escape(esc, contextId), PROJECTS_ID_SUFFIX, ID_SEPARATOR, escape(esc, project.getOpenaireid()), escape(esc, project.getAcronym())));
115 104
		sb.append(paramXML(CPROJECT_FULLNAME, project.getName()));
116 105
		sb.append(paramXML(CPROJECT_NUMBER, project.getGrantId()));
117 106
		sb.append(paramXML(CPROJECT_FUNDER, project.getFunder()));
......
120 109
		return sb.toString();
121 110
	}
122 111

  
123
	public static String asContentProviderXML(final String contextId, final CommunityContentprovider dataprovider) {
124
		/*
125
        <concept claim="true" id="egi::dataproviders::arxiv" label="Arxiv">
126
            <param name="openaireid">opendoar___1234::aaaaaa</param>
127
            <param name="name">Arxiv</param>
128
            <param name="officialname">Arxiv E-Prints archive</param>
129
        </concept>
130
		 */
112
	public static String asContentProviderXML(final String contextId, final CommunityContentprovider ccp) {
131 113
		final Escaper esc = XmlEscapers.xmlAttributeEscaper();
132 114
		final StringBuilder sb = new StringBuilder();
133 115
		sb.append(
134 116
				String.format(
135
						"<concept claim='true' id='%s::dataproviders::%s' label='%s'>\n",
136
						escape(esc, contextId), escape(esc, dataprovider.getOpenaireid()), escape(esc, dataprovider.getName())));
137
		sb.append(paramXML(OPENAIRE_ID, dataprovider.getOpenaireid()));
138
		sb.append(paramXML(CDATAPROVIDER_NAME, dataprovider.getName()));
139
		sb.append(paramXML(CDATAPROVIDER_OFFICIALNAME, dataprovider.getOfficialname()));
117
						"<concept claim='true' id='%s%s%s%s' label='%s'>\n",
118
						escape(esc, contextId), CONTENTPROVIDERS_ID_SUFFIX, ID_SEPARATOR, escape(esc, ccp.getOpenaireid()), escape(esc, ccp.getName())));
119
		sb.append(paramXML(OPENAIRE_ID, ccp.getOpenaireid()));
120
		sb.append(paramXML(CCONTENTPROVIDER_NAME, ccp.getName()));
121
		sb.append(paramXML(CCONTENTPROVIDER_OFFICIALNAME, ccp.getOfficialname()));
140 122
		sb.append("</concept>\n");
141 123
		return sb.toString();
142 124
	}
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/community/CommunityApiController.java
87 87
		communityApiCore.removeCommunityProject(id, projectId);
88 88
	}
89 89

  
90
	@RequestMapping(value = "/community/{id}/dataproviders", produces = { "application/json" }, method = RequestMethod.GET)
90
	@RequestMapping(value = "/community/{id}/contentproviders", produces = { "application/json" }, method = RequestMethod.GET)
91 91
	@ApiOperation(
92
			value = "get community projects",
93
			notes = "get community projects",
92
			value = "get the list of content providers associated to a given community",
93
			notes = "get the list of content providers associated to a given community",
94 94
			tags = { C, R, C_CP },
95 95
			response = CommunityContentprovider[].class)
96 96
	@ApiResponses(value = {
......
100 100
		return communityApiCore.getCommunityContentproviders(id);
101 101
	}
102 102

  
103
	@RequestMapping(value = "/community/{id}/dataproviders", produces = { "application/json" }, method = RequestMethod.POST)
103
	@RequestMapping(value = "/community/{id}/contentproviders", produces = { "application/json" }, method = RequestMethod.POST)
104 104
	@ApiOperation(
105 105
			value = "associate a content provider to the community",
106 106
			notes = "associate a content provider to the community",
......
115 115
		communityApiCore.addCommunityContentprovider(id, contentprovider);
116 116
	}
117 117

  
118
	@RequestMapping(value = "/community/{id}/dataproviders", produces = { "application/json" }, method = RequestMethod.DELETE)
118
	@RequestMapping(value = "/community/{id}/contentproviders", produces = { "application/json" }, method = RequestMethod.DELETE)
119 119
	@ApiOperation(
120
			value = "associate a content provider to the community",
121
			notes = "associate a content provider to the community",
120
			value = "remove the association between a content provider and the community",
121
			notes = "remove the association between a content provider and the community",
122 122
			tags = { C, W, C_CP })
123 123
	@ApiResponses(value = {
124 124
			@ApiResponse(code = 200, message = "OK"),
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/datasource/clients/ISClientImpl.java
101 101
				_getQuery(config.getFindCommunityContexts()));
102 102
	}
103 103

  
104
	@Override
104 105
	public void addConcept(final String id, final String categoryId, final String data) {
105 106
		final Queue<Throwable> errors = Lists.newLinkedList();
106 107
		final String xquery = String.format(
......
113 114
		}
114 115
	}
115 116

  
117
	@Override
116 118
	public void removeConcept(final String id, final String categoryId, final String conceptId) {
117 119
		final Queue<Throwable> errors = Lists.newLinkedList();
118 120
		_quickSeachProfile(String.format(

Also available in: Unified diff