private double checkFloat(ObjectNode node, String key) throws QueryException { if (!node.has(key)) { throw new QueryException("\"" + key + "\" not found on \"inBoundingBox\""); } JsonNode jsonNode = node.get(key); if (jsonNode.isNumber()) { return jsonNode.asDouble(); } else { throw new QueryException("\"" + key + "\" should be of type number"); } }
resource = getClass().getClassLoader().loadClass("org.bimserver.database.queries.StartFrame").getResource("json/" + namespaceString + ".json"); if (resource == null) { throw new QueryException("Could not find '" + namespaceString + "' namespace in predefined queries"); throw new QueryException("Could not find '" + namespaceString + "' namespace in predefined queries"); throw new QueryException("Could not find '" + singleIncludeName + "' in defines in namespace " + query.getName()); throw new QueryException(e); } catch (JsonMappingException e) { throw new QueryException(e); } catch (IOException e) { throw new QueryException(e);
EClass eClass = packageMetaData.getEClassIncludingDependencies(typeNode.asText()); if (eClass == null) { throw new QueryException("Type " + typeNode.asText() + " not found"); throw new QueryException(identifier + " object must have a \"name\" property"); if (typeNode.has("exclude")) { if (!typeNode.get("exclude").isArray()) { throw new QueryException("\"exclude\" must be an array"); String fieldName = fieldNames.next(); if (!fieldName.equals("name") && !fieldName.equals("includeAllSubTypes") && !fieldName.equals("exclude")) { throw new QueryException(identifier + " object cannot contain \"" + fieldName + "\" field"); throw new QueryException(identifier + " field must be of type string or of type object, is " + typeNode.toString());
private void addType(ObjectNode objectNode, CanInclude queryPart, String type, boolean includeAllSubTypes, List<String> excluded) throws QueryException { if (type.equals("Object")) { // no type filter return; } EClass eClass = packageMetaData.getEClassIncludingDependencies(type); if (eClass == null) { throw new QueryException("Type \"" + type + "\" not found"); } Set<EClass> excludedEClasses = null; if (excluded != null) { excludedEClasses = new HashSet<>(); for (String excl : excluded) { excludedEClasses.add(packageMetaData.getEClassIncludingDependencies(excl)); } } queryPart.addType(eClass, includeAllSubTypes, excludedEClasses); }
private void processSubInclude(Query query, CanInclude parentInclude, JsonNode includeNode) throws QueryException { if (includeNode instanceof ObjectNode) { ObjectNode innerInclude = (ObjectNode)includeNode; parentInclude.addInclude(parseInclude(query, innerInclude, null, parentInclude)); } else if (includeNode.isTextual()) { String includeName = includeNode.asText(); if (includeName.contains(":")) { parentInclude.addIncludeReference(getDefineFromFile(includeName, true), includeName); } else { Include otherInclude = query.getDefine(includeName); if (otherInclude == null) { throw new QueryException("Cannot find define \"" + includeName + "\""); } parentInclude.addIncludeReference(otherInclude, includeName); } } else { throw new QueryException("\"include\" must be of type object or string"); } }
public static QueryObjectProvider fromJsonNode(DatabaseSession databaseSession, BimServer bimServer, JsonNode fullQuery, Set<Long> roids, PackageMetaData packageMetaData) throws JsonParseException, JsonMappingException, IOException, QueryException { if (fullQuery instanceof ObjectNode) { JsonQueryObjectModelConverter converter = new JsonQueryObjectModelConverter(packageMetaData); Query query = converter.parseJson("query", (ObjectNode) fullQuery); return new QueryObjectProvider(databaseSession, bimServer, query, roids, packageMetaData); } else { throw new QueryException("Query root must be of type object"); } }
private void parseDefines(Query query, ObjectNode jsonNode) throws QueryException { Iterator<String> fieldNames = jsonNode.fieldNames(); // First pass, get all the name and create stub includes, using two passing to allow the usage of includes defined later in the structure while (fieldNames.hasNext()) { String fieldName = fieldNames.next(); JsonNode defineNode = jsonNode.get(fieldName); if (defineNode instanceof ObjectNode) { Include include = new Include(packageMetaData); query.addDefine(fieldName, include); } else { throw new QueryException("\"defines\"[" + fieldName + "] must be of type object"); } } // Second pass, actually construct the includes fieldNames = jsonNode.fieldNames(); while (fieldNames.hasNext()) { String fieldName = fieldNames.next(); JsonNode defineNode = jsonNode.get(fieldName); ObjectNode define = (ObjectNode)defineNode; parseInclude(query, define, query.getDefine(fieldName), null); } }
throw new QueryException("property \"" + propertyEntry.getKey() + "\" type not supported"); throw new QueryException("Query language has changed, propertyset name required now");
public void addFieldDirect(String fieldName) throws QueryException { EReference feature = null; for (TypeDef typeDef : types) { if (typeDef.geteClass().getEStructuralFeature(fieldName) == null) { throw new QueryException("Class \"" + typeDef.geteClass().getName() + "\" does not have the field \"" + fieldName + "\""); } if (feature == null) { if (!(typeDef.geteClass().getEStructuralFeature(fieldName) instanceof EReference)) { throw new QueryException(fieldName + " is not a reference"); } feature = (EReference) typeDef.geteClass().getEStructuralFeature(fieldName); } else { if (feature != typeDef.geteClass().getEStructuralFeature(fieldName)) { throw new QueryException("Classes \"" + typeDef.geteClass().getName() + "\" and \"" + feature.getEContainingClass().getName() + "\" have fields with the same name, but they are not logically the same"); } } } if (fieldsDirect == null) { fieldsDirect = new ArrayList<>(); } fieldsDirect.add(feature); }
/** * Add the fields _after_ adding the types, because the fields will be checked against the types, all types should have the given field. * * @param fieldName * @throws QueryException */ public void addField(String fieldName) throws QueryException { EReference feature = null; for (TypeDef typeDef : types) { if (typeDef.geteClass().getEStructuralFeature(fieldName) == null) { throw new QueryException("Class \"" + typeDef.geteClass().getName() + "\" does not have the field \"" + fieldName + "\""); } if (feature == null) { if (!(typeDef.geteClass().getEStructuralFeature(fieldName) instanceof EReference)) { throw new QueryException(fieldName + " is not a reference"); } feature = (EReference) typeDef.geteClass().getEStructuralFeature(fieldName); } else { if (feature != typeDef.geteClass().getEStructuralFeature(fieldName)) { throw new QueryException("Classes \"" + typeDef.geteClass().getName() + "\" and \"" + feature.getEContainingClass().getName() + "\" have fields with the same name, but they are not logically the same"); } } } if (fields == null) { fields = new ArrayList<>(); } fields.add(feature); }
throw new QueryException("includes require a \"type\" or \"types\" field " + jsonNode); ArrayNode types = (ArrayNode)typesNode; if (types.size() == 0) { throw new QueryException("\"types\" must have a least one element"); throw new QueryException("\"types\" must be of type array"); include.addOutputType(eClass); } else { throw new QueryException("\"outputType\" field mst be of type string"); ArrayNode types = (ArrayNode)typesNode; if (types.size() == 0) { throw new QueryException("\"outputTypes\" must have a least one element"); include.addOutputType(eClass); } else { throw new QueryException("\"outputTypes\"[" + i + "] field mst be of type string"); throw new QueryException("\"outputTypes\" must be of type array"); include.addField(fieldNode.asText()); } else { throw new QueryException("\"field\" must be of type string"); include.addField(fieldNode.asText()); } else { throw new QueryException("\"fields\"[" + i + "] must be of type string");
throw new QueryException("Only version " + LATEST_VERSION + " supported by this version of BIMserver"); parseDefines(query, (ObjectNode)fullQuery.get("defines")); } else { throw new QueryException("\"defines\" must be of type object"); throw new QueryException("\"queries\" must be of type array"); parseJsonQuery(query, (ObjectNode) fullQuery.get("query")); } else { throw new QueryException("\"query\" must be of type object");
throw new QueryException("\"types\" must be of type array"); queryPart.addOid(oidNode.asLong()); } else { throw new QueryException("\"oid\" must be of type number"); queryPart.addOid(oidNode.asLong()); } else { throw new QueryException("\"oids\"[" + i + "] must be of type number (" + oidNode + ")"); throw new QueryException("\"oids\" must be of type array"); queryPart.addGuid(guidNode.asText()); } else { throw new QueryException("\"guid\" must be of type string"); queryPart.addName(nameNode.asText()); } else { throw new QueryException("\"name\" must be of type string"); queryPart.addGuid(guidNode.asText()); } else { throw new QueryException("\"guids\"[" + i + "] must be of type string"); throw new QueryException("\"guids\" must be of type array"); queryPart.addName(nameNode.asText()); } else { throw new QueryException("\"names\"[" + i + "] must be of type string");
this.oids = new HashMap<EClass, List<Long>>(); if (oidsList.size() == 0) { throw new QueryException("\"oids\" parameter of type array is of size 0");
public StartFrame(QueryObjectProvider queryObjectProvider, Set<Long> roids) throws QueryException { this.queryObjectProvider = queryObjectProvider; if (roids.size() == 0) { throw new QueryException("At least one roid required");