Project

General

Profile

« Previous | Next » 

Revision 8724

check for null entities and/or attributes (typically when otherEntity is being used in EML).

View differences:

src/edu/ucsb/nceas/metacat/annotation/DatapackageSummarizer.java
55 55
	public static String oboe = "http://ecoinformatics.org/oboe/oboe.1.0/oboe.owl#";
56 56
	public static String oboe_core = "http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#";
57 57
	public static String oboe_characteristics = "http://ecoinformatics.org/oboe/oboe.1.0/oboe-characteristics.owl#";
58
	public static String oboe_sbc = "http://ecoinformatics.org/oboe-ext/sbclter.1.0/oboe-sbclter.owl#";
58 59
	public static String oa = "http://www.w3.org/ns/oa#";
59 60
	public static String oa_source = "http://www.w3.org/ns/oa.rdf";
60 61
	public static String dcterms = "http://purl.org/dc/terms/";
......
85 86
		ont.addImport(m.createResource(oboe));
86 87
		m.addSubModel(ModelFactory.createOntologyModel().read(oboe));
87 88
		
89
		ont.addImport(m.createResource(oboe_sbc));
90
		m.addSubModel(ModelFactory.createOntologyModel().read(oboe_sbc));
91
		
88 92
		ont.addImport(m.createResource(oa));
89 93
		m.addSubModel(ModelFactory.createOntologyModel().read(oa_source));
90 94

  
......
156 160
		// loop through the tables and attributes
157 161
		int entityCount = 1;
158 162
		Entity[] entities = dataPackage.getEntityList();
