public void createOptFullRange(
      CFSecurityAuthorization Authorization, CFDbTestOptFullRangeBuff Buff) {
    final String S_ProcName = "createOptFullRange";
    CFDbTestOptFullRangePKey pkey = schema.getFactoryOptFullRange().newPKey();
    pkey.setRequiredId(schema.nextOptFullRangeIdGen());
    Buff.setRequiredId(pkey.getRequiredId());
    CFDbTestOptFullRangeByUDescrIdxKey keyUDescrIdx =
        schema.getFactoryOptFullRange().newUDescrIdxKey();
    keyUDescrIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    keyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription());

    CFDbTestOptFullRangeByTenantIdxKey keyTenantIdx =
        schema.getFactoryOptFullRange().newTenantIdxKey();
    keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
      throw CFLib.getDefaultExceptionFactory()
          .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey);
    }

    if (dictByUDescrIdx.containsKey(keyUDescrIdx)) {
      throw CFLib.getDefaultExceptionFactory()
          .newUniqueIndexViolationException(
              getClass(), S_ProcName, "OptFullRangeUDescrIdx", keyUDescrIdx);
    }

    // Validate foreign keys

    {
      boolean allNull = true;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableTenant()
                .readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Container", "Tenant", "Tenant", null);
        }
      }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    dictByUDescrIdx.put(keyUDescrIdx, Buff);

    Map<CFDbTestOptFullRangePKey, CFDbTestOptFullRangeBuff> subdictTenantIdx;
    if (dictByTenantIdx.containsKey(keyTenantIdx)) {
      subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx);
    } else {
      subdictTenantIdx = new HashMap<CFDbTestOptFullRangePKey, CFDbTestOptFullRangeBuff>();
      dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx);
    }
    subdictTenantIdx.put(pkey, Buff);
  }
  public void createLoaderBehaviour(
      CFSecurityAuthorization Authorization, CFDbTestLoaderBehaviourBuff Buff) {
    final String S_ProcName = "createLoaderBehaviour";
    CFDbTestLoaderBehaviourPKey pkey = schema.getFactoryLoaderBehaviour().newPKey();
    pkey.setRequiredId(Buff.getRequiredId());
    Buff.setRequiredId(pkey.getRequiredId());
    CFDbTestLoaderBehaviourByUNameIdxKey keyUNameIdx =
        schema.getFactoryLoaderBehaviour().newUNameIdxKey();
    keyUNameIdx.setRequiredName(Buff.getRequiredName());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
      throw CFLib.getDefaultExceptionFactory()
          .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey);
    }

    if (dictByUNameIdx.containsKey(keyUNameIdx)) {
      throw CFLib.getDefaultExceptionFactory()
          .newUniqueIndexViolationException(
              getClass(), S_ProcName, "LoaderBehaviourUNameIdx", keyUNameIdx);
    }

    // Validate foreign keys

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    dictByUNameIdx.put(keyUNameIdx, Buff);
  }
示例#3
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;
  }
  public void updateSecDevice(CFSecurityAuthorization Authorization, CFSecuritySecDeviceBuff Buff) {
    CFSecuritySecDevicePKey pkey = schema.getFactorySecDevice().newPKey();
    pkey.setRequiredSecUserId(Buff.getRequiredSecUserId());
    pkey.setRequiredDevName(Buff.getRequiredDevName());
    CFSecuritySecDeviceBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(), "updateSecDevice", "Existing record not found", "SecDevice", pkey);
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "updateSecDevice", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFSecuritySecDeviceByUserIdxKey existingKeyUserIdx =
        schema.getFactorySecDevice().newUserIdxKey();
    existingKeyUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId());

    CFSecuritySecDeviceByUserIdxKey newKeyUserIdx = schema.getFactorySecDevice().newUserIdxKey();
    newKeyUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

    // Check unique indexes

    // Validate foreign keys

    {
      boolean allNull = true;

      if (allNull) {
        if (null
            == schema
                .getTableSecUser()
                .readDerivedByIdIdx(Authorization, Buff.getRequiredSecUserId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), "updateSecDevice", "Container", "SecDeviceSecUser", "SecUser", null);
        }
      }
    }

    // Update is valid

    Map<CFSecuritySecDevicePKey, CFSecuritySecDeviceBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);

    subdict = dictByUserIdx.get(existingKeyUserIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByUserIdx.containsKey(newKeyUserIdx)) {
      subdict = dictByUserIdx.get(newKeyUserIdx);
    } else {
      subdict = new HashMap<CFSecuritySecDevicePKey, CFSecuritySecDeviceBuff>();
      dictByUserIdx.put(newKeyUserIdx, subdict);
    }
    subdict.put(pkey, Buff);
  }
