java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java
branchv_0
changeset 215 42880d38ad3e
parent 214 1fb3c7953d8a
child 216 0eb9aec16bf4
equal deleted inserted replaced
214:1fb3c7953d8a 215:42880d38ad3e
   205 
   205 
   206 			ColumnsHeader header = constructHeader(
   206 			ColumnsHeader header = constructHeader(
   207 					new HeaderField("name", SQLType.VARCHAR),
   207 					new HeaderField("name", SQLType.VARCHAR),
   208 					new HeaderField("type", SQLType.VARCHAR),
   208 					new HeaderField("type", SQLType.VARCHAR),
   209 					new HeaderField("default", SQLType.VARCHAR),
   209 					new HeaderField("default", SQLType.VARCHAR),
   210 					new HeaderField("description", SQLType.VARCHAR)
   210 					new HeaderField("description", SQLType.VARCHAR),
       
   211 					new HeaderField("declared_in", SQLType.VARCHAR)
   211 			);
   212 			);
   212 
   213 
   213 			Map<String, Object[]> data = new HashMap<>();
   214 			Map<String, Object[]> data = new HashMap<>();
   214 			Class<Formatter> formatterClass = (Class<Formatter>) Class.forName(fd.getClassName());
   215 			Class<Formatter> formatterClass = (Class<Formatter>) Class.forName(fd.getClassName());
   215 			List<Class<? extends Formatter>> hierarchy = Functions.getClassHierarchy(formatterClass, Formatter.class);
   216 			List<Class<? extends Formatter>> hierarchy = Functions.getClassHierarchy(formatterClass, Formatter.class);
   216 			Collections.reverse(hierarchy);
   217 			Collections.reverse(hierarchy);
   217 			hierarchy.stream().forEach((c) -> {
   218 			hierarchy.stream().forEach((c) -> {
   218 				for (PropertyDeclaration p : getPropertyDeclarations(c)) {
   219 				for (PropertyDeclaration p : getPropertyDeclarations(c)) {
   219 					data.put(p.name(), propertyDeclarationToRow(p));
   220 					data.put(p.name(), propertyDeclarationToRow(p, c));
   220 				}
   221 				}
   221 			});
   222 			});
   222 
   223 
   223 			List<Parameter> parameters = new ArrayList<>();
   224 			List<Parameter> parameters = new ArrayList<>();
   224 			parameters.add(new NamedParameter("formatter", formatterName, SQLType.VARCHAR));
   225 			parameters.add(new NamedParameter("formatter", formatterName, SQLType.VARCHAR));
   227 		} catch (ClassNotFoundException e) {
   228 		} catch (ClassNotFoundException e) {
   228 			throw new ConfigurationException("Unable to find class " + fd.getClassName() + " of formatter" + fd.getName(), e);
   229 			throw new ConfigurationException("Unable to find class " + fd.getClassName() + " of formatter" + fd.getName(), e);
   229 		}
   230 		}
   230 	}
   231 	}
   231 
   232 
   232 	private static Object[] propertyDeclarationToRow(PropertyDeclaration p) {
   233 	private static Object[] propertyDeclarationToRow(PropertyDeclaration p, Class formatterClass) {
   233 		return new Object[]{
   234 		return new Object[]{
   234 			p.name(),
   235 			p.name(),
   235 			CommonProperties.getSimpleTypeName(p.type()),
   236 			CommonProperties.getSimpleTypeName(p.type()),
   236 			p.defaultValue(),
   237 			p.defaultValue(),
   237 			p.description()
   238 			p.description(),
       
   239 			formatterClass.getName()
   238 		};
   240 		};
   239 	}
   241 	}
   240 
   242 
   241 	private void listTypes() throws FormatterException, ConfigurationException {
   243 	private void listTypes() throws FormatterException, ConfigurationException {
   242 		ColumnsHeader header = constructHeader(new HeaderField("name", SQLType.VARCHAR), new HeaderField("code", SQLType.INTEGER));
   244 		ColumnsHeader header = constructHeader(new HeaderField("name", SQLType.VARCHAR), new HeaderField("code", SQLType.INTEGER));