|  | 54 | //TODO | 
                          |  | 55 | public static boolean validate(File file) throws Exception{ | 
                          |  | 56 | Model tmpModel = RDFDataMgr.loadModel(file.getAbsolutePath()); | 
                          |  | 57 | String endpointURI = getEndpointURI(tmpModel); | 
                          |  | 58 |  | 
                          |  | 59 | //TODO | 
                          |  | 60 | return true; | 
                          |  | 61 | } | 
                          |  | 62 |  | 
                          |  | 63 |  | 
                          |  | 64 | public static Resource getDefaultDataset(Model model) throws Exception{ | 
                          |  | 65 | Property sd_default_dataset = model.getProperty(URICollection.PROPERTY_SD_DEFAULT_DATA_SET); | 
                          |  | 66 | NodeIterator nit = model.listObjectsOfProperty(sd_default_dataset); | 
                          |  | 67 | Resource defaultDataSet = null; | 
                          |  | 68 | if( nit.hasNext() ){ | 
                          |  | 69 | RDFNode node = nit.next(); | 
                          |  | 70 | defaultDataSet = node.asResource(); | 
                          |  | 71 | } | 
                          |  | 72 | return defaultDataSet; | 
                          |  | 73 | } | 
                          |  | 74 |  | 
                          |  | 75 |  | 
                          |  | 76 | public static long getTriples(Resource defaultDataset) throws Exception{ | 
                          |  | 77 | // numTriples | 
                          |  | 78 | Model model = defaultDataset.getModel(); | 
                          |  | 79 | Property void_triples = model.getProperty(URICollection.PROPERTY_VOID_TRIPLES); | 
                          |  | 80 | NodeIterator nit = model.listObjectsOfProperty(defaultDataset, void_triples); | 
                          |  | 81 | long numTriples = 0; | 
                          |  | 82 | if( nit.hasNext()){ | 
                          |  | 83 | Literal numTriplesLit = nit.next().asLiteral(); | 
                          |  | 84 | numTriples = numTriplesLit.getLong(); | 
                          |  | 85 | } | 
                          |  | 86 | return numTriples; | 
                          |  | 87 | } | 
                          |  | 88 |  | 
                          |  | 89 |  | 
                          |  | 90 | public static long getProperties(Resource defaultDataset) throws Exception{ | 
                          |  | 91 | Model model = defaultDataset.getModel(); | 
                          |  | 92 | Property void_properties = model.getProperty(URICollection.PROPERTY_VOID_PROPERTIES); | 
                          |  | 93 | NodeIterator nit = model.listObjectsOfProperty(defaultDataset, void_properties); | 
                          |  | 94 | long numProperties = 0; | 
                          |  | 95 | if( nit.hasNext()){ | 
                          |  | 96 | Literal numPropertiesLit = nit.next().asLiteral(); | 
                          |  | 97 | numProperties = numPropertiesLit.getLong(); | 
                          |  | 98 | } | 
                          |  | 99 | return numProperties; | 
                          |  | 100 | } | 
                          |  | 101 |  | 
                          |  | 102 |  | 
                          |  | 103 | public static long getClasses(Resource defaultDataset) throws Exception{ | 
                          |  | 104 | Model model = defaultDataset.getModel(); | 
                          |  | 105 | Property void_classes = model.getProperty(URICollection.PROPERTY_VOID_CLASSES); | 
                          |  | 106 | NodeIterator nit = model.listObjectsOfProperty(defaultDataset, void_classes); | 
                          |  | 107 | long numClasses = 0; | 
                          |  | 108 | if( nit.hasNext()){ | 
                          |  | 109 | Literal numClassesLit = nit.next().asLiteral(); | 
                          |  | 110 | numClasses = numClassesLit.getLong(); | 
                          |  | 111 | } | 
                          |  | 112 | return numClasses; | 
                          |  | 113 | } | 
                          |  | 114 |  | 
                          |  | 115 |  | 
                          |  | 116 | public static long getDatatypes(Resource defaultDataset) throws Exception{ | 
                          |  | 117 | Model model = defaultDataset.getModel(); | 
                          |  | 118 | Property sbm_datatypes = model.getProperty(URICollection.PROPERTY_SB_DATATYPES); | 
                          |  | 119 | NodeIterator nit = model.listObjectsOfProperty(defaultDataset, sbm_datatypes); | 
                          |  | 120 | long numDatatypes = 0; | 
                          |  | 121 | if( nit.hasNext()){ | 
                          |  | 122 | Literal numDatatypesLit = nit.next().asLiteral(); | 
                          |  | 123 | numDatatypes = numDatatypesLit.getLong(); | 
                          |  | 124 | } | 
                          |  | 125 | return numDatatypes; | 
                          |  | 126 | } | 
                          |  | 127 |  | 
                          |  | 128 |  | 
                          |  | 129 | public static long getEndpointCategory(Resource defaultDataset) throws Exception{ | 
                          |  | 130 | Model model = defaultDataset.getModel(); | 
                          |  | 131 | Property sbm_endpointCategory = model.getProperty(URICollection.PROPERTY_SB_ENDPOINT_CATEGORY); | 
                          |  | 132 | NodeIterator nit = model.listObjectsOfProperty(defaultDataset, sbm_endpointCategory); | 
                          |  | 133 | long endpointCategory = 0; | 
                          |  | 134 | if( nit.hasNext()){ | 
                          |  | 135 | Literal endpointCategoryLit = nit.next().asLiteral(); | 
                          |  | 136 | endpointCategory = endpointCategoryLit.getLong(); | 
                          |  | 137 | } | 
                          |  | 138 | return endpointCategory; | 
                          |  | 139 | } | 
                          |  | 140 |  | 
                          |  | 141 | public static long getPropertyategory(Resource defaultDataset) throws Exception{ | 
                          |  | 142 | Model model = defaultDataset.getModel(); | 
                          |  | 143 | Property sbm_propertyCategory = model.getProperty(URICollection.PROPERTY_SB_PROPERTY_CATEGORY); | 
                          |  | 144 | NodeIterator nit = model.listObjectsOfProperty(defaultDataset, sbm_propertyCategory); | 
                          |  | 145 | long propertyCategory = 0; | 
                          |  | 146 | if( nit.hasNext()){ | 
                          |  | 147 | Literal propertyCategoryLit = nit.next().asLiteral(); | 
                          |  | 148 | propertyCategory = propertyCategoryLit.getLong(); | 
                          |  | 149 | } | 
                          |  | 150 | return propertyCategory; | 
                          |  | 151 | } | 
                          |  | 152 |  | 
                          |  | 153 |  | 
                          |  | 154 | public static long getClassCategory(Resource defaultDataset) throws Exception{ | 
                          |  | 155 | Model model = defaultDataset.getModel(); | 
                          |  | 156 | Property sbm_classCategory = model.getProperty(URICollection.PROPERTY_SB_CLASS_CATEGORY); | 
                          |  | 157 | NodeIterator nit = model.listObjectsOfProperty(defaultDataset, sbm_classCategory); | 
                          |  | 158 | long classCategory = 0; | 
                          |  | 159 | if( nit.hasNext()){ | 
                          |  | 160 | Literal classCategoryLit = nit.next().asLiteral(); | 
                          |  | 161 | classCategory = classCategoryLit.getLong(); | 
                          |  | 162 | } | 
                          |  | 163 | return classCategory; | 
                          |  | 164 | } | 
                          |  | 165 |  | 
                          |  | 166 |  | 
                          |  | 167 | public static Resource[] getPropertyPartitions(Resource defaultDataset) throws Exception{ | 
                          |  | 168 | Model model = defaultDataset.getModel(); | 
                          |  | 169 | Property void_propertyPartition = model.getProperty(URICollection.PROPERTY_VOID_PROPERTY_PARTITION); | 
                          |  | 170 | NodeIterator nit = model.listObjectsOfProperty(defaultDataset, void_propertyPartition); | 
                          |  | 171 | ArrayList<Resource> propertyPartitions = new ArrayList<Resource>(); | 
                          |  | 172 | if( nit.hasNext()){ | 
                          |  | 173 | Resource propertyPartition = nit.next().asResource(); | 
                          |  | 174 | propertyPartitions.add(propertyPartition); | 
                          |  | 175 | } | 
                          |  | 176 | return propertyPartitions.toArray(new Resource[0]); | 
                          |  | 177 | } | 
                          |  | 178 |  | 
                          |  | 179 | public static Resource[] getClassPartitions(Resource defaultDataset) throws Exception{ | 
                          |  | 180 | Model model = defaultDataset.getModel(); | 
                          |  | 181 | Property void_classPartition = model.getProperty(URICollection.PROPERTY_VOID_CLASS_PARTITION); | 
                          |  | 182 | NodeIterator nit = model.listObjectsOfProperty(defaultDataset, void_classPartition); | 
                          |  | 183 | ArrayList<Resource> classPartitions = new ArrayList<Resource>(); | 
                          |  | 184 | if( nit.hasNext()){ | 
                          |  | 185 | Resource classPartition = nit.next().asResource(); | 
                          |  | 186 | classPartitions.add(classPartition); | 
                          |  | 187 | } | 
                          |  | 188 | return classPartitions.toArray(new Resource[0]); | 
                          |  | 189 | } | 
                          |  | 190 |  | 
                          |  | 191 | public static Resource[] getNamedGraphs(Resource defaultDataset) throws Exception{ | 
                          |  | 192 | Model model = defaultDataset.getModel(); | 
                          |  | 193 | Property sd_namedGraph = model.getProperty(URICollection.PROPERTY_SD_NAMED_GRAPH); | 
                          |  | 194 | NodeIterator nit = model.listObjectsOfProperty(defaultDataset, sd_namedGraph); | 
                          |  | 195 | ArrayList<Resource> namedGraphs = new ArrayList<Resource>(); | 
                          |  | 196 | if( nit.hasNext()){ | 
                          |  | 197 | Resource namedGraph = nit.next().asResource(); | 
                          |  | 198 | namedGraphs.add(namedGraph); | 
                          |  | 199 | } | 
                          |  | 200 | return namedGraphs.toArray(new Resource[0]); | 
                          |  | 201 | } | 
                          |  | 202 |  | 
                          |  | 203 | public static String getName(Resource namedGraph) throws Exception{ | 
                          |  | 204 | Model model = namedGraph.getModel(); | 
                          |  | 205 | Property sd_name = model.getProperty(URICollection.PROPERTY_SD_NAME); | 
                          |  | 206 | NodeIterator nit = model.listObjectsOfProperty(namedGraph, sd_name); | 
                          |  | 207 | String name = null; | 
                          |  | 208 | if( nit.hasNext()){ | 
                          |  | 209 | Literal nameLit = nit.next().asLiteral(); | 
                          |  | 210 | name = nameLit.getString(); | 
                          |  | 211 | } | 
                          |  | 212 | return name; | 
                          |  | 213 | } | 
                          |  | 214 |  | 
                          |  | 215 | public static Resource[] getPropertyCategorySubsets(Resource defaultDataset) throws Exception{ | 
                          |  | 216 | Model model = defaultDataset.getModel(); | 
                          |  | 217 | Property void_propertyCategorySubset = model.getProperty(URICollection.PROPERTY_SB_PROPERTY_CATEGORY_SUBSET); | 
                          |  | 218 | NodeIterator nit = model.listObjectsOfProperty(defaultDataset, void_propertyCategorySubset); | 
                          |  | 219 | ArrayList<Resource> propertyCategorySubsets = new ArrayList<Resource>(); | 
                          |  | 220 | if( nit.hasNext()){ | 
                          |  | 221 | Resource propertyCategorySubset = nit.next().asResource(); | 
                          |  | 222 | propertyCategorySubsets.add(propertyCategorySubset); | 
                          |  | 223 | } | 
                          |  | 224 | return propertyCategorySubsets.toArray(new Resource[0]); | 
                          |  | 225 | } | 
                          |  | 226 |  | 
                          |  | 227 | public static Property[] getProperties(Model model) throws Exception{ | 
                          |  | 228 | Resource rdf_property = model.getResource(URICollection.CLASS_RDF_PROPERTY); | 
                          |  | 229 | Property rdf_type = model.getProperty(URICollection.PROPERTY_RDF_TYPE); | 
                          |  | 230 | ResIterator rit = model.listSubjectsWithProperty(rdf_type, rdf_property); | 
                          |  | 231 | ArrayList<Resource> properties = new ArrayList<Resource>(); | 
                          |  | 232 | if( rit.hasNext()){ | 
                          |  | 233 | String propertyURI  = rit.next().getURI(); | 
                          |  | 234 | Property property = model.getProperty(propertyURI); | 
                          |  | 235 | properties.add(property); | 
                          |  | 236 | } | 
                          |  | 237 | return properties.toArray(new Property[0]); | 
                          |  | 238 | } | 
                          |  | 239 |  | 
                          |  | 240 |  | 
                          |  | 241 | public static Resource[] getClasses(Model model) throws Exception{ | 
                          |  | 242 | Resource rdfs_class = model.getResource(URICollection.RESOURCE_RDFS_CLASS); | 
                          |  | 243 | Property rdf_type = model.getProperty(URICollection.PROPERTY_RDF_TYPE); | 
                          |  | 244 | ResIterator rit = model.listSubjectsWithProperty(rdf_type, rdfs_class); | 
                          |  | 245 | ArrayList<Resource> classes = new ArrayList<Resource>(); | 
                          |  | 246 | if( rit.hasNext()){ | 
                          |  | 247 | Resource classRes  = rit.next(); | 
                          |  | 248 | classes.add(classRes); | 
                          |  | 249 | } | 
                          |  | 250 | return classes.toArray(new Resource[0]); | 
                          |  | 251 | } | 
                          |  | 252 |  | 
                          |  | 253 | public static Resource[] getClassRelations(Resource propertyPartition) throws Exception{ | 
                          |  | 254 | //TODO | 
                          |  | 255 | return null; | 
                          |  | 256 | } | 
                          |  | 257 |  | 
                          |  | 258 | public static String getEndpointURI(Model model) throws Exception{ | 
                          |  | 259 | Property sd_endpoint = model.getProperty(URICollection.PROPERTY_SD_ENDPOINT); | 
                          |  | 260 | NodeIterator nit = model.listObjectsOfProperty(sd_endpoint); | 
                          |  | 261 | Resource endPointRes = null; | 
                          |  | 262 | String endpointURI = null; | 
                          |  | 263 | if( nit.hasNext() ){ | 
                          |  | 264 | RDFNode endPointNode = nit.next(); | 
                          |  | 265 | endPointRes = endPointNode.asResource(); | 
                          |  | 266 | endpointURI = endPointRes.getURI(); | 
                          |  | 267 | } | 
                          |  | 268 | return endpointURI; | 
                          |  | 269 | } | 
                          |  | 270 |  | 
                          |  | 271 |  | 
                          |  | 272 | private Resource getCrawlLogBlankNode(Resource defaultDataset) throws Exception { | 
                          |  | 273 | Model model = defaultDataset.getModel(); | 
                          |  | 274 | // log | 
                          |  | 275 | Property sbm_crawlLog = model.getProperty(URICollection.PROPERTY_SB_CRAWL_LOG); | 
                          |  | 276 | NodeIterator nit = model.listObjectsOfProperty(sbm_crawlLog); | 
                          |  | 277 | Resource crawlLogBlankNode = null; | 
                          |  | 278 | if( nit.hasNext() ){ | 
                          |  | 279 | RDFNode node = nit.next(); | 
                          |  | 280 | crawlLogBlankNode = node.asResource(); | 
                          |  | 281 | } | 
                          |  | 282 | return crawlLogBlankNode; | 
                          |  | 283 | } | 
                          |  | 284 |  | 
                          |  | 285 | private Calendar getStartTime(Resource crawlLogBlankNode) throws Exception{ | 
                          |  | 286 | Model model = crawlLogBlankNode.getModel(); | 
                          |  | 287 | Property sbm_startTime = model.getProperty(URICollection.PROPERTY_SB_CRAWL_START_TIME); | 
                          |  | 288 | NodeIterator nit = model.listObjectsOfProperty(sbm_startTime); | 
                          |  | 289 | Calendar startCal = null; | 
                          |  | 290 | if( nit.hasNext() ){ | 
                          |  | 291 | Literal startTimeLit = null; | 
                          |  | 292 | RDFNode node = nit.next(); | 
                          |  | 293 | startTimeLit = node.asLiteral(); | 
                          |  | 294 | startCal = ((com.hp.hpl.jena.datatypes.xsd.XSDDateTime)(startTimeLit.getValue())).asCalendar(); | 
                          |  | 295 | } | 
                          |  | 296 | return startCal; | 
                          |  | 297 | } | 
                          |  | 298 |  | 
                          |  | 299 | private Calendar getEndTime(Resource crawlLogBlankNode) throws Exception{ | 
                          |  | 300 | Model model = crawlLogBlankNode.getModel(); | 
                          |  | 301 | Property sbm_endTime = model.getProperty(URICollection.PROPERTY_SB_CRAWL_END_TIME); | 
                          |  | 302 | NodeIterator nit = model.listObjectsOfProperty(sbm_endTime); | 
                          |  | 303 | Calendar endCal = null; | 
                          |  | 304 | if( nit.hasNext() ){ | 
                          |  | 305 | Literal endTimeLit = null; | 
                          |  | 306 | RDFNode node = nit.next(); | 
                          |  | 307 | endTimeLit = node.asLiteral(); | 
                          |  | 308 | endCal = ((com.hp.hpl.jena.datatypes.xsd.XSDDateTime)(endTimeLit.getValue())).asCalendar(); | 
                          |  | 309 | } | 
                          |  | 310 | return endCal; | 
                          |  | 311 | } | 
                          |  | 312 |  | 
                          |  | 313 |  | 
                          |  | 314 |  | 
                          |  | 315 |  |