示例#5
0
    protected Map<String, Object> getARow(
        ResultSet resultSet,
        boolean convertType,
        List<String> colNames,
        Map<String, Integer> fieldNameVsType) {
      if (resultSet == null) return null;
      Map<String, Object> result = new HashMap<>();
      for (String colName : colNames) {
        try {
          if (!convertType) {
            // Use underlying database's type information except for BigDecimal and BigInteger
            // which cannot be serialized by JavaBin/XML. See SOLR-6165
            Object value = resultSet.getObject(colName);
            if (value instanceof BigDecimal || value instanceof BigInteger) {
              result.put(colName, value.toString());
            } else {
              result.put(colName, value);
            }
            continue;
          }

          Integer type = fieldNameVsType.get(colName);
          if (type == null) type = Types.VARCHAR;
          switch (type) {
            case Types.INTEGER:
              result.put(colName, resultSet.getInt(colName));
              break;
            case Types.FLOAT:
              result.put(colName, resultSet.getFloat(colName));
              break;
            case Types.BIGINT:
              result.put(colName, resultSet.getLong(colName));
              break;
            case Types.DOUBLE:
              result.put(colName, resultSet.getDouble(colName));
              break;
            case Types.DATE:
              result.put(colName, resultSet.getTimestamp(colName));
              break;
            case Types.BOOLEAN:
              result.put(colName, resultSet.getBoolean(colName));
              break;
            case Types.BLOB:
              result.put(colName, resultSet.getBytes(colName));
              break;
            default:
              result.put(colName, resultSet.getString(colName));
              break;
          }
        } catch (SQLException e) {
          logError("Error reading data ", e);
          wrapAndThrow(SEVERE, e, "Error reading data from database");
        }
      }
      return result;
    }
示例#6
0
  /** Creates a new instance of UserManager */
  public UserManager(Database p_database, Controller controller, ValueRecordManager p_valueManager)
      throws ReportingException {
    super(p_database, "sge_user", "u_", false, primaryKeyFields, null, controller);

    accountingMap = new HashMap();
    accountingMap.put("u_user", "a_owner");

    sharelogMap = new HashMap();
    sharelogMap.put("u_user", "sl_user");

    valueManager = p_valueManager;
  }
  public ICFSecurityServiceTypeObj realizeServiceType(ICFSecurityServiceTypeObj Obj) {
    ICFSecurityServiceTypeObj obj = Obj;
    CFSecurityServiceTypePKey pkey = obj.getPKey();
    ICFSecurityServiceTypeObj keepObj = null;
    if (members.containsKey(pkey) && (null != members.get(pkey))) {
      ICFSecurityServiceTypeObj 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 (indexByUDescrIdx != null) {
        CFSecurityServiceTypeByUDescrIdxKey keyUDescrIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryServiceType().newUDescrIdxKey();
        keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription());
        indexByUDescrIdx.remove(keyUDescrIdx);
      }

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

      if (indexByUDescrIdx != null) {
        CFSecurityServiceTypeByUDescrIdxKey keyUDescrIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryServiceType().newUDescrIdxKey();
        keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription());
        indexByUDescrIdx.put(keyUDescrIdx, keepObj);
      }
      if (allServiceType != null) {
        allServiceType.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 (allServiceType != null) {
        allServiceType.put(keepObj.getPKey(), keepObj);
      }

      if (indexByUDescrIdx != null) {
        CFSecurityServiceTypeByUDescrIdxKey keyUDescrIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryServiceType().newUDescrIdxKey();
        keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription());
        indexByUDescrIdx.put(keyUDescrIdx, keepObj);
      }
    }
    return (keepObj);
  }
  public Map<String, List> fetchHoldingItem(boolean cursor) throws SQLException {

    String holdingId = "";
    String tempHoldingId = "";
    List itemIds = new ArrayList();

    Map<String, List> map = null;
    if (cursor) {
      while (holdingItemResultSet.next()) {
        holdingId = "who-" + holdingItemResultSet.getString("HOLDINGS_ID");
        if (StringUtils.isNotEmpty(tempHoldingId) && !tempHoldingId.equals(holdingId)) {
          if (itemIds.size() > 0) {
            map = new HashMap<>();
            map.put(tempHoldingId, itemIds);
            return map;
          }
        }
        itemIds.add("wio-" + holdingItemResultSet.getString("ITEM_ID"));
        tempHoldingId = holdingId;
      }

    } else {
      holdingItemResultSet.previous();
      //           while(holdingItemResultSet.previous()) {
      //               break;
      //           }
      while (holdingItemResultSet.next()) {
        holdingId = "who-" + holdingItemResultSet.getString("HOLDINGS_ID");
        if (StringUtils.isNotEmpty(tempHoldingId) && !tempHoldingId.equals(holdingId)) {
          if (itemIds.size() > 0) {
            map = new HashMap<>();
            map.put(tempHoldingId, itemIds);
            return map;
          }
        }
        itemIds.add("wio-" + holdingItemResultSet.getString("ITEM_ID"));
        tempHoldingId = holdingId;
      }
    }

    if (itemIds.size() > 0) {
      map = new HashMap<>();
      map.put(tempHoldingId, itemIds);
      return map;
    } else {
      map = null;
    }
    holdingItemResultSet.close();
    return map;
  }
