public String buildInterfaceTable(String rule, String[] serviceList) throws FilterParseException {
    StringBuffer buffer = new StringBuffer();
    Filter filter = new Filter();
    Map interfaces = filter.getIPServiceMap(rule);

    Iterator i = interfaces.keySet().iterator();
    while (i.hasNext()) {
      String key = (String) i.next();
      buffer.append("<tr><td valign=\"top\">").append(key).append("</td>");
      buffer.append("<td>");

      if (serviceList != null && serviceList.length != 0) {
        Map services = (Map) interfaces.get(key);
        Iterator j = services.keySet().iterator();
        while (j.hasNext()) {
          String svc = (String) j.next();
          for (int idx = 0; idx < serviceList.length; idx++) {
            if (svc.equals(serviceList[idx])) {
              buffer.append(svc).append("<br>");
            }
          }
        }
      } else {
        buffer.append("All services");
      }
      buffer.append("</td>");

      buffer.append("</tr>");
    }

    return buffer.toString();
  }
示例#2
1
  @Override
  public Map<String, Object> saveMap(Map<String, Object> object, Class clazz) throws Exception {

    StringBuilder sql = new StringBuilder();
    EntityInfo entityInfo = ClassUtils.getEntityInfoByClazz(clazz);

    sql.append("INSERT INTO ");
    sql.append(entityInfo.getTableName());
    sql.append("(");

    List<String> columns = new ArrayList<String>();
    List<Object> values = new ArrayList<Object>();
    Map<String, String> ptcMap = ClassUtils.propToColumnMap.get(entityInfo.getClazzName());
    for (Map.Entry<String, Object> entry : object.entrySet()) {
      columns.add(ptcMap.get(entry.getKey()));
      values.add(entry.getValue());
    }
    sql.append(StringUtils.join(columns, ","));
    sql.append(") VALUES(");
    String[] params = new String[values.size()];
    Arrays.fill(params, "?");
    sql.append(StringUtils.join(params, ","));
    sql.append(")");
    if (entityInfo.getStrategy().equals(GenerationType.IDENTITY)) {
      Long id = addReutrnId(sql.toString(), values);
      if (id != null) {
        object.put(entityInfo.getPkName(), id);
      }
    } else {
      add(sql.toString(), values);
    }
    return object;
  }
示例#3
0
  @Override
  public void init(Context context, Properties initProps) {
    initProps = decryptPwd(initProps);
    Object o = initProps.get(CONVERT_TYPE);
    if (o != null) convertType = Boolean.parseBoolean(o.toString());

    factory = createConnectionFactory(context, initProps);

    String bsz = initProps.getProperty("batchSize");
    if (bsz != null) {
      bsz = context.replaceTokens(bsz);
      try {
        batchSize = Integer.parseInt(bsz);
        if (batchSize == -1) batchSize = Integer.MIN_VALUE;
      } catch (NumberFormatException e) {
        LOG.warn("Invalid batch size: " + bsz);
      }
    }

    for (Map<String, String> map : context.getAllEntityFields()) {
      String n = map.get(DataImporter.COLUMN);
      String t = map.get(DataImporter.TYPE);
      if ("sint".equals(t) || "integer".equals(t)) fieldNameVsType.put(n, Types.INTEGER);
      else if ("slong".equals(t) || "long".equals(t)) fieldNameVsType.put(n, Types.BIGINT);
      else if ("float".equals(t) || "sfloat".equals(t)) fieldNameVsType.put(n, Types.FLOAT);
      else if ("double".equals(t) || "sdouble".equals(t)) fieldNameVsType.put(n, Types.DOUBLE);
      else if ("date".equals(t)) fieldNameVsType.put(n, Types.DATE);
      else if ("boolean".equals(t)) fieldNameVsType.put(n, Types.BOOLEAN);
      else if ("binary".equals(t)) fieldNameVsType.put(n, Types.BLOB);
      else fieldNameVsType.put(n, Types.VARCHAR);
    }
  }
  private Counter getCounterFromVerificationData(Map<String, String> verificationData) {

    String sizeAndSymbol = verificationData.get(Constants.COUNTER_SIZE_AND_SYMBOL);
    String[] parts = sizeAndSymbol.split(" ");
    if (parts.length < Constants.MIN_LENGTH) {
      throw new NoSuchElementException();
    }
    String standardSize = parts[0] + " " + parts[1];
    String symbol = parts[2];
    if (parts.length > Constants.MIN_LENGTH) {
      for (int i = Constants.MIN_LENGTH; i < parts.length; i++) {
        symbol += " " + parts[i];
      }
    }
    CounterType counterType =
        counterTypeService.findOneBySymbolAndStandardSize(symbol, standardSize);
    if (counterType == null) {
      throw new NoSuchElementException();
    }
    Counter counter =
        new Counter(
            verificationData.get(Constants.YEAR),
            verificationData.get(Constants.COUNTER_NUMBER),
            counterType,
            verificationData.get(Constants.STAMP));

    return counter;
  }
