Project

General

Profile

« Previous | Next » 

Revision 49324

feeding the registry with resources and relationships

View differences:

RegistryClient.java
29 29
	private static final String DRI_NAMESPACE_URI = "http://www.driver-repository.eu/namespace/dri";
30 30
	private static final String RDF_NAMESPACE_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
31 31

  
32
	private GCubeResourceGenerator resourceGenerator;
32
	private GCubeResourceRegistrator gCubeResourceRegistrator;
33 33
	private SaxonHelper saxonHelper;
34 34
	private XPathSelector xpathSelectorObjIdentifier;
35
	private XPathSelector xpathSelectorCollectionDate;
36
	private XPathSelector xpathSelectorTransformationDate;
37
	private XPathSelector xpathSelectorDatasourceName;
38
	private XPathSelector xpathSelectorDatasourceApi;
35
	//	private XPathSelector xpathSelectorCollectionDate;
36
	//	private XPathSelector xpathSelectorTransformationDate;
37
	//	private XPathSelector xpathSelectorDatasourceName;
38
	//	private XPathSelector xpathSelectorDatasourceApi;
39 39
	private XPathSelector xpathSelectorRDF;
40 40

  
41 41
	private ResourceRegistryPublisher resourceRegistryPublisher;
......
43 43
	private String registryBaseURL;
44 44
	private String defaultBaseURI;
45 45

  
46
	protected RegistryClient(final String registryBaseURL, final SaxonHelper saxonHelper, final String defaultBaseURI, final GCubeResourceGenerator resourceGenerator)
46
	protected RegistryClient(final String registryBaseURL,
47
			final SaxonHelper saxonHelper,
48
			final String defaultBaseURI,
49
			final GCubeResourceRegistrator gCubeResourceRegistrator)
47 50
			throws ParthenosPublisherException {
48 51
		this.registryBaseURL = registryBaseURL;
49 52
		this.saxonHelper = saxonHelper;
50 53
		this.defaultBaseURI = defaultBaseURI;
51 54
		this.resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();
52 55
		this.resourceRegistryClient = ResourceRegistryClientFactory.create();
53
		this.resourceGenerator = resourceGenerator;
56
		this.gCubeResourceRegistrator = gCubeResourceRegistrator;
54 57
		try {
55 58
			prepareXpathSelectors();
56
		}catch(SaxonApiException e){
59
		} catch (SaxonApiException e) {
57 60
			throw new ParthenosPublisherException(e);
58 61
		}
59 62
	}
60 63

  
61
	public int register(final String record) throws ParthenosPublisherException{
64
	public int unregister(final String datasourceInterface) {
65
		return gCubeResourceRegistrator.unregister(datasourceInterface);
66
	}
67

  
68
	public void register(final String record) throws ParthenosPublisherException {
62 69
		try {
63 70
			if (StringUtils.isBlank(record)) {
64 71
				log.warn("Got empty record");
65
				return 0;
66 72
			}
67 73
			String objIdentifier = extractFromRecord(record, xpathSelectorObjIdentifier);
68 74
			if (StringUtils.isBlank(objIdentifier)) {
69 75
				log.warn("Got record with no objIdentifier -- skipping");
70
				return 0;
71 76
			}
72
			//TODO: get the json strings to register
73
			Iterable<String> resources = resourceGenerator.getGCubeER(record);
74
			for(String res : resources){
75
				//resourceRegistryPublisher.
76
			}
77
			return 0;
78
		}catch(Throwable e){
77
			String recordRDF = extractFromRecord(record, xpathSelectorRDF);
78
			gCubeResourceRegistrator.register(recordRDF, objIdentifier);
79
		} catch (Throwable e) {
79 80
			log.error(e.getMessage());
80 81
			throw new ParthenosPublisherException(e);
81 82
		}
82 83
	}
83 84

  
84

  
85 85
	private void prepareXpathSelectors() throws SaxonApiException {
86 86
		Map<String, String> namespaces = Maps.newHashMap();
87 87
		namespaces.put("oai", OAI_NAMESPACE_URI);
88 88
		namespaces.put("dri", DRI_NAMESPACE_URI);
89 89
		namespaces.put("rdf", RDF_NAMESPACE_URI);
90 90
		xpathSelectorObjIdentifier = this.saxonHelper.help().prepareXPathSelector("//oai:header/dri:objIdentifier/text()", namespaces);
91
		xpathSelectorCollectionDate = this.saxonHelper.help().prepareXPathSelector("//oai:header/dri:dateOfCollection/text()", namespaces);
92
		xpathSelectorTransformationDate = this.saxonHelper.help().prepareXPathSelector("//oai:header/dri:dateOfTransformation/text()", namespaces);
93
		xpathSelectorDatasourceName = this.saxonHelper.help().prepareXPathSelector("//oai:header/dri:datasourcename/text()", namespaces);
94
		xpathSelectorDatasourceApi = this.saxonHelper.help().prepareXPathSelector("//oai:header/dri:datasourceapi/text()", namespaces);
91
		//xpathSelectorCollectionDate = this.saxonHelper.help().prepareXPathSelector("//oai:header/dri:dateOfCollection/text()", namespaces);
92
		//xpathSelectorTransformationDate = this.saxonHelper.help().prepareXPathSelector("//oai:header/dri:dateOfTransformation/text()", namespaces);
93
		//xpathSelectorDatasourceName = this.saxonHelper.help().prepareXPathSelector("//oai:header/dri:datasourcename/text()", namespaces);
94
		//xpathSelectorDatasourceApi = this.saxonHelper.help().prepareXPathSelector("//oai:header/dri:datasourceapi/text()", namespaces);
95 95
		xpathSelectorRDF = this.saxonHelper.help().prepareXPathSelector("//oai:metadata/rdf:RDF", namespaces);
96 96
	}
97 97

  
......
103 103
		}
104 104
	}
105 105

  
106

  
107 106
	public void setSaxonHelper(final SaxonHelper saxonHelper) {
108 107
		this.saxonHelper = saxonHelper;
109 108
	}
......
128 127
		return defaultBaseURI;
129 128
	}
130 129

  
131
	public GCubeResourceGenerator getResourceGenerator() {
132
		return resourceGenerator;
130
	public GCubeResourceRegistrator getgCubeResourceRegistrator() {
131
		return gCubeResourceRegistrator;
133 132
	}
134 133

  
135
	public void setResourceGenerator(final GCubeResourceGenerator resourceGenerator) {
136
		this.resourceGenerator = resourceGenerator;
134
	public void setgCubeResourceRegistrator(final GCubeResourceRegistrator gCubeResourceRegistrator) {
135
		this.gCubeResourceRegistrator = gCubeResourceRegistrator;
137 136
	}
138 137

  
139 138
	public ResourceRegistryPublisher getResourceRegistryPublisher() {

Also available in: Unified diff