/** * Release geometry type * * @param connection Active h2 connection with DROP DOMAIN and DROP ALIAS rights */ public static void unRegisterGeometryType(Connection connection) throws SQLException { Statement st = connection.createStatement(); DomainInfo[] domainInfos = getBuiltInsType(); for (DomainInfo domainInfo : domainInfos) { st.execute("DROP DOMAIN IF EXISTS " + domainInfo.getDomainName()); } }
public DomainInfo unmarshall(JsonUnmarshallerContext context) throws Exception { DomainInfo domainInfo = new DomainInfo(); int originalDepth = context.getCurrentDepth(); String currentParentElement = context.getCurrentParentElement(); int targetDepth = originalDepth + 1; JsonToken token = context.getCurrentToken(); if (token == null) token = context.nextToken(); if (token == VALUE_NULL) return null; while (true) { if (token == null) break; if (token == FIELD_NAME || token == START_OBJECT) { if (context.testExpression("DomainName", targetDepth)) { context.nextToken(); domainInfo.setDomainName(StringJsonUnmarshaller.getInstance().unmarshall(context)); } } else if (token == END_ARRAY || token == END_OBJECT) { if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) { if (context.getCurrentDepth() <= originalDepth) break; } } token = context.nextToken(); } return domainInfo; }
public DomainInfo merger(DomainInfo info) { m_machine = info.getMachine(); m_loadSum += info.getLoadSum(); m_days++; if (info.getMaxLoad() > m_maxLoad) { m_maxLoad = info.getMaxLoad(); } m_maxLoadSum += info.getMaxLoadSum(); return this; }
@Override public String toString() { StringBuilder sb = new StringBuilder(); DomainInfo info = new DomainInfo(); for (DomainInfo temp : m_infos.values()) { info.merger(temp); } sb.append(info); return sb.toString(); }
/** * Register geometry type in an OSGi environment * * @param connection Active H2 connection * @throws SQLException */ public static void registerGeometryType(Connection connection) throws SQLException { Statement st = connection.createStatement(); for (DomainInfo domainInfo : getBuiltInsType()) { // Check for byte array first, to not throw an enigmatic error CastException st.execute( "CREATE DOMAIN IF NOT EXISTS " + domainInfo.getDomainName() + " AS " + GEOMETRY_BASE_TYPE + " CHECK (ST_GeometryTypeCode(VALUE) = " + domainInfo.getGeometryTypeCode() + ");"); } }
/** Marshall the given parameter object, and output to a SdkJsonGenerator */ public void marshall(DomainInfo domainInfo, StructuredJsonGenerator jsonGenerator) { if (domainInfo == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } try { jsonGenerator.writeStartObject(); if (domainInfo.getDomainName() != null) { jsonGenerator.writeFieldName("DomainName").writeValue(domainInfo.getDomainName()); } jsonGenerator.writeEndObject(); } catch (Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } }
private void processOneDay(Date date, List<String> domains) { for (String domain : domains) { try { Dailyreport report = m_dailyreportDao.findByNameDomainPeriod( date, domain, "health", DailyreportEntity.READSET_FULL); HealthReport healthReport = DefaultSaxParser.parse(report.getContent()); MachineInfo machine = healthReport.getMachineInfo(); MonthDomain indicator = m_indicators.get(domain); if (indicator == null) { indicator = new MonthDomain(); m_indicators.put(domain, indicator); } DomainInfo t = indicator.findOrCreatDomain(date); t.add(machine.getNumbers(), machine.getAvgMaxLoad(), machine.getAvgLoad()); } catch (DalNotFoundException e) { } catch (Exception e) { e.printStackTrace(); } } }