示例#5
0
 @Override
 public String get(Object key) {
   if (JdbcIndexDefinition.this.identifier.equals(key)) return identifier;
   if (keys.containsKey(key)) return keys.get(key);
   check();
   return map.get(key);
 }
  private List getTableColumns(
      Table table, List primaryKeys, List indices, Map uniqueIndices, Map uniqueColumns)
      throws SQLException {
    // get the columns
    List columns = new LinkedList();
    ResultSet columnRs = getColumnsResultSet(table);

    while (columnRs.next()) {
      int sqlType = columnRs.getInt("DATA_TYPE");
      String sqlTypeName = columnRs.getString("TYPE_NAME");
      String columnName = columnRs.getString("COLUMN_NAME");
      String columnDefaultValue = columnRs.getString("COLUMN_DEF");

      String remarks = columnRs.getString("REMARKS");
      if (remarks == null && dbHelper.isOracleDataBase()) {
        remarks = getOracleColumnComments(table.getSqlName(), columnName);
      }

      // if columnNoNulls or columnNullableUnknown assume "not nullable"
      boolean isNullable = (DatabaseMetaData.columnNullable == columnRs.getInt("NULLABLE"));
      int size = columnRs.getInt("COLUMN_SIZE");
      int decimalDigits = columnRs.getInt("DECIMAL_DIGITS");

      boolean isPk = primaryKeys.contains(columnName);
      boolean isIndexed = indices.contains(columnName);
      String uniqueIndex = (String) uniqueIndices.get(columnName);
      List columnsInUniqueIndex = null;
      if (uniqueIndex != null) {
        columnsInUniqueIndex = (List) uniqueColumns.get(uniqueIndex);
      }

      boolean isUnique = columnsInUniqueIndex != null && columnsInUniqueIndex.size() == 1;
      if (isUnique) {
        GLogger.trace("unique column:" + columnName);
      }
      Column column =
          new Column(
              table,
              sqlType,
              sqlTypeName,
              columnName,
              size,
              decimalDigits,
              isPk,
              isNullable,
              isIndexed,
              isUnique,
              columnDefaultValue,
              remarks);
      BeanHelper.copyProperties(
          column, TableOverrideValuesProvider.getColumnOverrideValues(table, column));
      columns.add(column);
    }
    columnRs.close();
    return columns;
  }
示例#7
0
  public void parseInputFile(File inputFile) throws IOException {
    geneFeatures.clear();
    otherRecords.clear();

    try {
      GFFEntrySet gffEntries = GFFTools.readGFF(inputFile);

      Iterator itr = gffEntries.lineIterator();
      int count = 0;
      int intronFeatures = 0;
      LinkedList<GFFRecord> cdsRecs = new LinkedList<GFFRecord>();

      while (itr.hasNext()) {
        Object val = itr.next();
        if (val instanceof GFFRecord) {
          GFFRecord rec = (GFFRecord) val;
          count += 1;

          if (rec.getFeature().endsWith("gene")) {
            GeneFeatures gf = new GeneFeatures(rec);
            geneFeatures.put(gf.id, gf);
          } else if (rec.getFeature().equals("CDS")) {
            cdsRecs.addLast(rec);
          } else {
            otherRecords.add(rec);
          }
        }
      }

      for (GFFRecord rec : cdsRecs) {
        Map<String, List<String>> attrs = decodeAttrMap(rec);
        if (geneFeatures.containsKey(attrs.get("Parent").get(0))) {
          geneFeatures.get(attrs.get("Parent").get(0)).addCDS(rec, attrs);
        } else {
          System.err.println("Unknown CDS Parent: " + attrs.get("Parent").get(0));
        }
      }

      for (String k : geneFeatures.keySet()) {
        GeneFeatures gf = geneFeatures.get(k);
        if (gf.cds != null && gf.cds.size() > 1) {
          intronFeatures++;
        }
      }

      System.err.println("# GFF Records: " + count);
      System.err.println("# Gene Feature Sets: " + geneFeatures.size());
      System.err.println("\t# Intron-Features: " + intronFeatures);

    } catch (ParserException e) {
      e.printStackTrace();
    } catch (BioException e) {
      e.printStackTrace();
    }
  }
 /**
  * Carga datos desde base de datos (mapeo)
  *
  * @param DataSource ds
  * @param Map map
  * @return CategoryRowGateway
  * @throws
  */
 public static CategoryRowGateway load(DataSource ds, Map map) {
   CategoryRowGateway cat = null;
   if (map == null) {
     cat = new CategoryRowGateway();
   } else {
     int idCategory = ((Integer) map.get("id_category")).intValue();
     String name = (String) map.get("category_name");
     cat = new CategoryRowGateway(idCategory, name);
   }
   cat.setDataSource(ds);
   return cat;
 }