示例#9
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);
    }
  }
  public void updateLoaderBehaviour(
      CFSecurityAuthorization Authorization, CFDbTestLoaderBehaviourBuff Buff) {
    CFDbTestLoaderBehaviourPKey pkey = schema.getFactoryLoaderBehaviour().newPKey();
    pkey.setRequiredId(Buff.getRequiredId());
    CFDbTestLoaderBehaviourBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(),
              "updateLoaderBehaviour",
              "Existing record not found",
              "LoaderBehaviour",
              pkey);
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "updateLoaderBehaviour", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFDbTestLoaderBehaviourByUNameIdxKey existingKeyUNameIdx =
        schema.getFactoryLoaderBehaviour().newUNameIdxKey();
    existingKeyUNameIdx.setRequiredName(existing.getRequiredName());

    CFDbTestLoaderBehaviourByUNameIdxKey newKeyUNameIdx =
        schema.getFactoryLoaderBehaviour().newUNameIdxKey();
    newKeyUNameIdx.setRequiredName(Buff.getRequiredName());

    // Check unique indexes

    if (!existingKeyUNameIdx.equals(newKeyUNameIdx)) {
      if (dictByUNameIdx.containsKey(newKeyUNameIdx)) {
        throw CFLib.getDefaultExceptionFactory()
            .newUniqueIndexViolationException(
                getClass(), "updateLoaderBehaviour", "LoaderBehaviourUNameIdx", newKeyUNameIdx);
      }
    }

    // Validate foreign keys

    // Update is valid

    Map<CFDbTestLoaderBehaviourPKey, CFDbTestLoaderBehaviourBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);

    dictByUNameIdx.remove(existingKeyUNameIdx);
    dictByUNameIdx.put(newKeyUNameIdx, Buff);
  }