159
		for (Entity entity: entities) {
160
			String entityName = entity.getName();
161
			logMetacat.debug("Entity name: " + entityName);
162
			Attribute[] attributes = entity.getAttributeList().getAttributes();
163
			int attributeCount = 1;
164
			for (Attribute attribute: attributes) {
165
				
166
				// for naming the individuals uniquely
167
				String cnt = entityCount + "_" + attributeCount;
168
				
169
				String attributeName = attribute.getName();
170
				String attributeLabel = attribute.getLabel();
171
				String attributeDefinition = attribute.getDefinition();
172
				String attributeType = attribute.getAttributeType();
173
				String attributeScale = attribute.getMeasurementScale();
174
				String attributeUnitType = attribute.getUnitType();
175
				String attributeUnit = attribute.getUnit();
176
				String attributeDomain = attribute.getDomain().getClass().getSimpleName();
177

  
178
				logMetacat.debug("Attribute name: " + attributeName);
179
				logMetacat.debug("Attribute label: " + attributeLabel);
180
				logMetacat.debug("Attribute definition: " + attributeDefinition);
181
				logMetacat.debug("Attribute type: " + attributeType);
182
				logMetacat.debug("Attribute scale: " + attributeScale);
183
				logMetacat.debug("Attribute unit type: " + attributeUnitType);
184
				logMetacat.debug("Attribute unit: " + attributeUnit);
185
				logMetacat.debug("Attribute domain: " + attributeDomain);
186
			
187
				// look up the characteristic or standard subclasses
188
				Resource standard = this.lookupStandard(standardClass, attribute);
189
				Resource characteristic = this.lookupCharacteristic(characteristicClass, attribute);
190
				
191
				if (standard != null || characteristic != null) {
163
		if (entities != null) {
164
			for (Entity entity: entities) {
165
				String entityName = entity.getName();
166
				logMetacat.debug("Entity name: " + entityName);
167
				Attribute[] attributes = entity.getAttributeList().getAttributes();
168
				int attributeCount = 1;
169
				if (attributes != null) {
170
					for (Attribute attribute: attributes) {
171
						
172
						// for naming the individuals uniquely
173
						String cnt = entityCount + "_" + attributeCount;
174
						
175
						String attributeName = attribute.getName();
176
						String attributeLabel = attribute.getLabel();
177
						String attributeDefinition = attribute.getDefinition();
178
						String attributeType = attribute.getAttributeType();
179
						String attributeScale = attribute.getMeasurementScale();
180
						String attributeUnitType = attribute.getUnitType();
181
						String attributeUnit = attribute.getUnit();
182
						String attributeDomain = attribute.getDomain().getClass().getSimpleName();
183
		
184
						logMetacat.debug("Attribute name: " + attributeName);
185
						logMetacat.debug("Attribute label: " + attributeLabel);
186
						logMetacat.debug("Attribute definition: " + attributeDefinition);
187
						logMetacat.debug("Attribute type: " + attributeType);
188
						logMetacat.debug("Attribute scale: " + attributeScale);
189
						logMetacat.debug("Attribute unit type: " + attributeUnitType);
190
						logMetacat.debug("Attribute unit: " + attributeUnit);
191
						logMetacat.debug("Attribute domain: " + attributeDomain);
192 192
					
193
					// instances
194
					Individual m1 = m.createIndividual(ont.getURI() + "#measurement" + cnt, measurementClass);
195
					Individual a1 = m.createIndividual(ont.getURI() + "#annotation" + cnt, annotationClass);
196
					Individual t1 = m.createIndividual(ont.getURI() + "#target" + cnt, specificResourceClass);
197
					String xpointer = "xpointer(/eml/dataSet/" + entityCount + "/attributeList/" + attributeCount + ")";
198
					Individual s1 = m.createIndividual(ont.getURI() + "#" + xpointer, fragmentSelectorClass);
199
					s1.addLiteral(rdfValue, xpointer);
200
					s1.addProperty(conformsToProperty, "http://www.w3.org/TR/xptr/");
201
					
202
					// statements about the annotation
203
					a1.addProperty(hasBodyProperty, m1);
204
					a1.addProperty(hasTargetProperty, t1);
205
					t1.addProperty(hasSourceProperty, meta1);
206
					t1.addProperty(hasSelectorProperty, s1);
207
					//a1.addProperty(annotatedByProperty, p1);
208
					
209
					// describe the measurement in terms of restrictions
210
					if (standard != null) {
211
						AllValuesFromRestriction avfr = m.createAllValuesFromRestriction(null, usesStandard, standard);
212
						m1.addOntClass(avfr);
193
						// look up the characteristic or standard subclasses
194
						Resource standard = this.lookupStandard(standardClass, attribute);
195
						Resource characteristic = this.lookupCharacteristic(characteristicClass, attribute);
196
						
197
						if (standard != null || characteristic != null) {
198
							
199
							// instances
200
							Individual m1 = m.createIndividual(ont.getURI() + "#measurement" + cnt, measurementClass);
201
							Individual a1 = m.createIndividual(ont.getURI() + "#annotation" + cnt, annotationClass);
202
							Individual t1 = m.createIndividual(ont.getURI() + "#target" + cnt, specificResourceClass);
203
							String xpointer = "xpointer(/eml/dataSet/" + entityCount + "/attributeList/" + attributeCount + ")";
204
							Individual s1 = m.createIndividual(ont.getURI() + "#" + xpointer, fragmentSelectorClass);
205
							s1.addLiteral(rdfValue, xpointer);
206
							s1.addProperty(conformsToProperty, "http://www.w3.org/TR/xptr/");
207
							
208
							// statements about the annotation
209
							a1.addProperty(hasBodyProperty, m1);
210
							a1.addProperty(hasTargetProperty, t1);
211
							t1.addProperty(hasSourceProperty, meta1);
212
							t1.addProperty(hasSelectorProperty, s1);
213
							//a1.addProperty(annotatedByProperty, p1);
214
							
215
							// describe the measurement in terms of restrictions
216
							if (standard != null) {
217
								AllValuesFromRestriction avfr = m.createAllValuesFromRestriction(null, usesStandard, standard);
218
								m1.addOntClass(avfr);
219
							}
220
							if (characteristic != null) {
221
								AllValuesFromRestriction avfr = m.createAllValuesFromRestriction(null, ofCharacteristic, characteristic);
222
								m1.addOntClass(avfr);
223
							}
224
						}
225
						attributeCount++;
226
						
213 227
					}
214
					if (characteristic != null) {
215
						AllValuesFromRestriction avfr = m.createAllValuesFromRestriction(null, ofCharacteristic, characteristic);
216
						m1.addOntClass(avfr);
217
					}
218 228
				}
219
				attributeCount++;
220
				
229
				entityCount++;
221 230
			}
222
			entityCount++;
223 231
		}
224 232
		
225 233
		StringWriter sw = new StringWriter();

Also available in: Unified diff