示例#9
0
  /**
   * Creates an item object from String parameters.
   *
   * @param conn connection to database
   * @param param map of parameters to set
   * @return an item object
   */
  public static Item createItem(Connection conn, Map<String, String[]> param) throws SQLException {

    Item item = new Item();
    item.setName(param.get("name")[0]);
    item.setPrice(Integer.parseInt(param.get("price")[0]));
    item.setQuantity(Integer.parseInt(param.get("quantity")[0]));
    Clob cl = conn.createClob();
    cl.setString(1, param.get("description")[0]);
    item.setDescription(cl);
    item.setStringDescr(cl);
    return item;
  }
  public ICFBamDataScopeObj realizeDataScope(ICFBamDataScopeObj Obj) {
    ICFBamDataScopeObj obj = Obj;
    CFBamDataScopePKey pkey = obj.getPKey();
    ICFBamDataScopeObj keepObj = null;
    if (members.containsKey(pkey) && (null != members.get(pkey))) {
      ICFBamDataScopeObj existingObj = members.get(pkey);
      keepObj = existingObj;

      /*
       *	We always rebind the data because if we're being called, some index has
       *	been updated and is refreshing it's data, which may or may not have changed
       */

      // Detach object from alternate and duplicate indexes, leave PKey alone

      if (indexByUNameIdx != null) {
        CFBamDataScopeByUNameIdxKey keyUNameIdx =
            ((ICFBamSchema) schema.getBackingStore()).getFactoryDataScope().newUNameIdxKey();
        keyUNameIdx.setRequiredName(keepObj.getRequiredName());
        indexByUNameIdx.remove(keyUNameIdx);
      }

      keepObj.setBuff(Obj.getBuff());
      // Attach new object to alternate and duplicate indexes -- PKey stay stable

      if (indexByUNameIdx != null) {
        CFBamDataScopeByUNameIdxKey keyUNameIdx =
            ((ICFBamSchema) schema.getBackingStore()).getFactoryDataScope().newUNameIdxKey();
        keyUNameIdx.setRequiredName(keepObj.getRequiredName());
        indexByUNameIdx.put(keyUNameIdx, keepObj);
      }
      if (allDataScope != null) {
        allDataScope.put(keepObj.getPKey(), keepObj);
      }
    } else {
      keepObj = obj;
      keepObj.setIsNew(false);
      // Attach new object to PKey, all, alternate, and duplicate indexes
      members.put(keepObj.getPKey(), keepObj);
      if (allDataScope != null) {
        allDataScope.put(keepObj.getPKey(), keepObj);
      }

      if (indexByUNameIdx != null) {
        CFBamDataScopeByUNameIdxKey keyUNameIdx =
            ((ICFBamSchema) schema.getBackingStore()).getFactoryDataScope().newUNameIdxKey();
        keyUNameIdx.setRequiredName(keepObj.getRequiredName());
        indexByUNameIdx.put(keyUNameIdx, keepObj);
      }
    }
    return (keepObj);
  }
 /**
  * Crea un objeto a partir de una fuente de datos
  *
  * @param fuente
  * @param mapa de datos
  * @return Objeto creado
  */
 public static LocationRowGateway load(DataSource ds, Map map) {
   LocationRowGateway loc = null;
   if (map == null) loc = new LocationRowGateway();
   else {
     int locationType = ((Integer) map.get("locationTypeId")).intValue();
     int event = ((Integer) map.get("eventId")).intValue();
     int price = ((Integer) map.get("price")).intValue();
     int quantity = ((Integer) map.get("quantity")).intValue();
     boolean numbered = ((Integer) map.get("numbered")).intValue() == 1;
     loc = new LocationRowGateway(locationType, event, price, quantity, numbered);
   }
   loc.setDataSource(ds);
   return loc;
 }
 public ICFSecuritySecGroupIncludeObj readSecGroupIncludeByUIncludeIdx(
     long ClusterId, int SecGroupId, int IncludeGroupId, boolean forceRead) {
   if (indexByUIncludeIdx == null) {
     indexByUIncludeIdx =
         new HashMap<CFSecuritySecGroupIncludeByUIncludeIdxKey, ICFSecuritySecGroupIncludeObj>();
   }
   CFSecuritySecGroupIncludeByUIncludeIdxKey key =
       ((ICFInternetSchema) schema.getBackingStore())
           .getFactorySecGroupInclude()
           .newUIncludeIdxKey();
   key.setRequiredClusterId(ClusterId);
   key.setRequiredSecGroupId(SecGroupId);
   key.setRequiredIncludeGroupId(IncludeGroupId);
   ICFSecuritySecGroupIncludeObj obj = null;
   if ((!forceRead) && indexByUIncludeIdx.containsKey(key)) {
     obj = indexByUIncludeIdx.get(key);
   } else {
     CFSecuritySecGroupIncludeBuff buff =
         ((ICFInternetSchema) schema.getBackingStore())
             .getTableSecGroupInclude()
             .readDerivedByUIncludeIdx(
                 schema.getAuthorization(), ClusterId, SecGroupId, IncludeGroupId);
     if (buff != null) {
       obj = schema.getSecGroupIncludeTableObj().newInstance();
       obj.setPKey(
           ((ICFInternetSchema) schema.getBackingStore()).getFactorySecGroupInclude().newPKey());
       obj.setBuff(buff);
       obj = (ICFSecuritySecGroupIncludeObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       indexByUIncludeIdx.put(key, null);
     }
   }
   return (obj);
 }
 public ICFSecuritySecGroupIncludeObj readSecGroupInclude(
     CFSecuritySecGroupIncludePKey pkey, boolean forceRead) {
   ICFSecuritySecGroupIncludeObj obj = null;
   if ((!forceRead) && members.containsKey(pkey)) {
     obj = members.get(pkey);
   } else {
     CFSecuritySecGroupIncludeBuff readBuff =
         ((ICFInternetSchema) schema.getBackingStore())
             .getTableSecGroupInclude()
             .readDerivedByIdIdx(
                 schema.getAuthorization(),
                 pkey.getRequiredClusterId(),
                 pkey.getRequiredSecGroupIncludeId());
     if (readBuff != null) {
       obj = schema.getSecGroupIncludeTableObj().newInstance();
       obj.setPKey(
           ((ICFInternetSchema) schema.getBackingStore()).getFactorySecGroupInclude().newPKey());
       obj.setBuff(readBuff);
       obj = (ICFSecuritySecGroupIncludeObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       members.put(pkey, null);
     }
   }
   return (obj);
 }
 public void deleteSecGroupIncludeByUIncludeIdx(
     long ClusterId, int SecGroupId, int IncludeGroupId) {
   if (indexByUIncludeIdx == null) {
     indexByUIncludeIdx =
         new HashMap<CFSecuritySecGroupIncludeByUIncludeIdxKey, ICFSecuritySecGroupIncludeObj>();
   }
   CFSecuritySecGroupIncludeByUIncludeIdxKey key =
       ((ICFInternetSchema) schema.getBackingStore())
           .getFactorySecGroupInclude()
           .newUIncludeIdxKey();
   key.setRequiredClusterId(ClusterId);
   key.setRequiredSecGroupId(SecGroupId);
   key.setRequiredIncludeGroupId(IncludeGroupId);
   ICFSecuritySecGroupIncludeObj obj = null;
   if (indexByUIncludeIdx.containsKey(key)) {
     obj = indexByUIncludeIdx.get(key);
     ((ICFInternetSchema) schema.getBackingStore())
         .getTableSecGroupInclude()
         .deleteSecGroupIncludeByUIncludeIdx(
             schema.getAuthorization(), ClusterId, SecGroupId, IncludeGroupId);
     obj.forget(true);
   } else {
     ((ICFInternetSchema) schema.getBackingStore())
         .getTableSecGroupInclude()
         .deleteSecGroupIncludeByUIncludeIdx(
             schema.getAuthorization(), ClusterId, SecGroupId, IncludeGroupId);
   }
 }
 public ICFSecurityTSecGroupMemberObj readTSecGroupMemberByUUserIdx(
     long TenantId, int TSecGroupId, UUID SecUserId, boolean forceRead) {
   if (indexByUUserIdx == null) {
     indexByUUserIdx =
         new HashMap<CFSecurityTSecGroupMemberByUUserIdxKey, ICFSecurityTSecGroupMemberObj>();
   }
   CFSecurityTSecGroupMemberByUUserIdxKey key =
       ((ICFCrmSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newUUserIdxKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredTSecGroupId(TSecGroupId);
   key.setRequiredSecUserId(SecUserId);
   ICFSecurityTSecGroupMemberObj obj = null;
   if ((!forceRead) && indexByUUserIdx.containsKey(key)) {
     obj = indexByUUserIdx.get(key);
   } else {
     CFSecurityTSecGroupMemberBuff buff =
         ((ICFCrmSchema) schema.getBackingStore())
             .getTableTSecGroupMember()
             .readDerivedByUUserIdx(schema.getAuthorization(), TenantId, TSecGroupId, SecUserId);
     if (buff != null) {
       obj = schema.getTSecGroupMemberTableObj().newInstance();
       obj.setPKey(
           ((ICFCrmSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newPKey());
       obj.setBuff(buff);
       obj = (ICFSecurityTSecGroupMemberObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       indexByUUserIdx.put(key, null);
     }
   }
   return (obj);
 }
 public ICFSecurityServiceTypeObj readServiceTypeByUDescrIdx(
     String Description, boolean forceRead) {
   if (indexByUDescrIdx == null) {
     indexByUDescrIdx =
         new HashMap<CFSecurityServiceTypeByUDescrIdxKey, ICFSecurityServiceTypeObj>();
   }
   CFSecurityServiceTypeByUDescrIdxKey key =
       ((ICFAccSchema) schema.getBackingStore()).getFactoryServiceType().newUDescrIdxKey();
   key.setRequiredDescription(Description);
   ICFSecurityServiceTypeObj obj = null;
   if ((!forceRead) && indexByUDescrIdx.containsKey(key)) {
     obj = indexByUDescrIdx.get(key);
   } else {
     CFSecurityServiceTypeBuff buff =
         ((ICFAccSchema) schema.getBackingStore())
             .getTableServiceType()
             .readDerivedByUDescrIdx(schema.getAuthorization(), Description);
     if (buff != null) {
       obj = schema.getServiceTypeTableObj().newInstance();
       obj.setPKey(((ICFAccSchema) schema.getBackingStore()).getFactoryServiceType().newPKey());
       obj.setBuff(buff);
       obj = (ICFSecurityServiceTypeObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       indexByUDescrIdx.put(key, null);
     }
   }
   return (obj);
 }
  public void forgetTax(ICFAccTaxObj Obj, boolean forgetSubObjects) {
    ICFAccTaxObj obj = Obj;
    CFAccTaxPKey pkey = obj.getPKey();
    if (members.containsKey(pkey)) {
      ICFAccTaxObj keepObj = members.get(pkey);
      // Detach object from alternate, duplicate, all and PKey indexes

      if (indexByTenantIdx != null) {
        CFAccTaxByTenantIdxKey keyTenantIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryTax().newTenantIdxKey();
        keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        Map<CFAccTaxPKey, ICFAccTaxObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx);
        if (mapTenantIdx != null) {
          mapTenantIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByUNameIdx != null) {
        CFAccTaxByUNameIdxKey keyUNameIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryTax().newUNameIdxKey();
        keyUNameIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyUNameIdx.setRequiredName(keepObj.getRequiredName());
        indexByUNameIdx.remove(keyUNameIdx);
      }

      if (allTax != null) {
        allTax.remove(keepObj.getPKey());
      }
      members.remove(pkey);
      if (forgetSubObjects) {}
    }
  }
  public void deleteISOCurrency(CFBamAuthorization Authorization, CFBamISOCurrencyBuff Buff) {
    final String S_ProcName = "CFBamRamISOCurrencyTable.deleteISOCurrency() ";
    CFBamISOCurrencyPKey pkey = schema.getFactoryISOCurrency().newPKey();
    pkey.setRequiredId(Buff.getRequiredId());
    CFBamISOCurrencyBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      return;
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "deleteISOCurrency", pkey);
    }
    CFBamISOCurrencyByCcyCdIdxKey keyCcyCdIdx = schema.getFactoryISOCurrency().newCcyCdIdxKey();
    keyCcyCdIdx.setRequiredISOCode(existing.getRequiredISOCode());

    CFBamISOCurrencyByCcyNmIdxKey keyCcyNmIdx = schema.getFactoryISOCurrency().newCcyNmIdxKey();
    keyCcyNmIdx.setRequiredName(existing.getRequiredName());

    // Validate reverse foreign keys

    // Delete is valid

    schema
        .getTableISOCountryCurrency()
        .deleteISOCountryCurrencyByCurrencyIdx(Authorization, Buff.getRequiredId());
    Map<CFBamISOCurrencyPKey, CFBamISOCurrencyBuff> subdict;

    dictByPKey.remove(pkey);

    dictByCcyCdIdx.remove(keyCcyCdIdx);

    dictByCcyNmIdx.remove(keyCcyNmIdx);
  }
 public ICFSecuritySecAppObj readSecAppByUJEEMountIdx(
     long ClusterId, String JEEMountName, boolean forceRead) {
   if (indexByUJEEMountIdx == null) {
     indexByUJEEMountIdx = new HashMap<CFSecuritySecAppByUJEEMountIdxKey, ICFSecuritySecAppObj>();
   }
   CFSecuritySecAppByUJEEMountIdxKey key =
       ((ICFCrmSchema) schema.getBackingStore()).getFactorySecApp().newUJEEMountIdxKey();
   key.setRequiredClusterId(ClusterId);
   key.setRequiredJEEMountName(JEEMountName);
   ICFSecuritySecAppObj obj = null;
   if ((!forceRead) && indexByUJEEMountIdx.containsKey(key)) {
     obj = indexByUJEEMountIdx.get(key);
   } else {
     CFSecuritySecAppBuff buff =
         ((ICFCrmSchema) schema.getBackingStore())
             .getTableSecApp()
             .readDerivedByUJEEMountIdx(schema.getAuthorization(), ClusterId, JEEMountName);
     if (buff != null) {
       obj = schema.getSecAppTableObj().newInstance();
       obj.setPKey(((ICFCrmSchema) schema.getBackingStore()).getFactorySecApp().newPKey());
       obj.setBuff(buff);
       obj = (ICFSecuritySecAppObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       indexByUJEEMountIdx.put(key, null);
     }
   }
   return (obj);
 }
示例#20
0
  public void init(final Configuration config) throws PwmException {
    final Map<FileValue.FileInformation, FileValue.FileContent> fileValue =
        config.readSettingAsFile(PwmSetting.DATABASE_JDBC_DRIVER);
    final byte[] jdbcDriverBytes;
    if (fileValue != null && !fileValue.isEmpty()) {
      final FileValue.FileInformation fileInformation1 = fileValue.keySet().iterator().next();
      final FileValue.FileContent fileContent = fileValue.get(fileInformation1);
      jdbcDriverBytes = fileContent.getContents();
    } else {
      jdbcDriverBytes = null;
    }

    this.dbConfiguration =
        new DBConfiguration(
            config.readSettingAsString(PwmSetting.DATABASE_CLASS),
            config.readSettingAsString(PwmSetting.DATABASE_URL),
            config.readSettingAsString(PwmSetting.DATABASE_USERNAME),
            config.readSettingAsPassword(PwmSetting.DATABASE_PASSWORD),
            config.readSettingAsString(PwmSetting.DATABASE_COLUMN_TYPE_KEY),
            config.readSettingAsString(PwmSetting.DATABASE_COLUMN_TYPE_VALUE),
            jdbcDriverBytes);

    this.instanceID = pwmApplication == null ? null : pwmApplication.getInstanceID();
    this.traceLogging = config.readSettingAsBoolean(PwmSetting.DATABASE_DEBUG_TRACE);

    if (this.dbConfiguration.isEmpty()) {
      status = PwmService.STATUS.CLOSED;
      LOGGER.debug("skipping database connection open, no connection parameters configured");
    }
  }
示例#21
0
  private synchronized void init() throws SQLException {
    if (isClosed) return;

    // do tables exists?
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery(TABLE_NAMES_SELECT_STMT);

    ArrayList<String> missingTables = new ArrayList(TABLES.keySet());
    while (rs.next()) {
      String tableName = rs.getString("name");
      missingTables.remove(tableName);
    }

    for (String missingTable : missingTables) {
      try {
        Statement createStmt = conn.createStatement();
        // System.out.println("Adding table "+ missingTable);
        createStmt.executeUpdate(TABLES.get(missingTable));
        createStmt.close();

      } catch (Exception e) {
        System.err.println(e.getClass().getName() + ": " + e.getMessage());
      }
    }
  }
示例#22
0
 SqlDialect get(DataSource dataSource) {
   Connection connection = null;
   try {
     connection = dataSource.getConnection();
     DatabaseMetaData metaData = connection.getMetaData();
     String productName = metaData.getDatabaseProductName();
     String productVersion = metaData.getDatabaseProductVersion();
     List key = Arrays.asList(productName, productVersion);
     SqlDialect dialect = map.get(key);
     if (dialect == null) {
       final SqlDialect.DatabaseProduct product =
           SqlDialect.getProduct(productName, productVersion);
       dialect = new SqlDialect(product, productName, metaData.getIdentifierQuoteString());
       map.put(key, dialect);
     }
     connection.close();
     connection = null;
     return dialect;
   } catch (SQLException e) {
     throw new RuntimeException(e);
   } finally {
     if (connection != null) {
       try {
         connection.close();
       } catch (SQLException e) {
         // ignore
       }
     }
   }
 }
  public void forgetSecDevice(ICFSecuritySecDeviceObj Obj, boolean forgetSubObjects) {
    ICFSecuritySecDeviceObj obj = Obj;
    CFSecuritySecDevicePKey pkey = obj.getPKey();
    if (members.containsKey(pkey)) {
      ICFSecuritySecDeviceObj keepObj = members.get(pkey);
      // Detach object from alternate, duplicate, all and PKey indexes

      if (indexByUserIdx != null) {
        CFSecuritySecDeviceByUserIdxKey keyUserIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecDevice().newUserIdxKey();
        keyUserIdx.setRequiredSecUserId(keepObj.getRequiredSecUserId());
        Map<CFSecuritySecDevicePKey, ICFSecuritySecDeviceObj> mapUserIdx =
            indexByUserIdx.get(keyUserIdx);
        if (mapUserIdx != null) {
          mapUserIdx.remove(keepObj.getPKey());
        }
      }

      if (allSecDevice != null) {
        allSecDevice.remove(keepObj.getPKey());
      }
      members.remove(pkey);
      if (forgetSubObjects) {}
    }
  }
  public void forgetServiceType(ICFSecurityServiceTypeObj Obj, boolean forgetSubObjects) {
    ICFSecurityServiceTypeObj obj = Obj;
    CFSecurityServiceTypePKey pkey = obj.getPKey();
    if (members.containsKey(pkey)) {
      ICFSecurityServiceTypeObj keepObj = members.get(pkey);
      // Detach object from alternate, duplicate, all and PKey indexes

      if (indexByUDescrIdx != null) {
        CFSecurityServiceTypeByUDescrIdxKey keyUDescrIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryServiceType().newUDescrIdxKey();
        keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription());
        indexByUDescrIdx.remove(keyUDescrIdx);
      }

      if (allServiceType != null) {
        allServiceType.remove(keepObj.getPKey());
      }
      members.remove(pkey);
      if (forgetSubObjects) {
        ((ICFSecuritySchemaObj) schema)
            .getServiceTableObj()
            .forgetServiceByTypeIdx(keepObj.getRequiredServiceTypeId());
      }
    }
  }
示例#25
0
  public static boolean isZero(List list, String col) {
    if (list == null) {
      return false;
    }
    boolean b = false;
    int i, num = 0;
    String v = null;
    Map m = null;
    double dv = 0;

    num = list.size();
    for (i = 0; i < num; i++) {
      m = (Map) list.get(i);
      v = (String) m.get(col);
      // if(f.empty(v)){return true;}
      if (f.empty(v)) {
        continue;
      }
      // System.out.println(v);
      v = f.v(v);
      dv = f.getDouble(v, 0);
      // if(dv==0){return true;}
      if (dv > 0) {
        return false;
      }
      b = true;
    }

    return b;
  }
 public ICFSecurityISOCountryCurrencyObj readISOCountryCurrency(
     CFSecurityISOCountryCurrencyPKey pkey, boolean forceRead) {
   ICFSecurityISOCountryCurrencyObj obj = null;
   if ((!forceRead) && members.containsKey(pkey)) {
     obj = members.get(pkey);
   } else {
     CFSecurityISOCountryCurrencyBuff readBuff =
         ((ICFInternetSchema) schema.getBackingStore())
             .getTableISOCountryCurrency()
             .readDerivedByIdIdx(
                 schema.getAuthorization(),
                 pkey.getRequiredISOCountryId(),
                 pkey.getRequiredISOCurrencyId());
     if (readBuff != null) {
       obj = schema.getISOCountryCurrencyTableObj().newInstance();
       obj.setPKey(
           ((ICFInternetSchema) schema.getBackingStore())
               .getFactoryISOCountryCurrency()
               .newPKey());
       obj.setBuff(readBuff);
       obj = (ICFSecurityISOCountryCurrencyObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       members.put(pkey, null);
     }
   }
   return (obj);
 }
示例#27
0
  public String getQualifiedColumn(String modelProperty) throws XavaException {
    PropertyMapping propertyMapping = (PropertyMapping) propertyMappings.get(modelProperty);
    if (propertyMapping != null && propertyMapping.hasFormula()) return getColumn(modelProperty);

    String tableColumn = getTableColumn(modelProperty, true);
    if (Is.emptyString(tableColumn)) return "'" + modelProperty + "'";
    if (referencePropertyWithFormula) {
      referencePropertyWithFormula = false;
      return tableColumn;
    }
    // for calculated fields or created by multiple converter

    if (modelProperty.indexOf('.') >= 0) {
      if (tableColumn.indexOf('.') < 0) return tableColumn;
      String reference = modelProperty.substring(0, modelProperty.lastIndexOf('.'));
      if (tableColumn.startsWith(getTableToQualifyColumn() + ".")) {
        String member = modelProperty.substring(modelProperty.lastIndexOf('.') + 1);
        if (getMetaModel().getMetaReference(reference).getMetaModelReferenced().isKey(member))
          return tableColumn;
      }

      // The next code uses the alias of the table instead of its name. In order to
      // support multiple references to the same model
      if (reference.indexOf('.') >= 0) {
        if (getMetaModel().getMetaProperty(modelProperty).isKey()) {
          reference = reference.substring(0, reference.lastIndexOf('.'));
        }
        reference = reference.replaceAll("\\.", "_");
      }
      return "T_" + reference + tableColumn.substring(tableColumn.lastIndexOf('.'));
    } else {
      return getTableToQualifyColumn() + "." + tableColumn;
    }
  }
 public void deleteTSecGroupMemberByUUserIdx(long TenantId, int TSecGroupId, UUID SecUserId) {
   if (indexByUUserIdx == null) {
     indexByUUserIdx =
         new HashMap<CFSecurityTSecGroupMemberByUUserIdxKey, ICFSecurityTSecGroupMemberObj>();
   }
   CFSecurityTSecGroupMemberByUUserIdxKey key =
       ((ICFCrmSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newUUserIdxKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredTSecGroupId(TSecGroupId);
   key.setRequiredSecUserId(SecUserId);
   ICFSecurityTSecGroupMemberObj obj = null;
   if (indexByUUserIdx.containsKey(key)) {
     obj = indexByUUserIdx.get(key);
     ((ICFCrmSchema) schema.getBackingStore())
         .getTableTSecGroupMember()
         .deleteTSecGroupMemberByUUserIdx(
             schema.getAuthorization(), TenantId, TSecGroupId, SecUserId);
     obj.forget(true);
   } else {
     ((ICFCrmSchema) schema.getBackingStore())
         .getTableTSecGroupMember()
         .deleteTSecGroupMemberByUUserIdx(
             schema.getAuthorization(), TenantId, TSecGroupId, SecUserId);
   }
 }
 public ICFAccTaxObj readTaxByUNameIdx(long TenantId, String Name, boolean forceRead) {
   if (indexByUNameIdx == null) {
     indexByUNameIdx = new HashMap<CFAccTaxByUNameIdxKey, ICFAccTaxObj>();
   }
   CFAccTaxByUNameIdxKey key =
       ((ICFAccSchema) schema.getBackingStore()).getFactoryTax().newUNameIdxKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredName(Name);
   ICFAccTaxObj obj = null;
   if ((!forceRead) && indexByUNameIdx.containsKey(key)) {
     obj = indexByUNameIdx.get(key);
   } else {
     CFAccTaxBuff buff =
         ((ICFAccSchema) schema.getBackingStore())
             .getTableTax()
             .readDerivedByUNameIdx(schema.getAuthorization(), TenantId, Name);
     if (buff != null) {
       obj = schema.getTaxTableObj().newInstance();
       obj.setPKey(((ICFAccSchema) schema.getBackingStore()).getFactoryTax().newPKey());
       obj.setBuff(buff);
       obj = (ICFAccTaxObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       indexByUNameIdx.put(key, null);
     }
   }
   return (obj);
 }
 public ICFSecurityTSecGroupMemberObj readTSecGroupMember(
     CFSecurityTSecGroupMemberPKey pkey, boolean forceRead) {
   ICFSecurityTSecGroupMemberObj obj = null;
   if ((!forceRead) && members.containsKey(pkey)) {
     obj = members.get(pkey);
   } else {
     CFSecurityTSecGroupMemberBuff readBuff =
         ((ICFCrmSchema) schema.getBackingStore())
             .getTableTSecGroupMember()
             .readDerivedByIdIdx(
                 schema.getAuthorization(),
                 pkey.getRequiredTenantId(),
                 pkey.getRequiredTSecGroupMemberId());
     if (readBuff != null) {
       obj = schema.getTSecGroupMemberTableObj().newInstance();
       obj.setPKey(
           ((ICFCrmSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newPKey());
       obj.setBuff(readBuff);
       obj = (ICFSecurityTSecGroupMemberObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       members.put(pkey, null);
     }
   }
   return (obj);
 }