示例#11
0
 @Override
 public boolean contains(final DatabaseTable table, final String key) throws DatabaseException {
   final boolean result = get(table, key) != null;
   if (traceLogging) {
     final Map<String, Object> debugOutput = new LinkedHashMap<>();
     debugOutput.put("table", table);
     debugOutput.put("key", key);
     debugOutput.put("result", result);
     LOGGER.trace(
         "contains operation result: "
             + JsonUtil.serializeMap(debugOutput, JsonUtil.Flag.PrettyPrint));
   }
   updateStats(true, false);
   return result;
 }
  public Map<String, List> fetchBibHolding(boolean cursor) throws SQLException {
    String holdingId = "";
    String tempHoldingId = "";
    List bibIds = new ArrayList();
    Map<String, List> map = null;

    if (cursor) {
      while (bibHoldingsResultSet.next()) {
        holdingId = "who-" + bibHoldingsResultSet.getString("HOLDINGS_ID");
        if (StringUtils.isNotEmpty(tempHoldingId) && !tempHoldingId.equals(holdingId)) {

          if (bibIds.size() > 0) {
            map = new HashMap<>();
            bibIds.remove(0);
            map.put(tempHoldingId, bibIds);
            return map;
          }
        }

        bibIds.add("wbm-" + bibHoldingsResultSet.getString("BIB_ID"));
        tempHoldingId = holdingId;
      }

    } else {
      while (bibHoldingsResultSet.next()) {
        holdingId = "who-" + bibHoldingsResultSet.getString("HOLDINGS_ID");
        if (StringUtils.isNotEmpty(tempHoldingId) && !tempHoldingId.equals(holdingId)) {

          map = new HashMap<>();
          map.put(tempHoldingId, bibIds);
          return map;
        }
        bibIds.add("wbm-" + bibHoldingsResultSet.getString("BIB_ID"));
        tempHoldingId = holdingId;
      }
    }

    if (bibIds.size() > 0) {
      map = new HashMap<>();
      bibIds.remove(0);
      map.put(tempHoldingId, bibIds);
      return map;
    } else {
      map = null;
    }
    bibHoldingsResultSet.close();
    return map;
  }
 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);
 }
 private static void setValues(
     byte[][] values,
     int[] pkSlotIndex,
     int[] columnIndexes,
     PTable table,
     Map<ImmutableBytesPtr, Map<PColumn, byte[]>> mutation) {
   Map<PColumn, byte[]> columnValues = Maps.newHashMapWithExpectedSize(columnIndexes.length);
   byte[][] pkValues = new byte[table.getPKColumns().size()][];
   // If the table uses salting, the first byte is the salting byte, set to an empty arrary
   // here and we will fill in the byte later in PRowImpl.
   if (table.getBucketNum() != null) {
     pkValues[0] = new byte[] {0};
   }
   for (int i = 0; i < values.length; i++) {
     byte[] value = values[i];
     PColumn column = table.getColumns().get(columnIndexes[i]);
     if (SchemaUtil.isPKColumn(column)) {
       pkValues[pkSlotIndex[i]] = value;
     } else {
       columnValues.put(column, value);
     }
   }
   ImmutableBytesPtr ptr = new ImmutableBytesPtr();
   table.newKey(ptr, pkValues);
   mutation.put(ptr, columnValues);
 }
 public ICFBamClearTopDepObj readClearTopDepByUNameIdx(
     long TenantId, long ContTableId, String Name, boolean forceRead) {
   if (indexByUNameIdx == null) {
     indexByUNameIdx = new HashMap<CFBamClearTopDepByUNameIdxKey, ICFBamClearTopDepObj>();
   }
   CFBamClearTopDepByUNameIdxKey key =
       schema.getBackingStore().getFactoryClearTopDep().newUNameIdxKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredContTableId(ContTableId);
   key.setRequiredName(Name);
   ICFBamClearTopDepObj obj = null;
   if ((!forceRead) && indexByUNameIdx.containsKey(key)) {
     obj = indexByUNameIdx.get(key);
   } else {
     CFBamClearTopDepBuff buff =
         schema
             .getBackingStore()
             .getTableClearTopDep()
             .readDerivedByUNameIdx(schema.getAuthorization(), TenantId, ContTableId, Name);
     if (buff != null) {
       obj =
           (ICFBamClearTopDepObj)
               schema.getScopeTableObj().constructByClassCode(buff.getClassCode());
       obj.setPKey(schema.getBackingStore().getFactoryScope().newPKey());
       obj.setBuff(buff);
       obj = (ICFBamClearTopDepObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       indexByUNameIdx.put(key, null);
     }
   }
   return (obj);
 }
 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 ICFSecurityISOCountryObj readISOCountryByNameIdx(String Name, boolean forceRead) {
   if (indexByNameIdx == null) {
     indexByNameIdx = new HashMap<CFSecurityISOCountryByNameIdxKey, ICFSecurityISOCountryObj>();
   }
   CFSecurityISOCountryByNameIdxKey key =
       ((ICFInternetSchema) schema.getBackingStore()).getFactoryISOCountry().newNameIdxKey();
   key.setRequiredName(Name);
   ICFSecurityISOCountryObj obj = null;
   if ((!forceRead) && indexByNameIdx.containsKey(key)) {
     obj = indexByNameIdx.get(key);
   } else {
     CFSecurityISOCountryBuff buff =
         ((ICFInternetSchema) schema.getBackingStore())
             .getTableISOCountry()
             .readDerivedByNameIdx(schema.getAuthorization(), Name);
     if (buff != null) {
       obj = schema.getISOCountryTableObj().newInstance();
       obj.setPKey(
           ((ICFInternetSchema) schema.getBackingStore()).getFactoryISOCountry().newPKey());
       obj.setBuff(buff);
       obj = (ICFSecurityISOCountryObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       indexByNameIdx.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 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);
 }
 public ICFCrmMemoObj readMemoByUDescrIdx(
     long TenantId, long ContactId, String Description, boolean forceRead) {
   if (indexByUDescrIdx == null) {
     indexByUDescrIdx = new HashMap<CFCrmMemoByUDescrIdxKey, ICFCrmMemoObj>();
   }
   CFCrmMemoByUDescrIdxKey key =
       ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredContactId(ContactId);
   key.setRequiredDescription(Description);
   ICFCrmMemoObj obj = null;
   if ((!forceRead) && indexByUDescrIdx.containsKey(key)) {
     obj = indexByUDescrIdx.get(key);
   } else {
     CFCrmMemoBuff buff =
         ((ICFAccSchema) schema.getBackingStore())
             .getTableMemo()
             .readDerivedByUDescrIdx(schema.getAuthorization(), TenantId, ContactId, Description);
     if (buff != null) {
       obj = schema.getMemoTableObj().newInstance();
       obj.setPKey(((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newPKey());
       obj.setBuff(buff);
       obj = (ICFCrmMemoObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       indexByUDescrIdx.put(key, null);
     }
   }
   return (obj);
 }
 public ICFInternetDomainObj readDomainByNameIdx(
     long TenantId, long SubDomainOfId, String Name, boolean forceRead) {
   if (indexByNameIdx == null) {
     indexByNameIdx = new HashMap<CFInternetDomainByNameIdxKey, ICFInternetDomainObj>();
   }
   CFInternetDomainByNameIdxKey key =
       ((ICFBamSchema) schema.getBackingStore()).getFactoryDomain().newNameIdxKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredSubDomainOfId(SubDomainOfId);
   key.setRequiredName(Name);
   ICFInternetDomainObj obj = null;
   if ((!forceRead) && indexByNameIdx.containsKey(key)) {
     obj = indexByNameIdx.get(key);
   } else {
     CFInternetDomainBuff buff =
         ((ICFBamSchema) schema.getBackingStore())
             .getTableDomain()
             .readDerivedByNameIdx(schema.getAuthorization(), TenantId, SubDomainOfId, Name);
     if (buff != null) {
       obj =
           (ICFInternetDomainObj)
               schema.getDomainBaseTableObj().constructByClassCode(buff.getClassCode());
       obj.setPKey(((ICFBamSchema) schema.getBackingStore()).getFactoryDomainBase().newPKey());
       obj.setBuff(buff);
       obj = (ICFInternetDomainObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       indexByNameIdx.put(key, null);
     }
   }
   return (obj);
 }
示例#23
0
  /** Create the data-service for select data by given key operation. */
  private void addSelectWithKeyOperation(
      DataService dataServiceObject,
      String schema,
      DatabaseMetaData metaData,
      String dbName,
      String tableName,
      String pKey)
      throws SQLException, DataServiceFault, NullPointerException {
    Map<String, WithParam> paramMap = new HashMap<String, WithParam>();
    List<String> paramList = new ArrayList<String>();

    ResultSet columnNames = getColumnNames(metaData, schema, dbName, tableName, null);
    String colomNames = "";
    int i = 0;
    while (columnNames.next()) {
      String name = columnNames.getString(DBConstants.DataServiceGenerator.COLUMN_NAME);
      // get the colomn names for the query
      if (i == 0) {
        colomNames = " " + name;
      } else {
        colomNames = colomNames + ", " + name;
      }
      i++;
      if (pKey.equals(name)) {
        WithParam withParam =
            new WithParam(pKey, pKey, pKey, DBConstants.DataServiceGenerator.QUERY_PARAM);
        paramMap.put(pKey, withParam);
        paramList.add(pKey);
      }
    }
    Set<String> requiredRoles = new HashSet<String>();
    String queryId =
        DBConstants.DataServiceGenerator.SELECT_WITH_KEY
            + tableName
            + DBConstants.DataServiceGenerator._QUERY;
    String OpName =
        DBConstants.DataServiceGenerator.SELECT_WITH_KEY
            + tableName
            + DBConstants.DataServiceGenerator._OPERATION;
    CallQuery callQuery = new CallQuery(dataServiceObject, queryId, paramMap, requiredRoles);
    List<CallQuery> callQueries = new ArrayList<CallQuery>();
    callQueries.add(callQuery);
    CallQueryGroup callQueryGroup = new CallQueryGroup(callQueries);
    // batchRequest=false
    // parentOperation=null
    Operation operation =
        new Operation(dataServiceObject, OpName, null, callQueryGroup, false, null, false, false);
    dataServiceObject.addOperation(operation);
    dataServiceObject.addQuery(
        this.getSelectWithKeyQuery(
            paramList,
            pKey,
            queryId,
            tableName,
            dataServiceObject,
            metaData,
            dbName,
            schema,
            colomNames));
  }
示例#24
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 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);
 }
 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 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);
 }
示例#28
0
  /** Update Operation. */
  private void addUpdateOperation(
      DataService dataServiceObject,
      String schema,
      DatabaseMetaData metaData,
      String dbName,
      String tableName,
      String pKey)
      throws SQLException, DataServiceFault {
    Map<String, WithParam> paramMap = new HashMap<String, WithParam>();
    List<String> paramList = new ArrayList<String>();

    ResultSet columnNames = getColumnNames(metaData, schema, dbName, tableName, null);
    while (columnNames.next()) {
      String name = columnNames.getString(DBConstants.DataServiceGenerator.COLUMN_NAME);
      if (!name.equals(pKey)) {
        WithParam withParam1 =
            new WithParam(name, name, name, DBConstants.DataServiceGenerator.QUERY_PARAM);
        paramMap.put(name, withParam1);
        paramList.add(name); // add to this @param into @param List
      }
    }
    WithParam withParam2 =
        new WithParam(pKey, pKey, pKey, DBConstants.DataServiceGenerator.QUERY_PARAM);
    paramMap.put(pKey, withParam2);
    paramList.add(pKey);
    Set<String> requiredRoles = new HashSet<String>(); // empty set
    String queryId =
        DBConstants.DataServiceGenerator.UPDATE_
            + tableName
            + DBConstants.DataServiceGenerator._QUERY;
    String OpName =
        DBConstants.DataServiceGenerator.UPDATE_
            + tableName
            + DBConstants.DataServiceGenerator._OPERATION;
    CallQuery callQuery = new CallQuery(dataServiceObject, queryId, paramMap, requiredRoles);
    List<CallQuery> callQueries = new ArrayList<CallQuery>();
    callQueries.add(callQuery);
    CallQueryGroup callQueryGroup = new CallQueryGroup(callQueries);
    // batchRequest=false
    // parentOperation=null
    Operation operation =
        new Operation(dataServiceObject, OpName, null, callQueryGroup, false, null, false, false);
    dataServiceObject.addOperation(operation);
    dataServiceObject.addQuery(
        this.getUpdateQuery(
            paramList, pKey, queryId, tableName, dataServiceObject, metaData, dbName, schema));
  }
  public void createSecDevice(CFSecurityAuthorization Authorization, CFSecuritySecDeviceBuff Buff) {
    final String S_ProcName = "createSecDevice";
    CFSecuritySecDevicePKey pkey = schema.getFactorySecDevice().newPKey();
    pkey.setRequiredSecUserId(Buff.getRequiredSecUserId());
    pkey.setRequiredDevName(Buff.getRequiredDevName());
    Buff.setRequiredSecUserId(pkey.getRequiredSecUserId());
    Buff.setRequiredDevName(pkey.getRequiredDevName());
    CFSecuritySecDeviceByUserIdxKey keyUserIdx = schema.getFactorySecDevice().newUserIdxKey();
    keyUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
      throw CFLib.getDefaultExceptionFactory()
          .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey);
    }

    // Validate foreign keys

    {
      boolean allNull = true;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableSecUser()
                .readDerivedByIdIdx(Authorization, Buff.getRequiredSecUserId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Container", "SecDeviceSecUser", "SecUser", null);
        }
      }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    Map<CFSecuritySecDevicePKey, CFSecuritySecDeviceBuff> subdictUserIdx;
    if (dictByUserIdx.containsKey(keyUserIdx)) {
      subdictUserIdx = dictByUserIdx.get(keyUserIdx);
    } else {
      subdictUserIdx = new HashMap<CFSecuritySecDevicePKey, CFSecuritySecDeviceBuff>();
      dictByUserIdx.put(keyUserIdx, subdictUserIdx);
    }
    subdictUserIdx.put(pkey, Buff);
  }
 public InsertableProbePlatformDataset(
     InsertableProbePlatform pp, Collection<InsertableProbe> ps) {
   platform = pp;
   probes = new HashMap<String, InsertableProbe>();
   for (InsertableProbe p : ps) {
     probes.put(p.name, p);
   }
 }