Package org.exoplatform.services.jcr.impl.checker

Examples of org.exoplatform.services.jcr.impl.checker.PropertyRemover


         statement = statement.replace("?", "0");
      }

      itemsInspectionQuery.add(new InspectionQuery(statement, new String[]{DBConstants.COLUMN_ID,
         DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME},
         "A node that has a single valued properties with nothing declared in the VALUE table.", new PropertyRemover(
            jdbcDataContainer.getConnectionFactory(), nodeTypeManager)));

      itemsInspectionQuery.add(new InspectionQuery(jdbcDataContainer.multiDb
         ? "select * from JCR_MITEM N where N.I_CLASS=1 and NOT EXISTS "
            + "(select * from JCR_MITEM P where P.I_CLASS=2 and P.PARENT_ID=N.ID "
            + "and P.NAME='[http://www.jcp.org/jcr/1.0]primaryType')"
         : "select * from JCR_SITEM N where N.CONTAINER_NAME='" + jdbcDataContainer.containerName
            + "' and N.I_CLASS=1 and NOT EXISTS (select * from JCR_SITEM P "
            + "where P.I_CLASS=2 and P.PARENT_ID=N.ID and P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' "
            + "and P.CONTAINER_NAME='" + jdbcDataContainer.containerName + "')", new String[]{DBConstants.COLUMN_ID,
         DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME}, "A node that doesn't have primary type property",
         new NodeRemover(jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.multiDb ? "JCR_MITEM"
            : "JCR_SITEM", nodeTypeManager)));

      itemsInspectionQuery.add(new InspectionQuery(jdbcDataContainer.multiDb
         ? "select * from JCR_MVALUE V where NOT EXISTS(select * from JCR_MITEM P "
            + "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)"
         : "select * from JCR_SVALUE V where NOT EXISTS(select * from JCR_SITEM P "
            + "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)", new String[]{DBConstants.COLUMN_ID,
         DBConstants.COLUMN_VPROPERTY_ID}, "All value records that has not related property record",
         new ValueRecordsRemover(jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerName,
            jdbcDataContainer.multiDb)));

      // The differences in the queries by DB dialect.
      if (jdbcDataContainer.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE))
      {
         statement =
            jdbcDataContainer.multiDb
               ? "select * from JCR_MVALUE where (STORAGE_DESC is not null and not DATA like null)"
               : "select V.* from JCR_SVALUE V, JCR_SITEM I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
                  + jdbcDataContainer.containerName + "' AND ((STORAGE_DESC is not null and not DATA like null))";
      }
      else if (jdbcDataContainer.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLE)
         || jdbcDataContainer.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLEOCI))
      {
         statement =
            jdbcDataContainer.multiDb
               ? "select * from JCR_MVALUE where (STORAGE_DESC is not null and DATA is not null)"
               : "select V.* from JCR_SVALUE V, JCR_SITEM I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
                  + jdbcDataContainer.containerName + "' AND (STORAGE_DESC is not null and DATA is not null)";
      }
      else
      {
         statement =
            jdbcDataContainer.multiDb
               ? "select * from JCR_MVALUE where (STORAGE_DESC is not null and DATA is not null)"
               : "select V.* from JCR_SVALUE V, JCR_SITEM I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
                  + jdbcDataContainer.containerName + "' AND ((STORAGE_DESC is not null and DATA is not null))";
      }
      itemsInspectionQuery.add(new InspectionQuery(statement, new String[]{DBConstants.COLUMN_ID},
         "Incorrect VALUE records. Both fields STORAGE_DESC and DATA contain not null value.", new DummyRepair()));

      itemsInspectionQuery.add(new InspectionQuery(jdbcDataContainer.multiDb
         ? "select * from JCR_MITEM I where I.ID = I.PARENT_ID and I.NAME <> '" + Constants.ROOT_PARENT_NAME + "'"
         : "select * from JCR_SITEM I where I.ID = I.PARENT_ID and I.CONTAINER_NAME='"
            + jdbcDataContainer.containerName + "' and I.NAME <> '" + Constants.ROOT_PARENT_NAME + "'", new String[]{
         DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME}, "An item is its own parent.",
         new RootAsParentAssigner(jdbcDataContainer.getConnectionFactory())));

      itemsInspectionQuery
         .add(new InspectionQuery(
            jdbcDataContainer.multiDb
               ? "select * from JCR_MITEM I where EXISTS (select * from JCR_MITEM J"
                  + " WHERE I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
                  + " and I.VERSION != J.VERSION and I.I_CLASS = 2)"
               : "select * from JCR_SITEM I where I.CONTAINER_NAME='"
                  + jdbcDataContainer.containerName
                  + "' and EXISTS (select * from JCR_SITEM J WHERE I.CONTAINER_NAME = J.CONTAINER_NAME and"
                  + " I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
                  + " and I.VERSION != J.VERSION and I.I_CLASS = 2)",
            new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME,
               DBConstants.COLUMN_VERSION, DBConstants.COLUMN_CLASS, DBConstants.COLUMN_INDEX},
            "Several versions of same item.", new EarlierVersionsRemover(jdbcDataContainer.getConnectionFactory())));

      itemsInspectionQuery.add(new InspectionQuery(jdbcDataContainer.multiDb
         ? "select * from JCR_MITEM P, JCR_MVALUE V where P.ID=V.PROPERTY_ID and P.P_TYPE=9 and NOT EXISTS "
            + "(select * from JCR_MREF R where P.ID=R.PROPERTY_ID)"
         : "select * from JCR_SITEM P, JCR_SVALUE V where P.ID=V.PROPERTY_ID and P.CONTAINER_NAME='"
            + jdbcDataContainer.containerName
            + "' and P.P_TYPE=9 and NOT EXISTS (select * from JCR_SREF R where P.ID=R.PROPERTY_ID)", new String[]{
         DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME},
         "Reference properties without reference records", new PropertyRemover(jdbcDataContainer
            .getConnectionFactory(), nodeTypeManager)));
   }
View Full Code Here


         statement = statement.replace("?", "0");
      }

      itemsInspectionQuery.add(new InspectionQuery(statement, new String[]{DBConstants.COLUMN_ID,
         DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME},
         "A node that has a single valued properties with nothing declared in the VALUE table.", new PropertyRemover(
            jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerConfig, nodeTypeManager)));

      itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable
         + " N where N.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
         + "' and N.I_CLASS=1 and NOT EXISTS (select * from " + itemTable + " P "
         + "where P.I_CLASS=2 and P.PARENT_ID=N.ID and P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' "
         + "and P.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName + "')" : "select * from "
         + itemTable + " N where N.I_CLASS=1 and NOT EXISTS " + "(select * from " + itemTable
         + " P where P.I_CLASS=2 and P.PARENT_ID=N.ID " + "and P.NAME='[http://www.jcp.org/jcr/1.0]primaryType')",
         new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME},
         "A node that doesn't have primary type property", new NodeRemover(jdbcDataContainer.getConnectionFactory(),
            jdbcDataContainer.containerConfig, nodeTypeManager)));

      itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + valueTable
         + " V where NOT EXISTS(select * from " + itemTable + " P " + "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)"
         : "select * from " + valueTable + " V where NOT EXISTS(select * from " + itemTable + " P "
            + "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)", new String[]{DBConstants.COLUMN_ID,
         DBConstants.COLUMN_VPROPERTY_ID}, "All value records that has not related property record",
         new ValueRecordsRemover(jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerConfig)));

      // The differences in the queries by DB dialect.
      if (jdbcDataContainer.containerConfig.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE))
      {
         statement =
            singleDatabase ? "select V.* from " + valueTable + " V, " + itemTable
               + " I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
               + jdbcDataContainer.containerConfig.containerName
               + "' AND ((STORAGE_DESC is not null and not DATA like null))" : "select * from " + valueTable
               + " where (STORAGE_DESC is not null and not DATA like null)";
      }
      else if (jdbcDataContainer.containerConfig.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLE)
         || jdbcDataContainer.containerConfig.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLEOCI))
      {
         statement =
            singleDatabase ? "select V.* from " + valueTable + " V, " + itemTable
               + " I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
               + jdbcDataContainer.containerConfig.containerName
               + "' AND (STORAGE_DESC is not null and DATA is not null)" : "select * from " + valueTable
               + " where (STORAGE_DESC is not null and DATA is not null)";
      }
      else
      {
         statement =
            singleDatabase ? "select V.* from " + valueTable + " V, " + itemTable
               + " I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
               + jdbcDataContainer.containerConfig.containerName
               + "' AND ((STORAGE_DESC is not null and DATA is not null))" : "select * from " + valueTable
               + " where (STORAGE_DESC is not null and DATA is not null)";
      }
      itemsInspectionQuery.add(new InspectionQuery(statement, new String[]{DBConstants.COLUMN_ID},
         "Incorrect VALUE records. Both fields STORAGE_DESC and DATA contain not null value.", new DummyRepair()));

      itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable
         + " I where I.ID = I.PARENT_ID and I.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
         + "' and I.NAME <> '" + Constants.ROOT_PARENT_NAME + "'" : "select * from " + itemTable
         + " I where I.ID = I.PARENT_ID and I.NAME <> '" + Constants.ROOT_PARENT_NAME + "'", new String[]{
         DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME}, "An item is its own parent.",
         new RootAsParentAssigner(jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerConfig)));

      itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable
         + " I where I.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
         + "' and EXISTS (select * from " + itemTable + " J WHERE I.CONTAINER_NAME = J.CONTAINER_NAME and"
         + " I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
         + " and I.VERSION != J.VERSION and I.I_CLASS = 2)" : "select * from " + itemTable
         + " I where EXISTS (select * from " + itemTable + " J"
         + " WHERE I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
         + " and I.VERSION != J.VERSION and I.I_CLASS = 2)", new String[]{DBConstants.COLUMN_ID,
         DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME, DBConstants.COLUMN_VERSION, DBConstants.COLUMN_CLASS,
         DBConstants.COLUMN_INDEX}, "Several versions of same item.", new EarlierVersionsRemover(jdbcDataContainer
         .getConnectionFactory(), jdbcDataContainer.containerConfig)));

      itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable + " P, " + valueTable
         + " V where P.ID=V.PROPERTY_ID and P.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
         + "' and P.P_TYPE=9 and NOT EXISTS (select * from " + refTable + " R where P.ID=R.PROPERTY_ID)"
         : "select * from " + itemTable + " P, " + valueTable
            + " V where P.ID=V.PROPERTY_ID and P.P_TYPE=9 and NOT EXISTS " + "(select * from " + refTable
            + " R where P.ID=R.PROPERTY_ID)", new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID,
         DBConstants.COLUMN_NAME}, "Reference properties without reference records", new PropertyRemover(
         jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerConfig, nodeTypeManager)));
   }
View Full Code Here

                  + "where V.PROPERTY_ID=P.ID)" : "select * from JCR_SITEM P where P.CONTAINER_NAME='"
                  + jdbcDataContainer.containerName + "' and P.I_CLASS=2"
                  + " and P.P_MULTIVALUED=? and NOT EXISTS( select * from JCR_SVALUE V where V.PROPERTY_ID=P.ID)",
            new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME},
            "A node that has a single valued properties with nothing declared in the VALUE table.",
            new PropertyRemover(jdbcDataContainer.getConnectionFactory(), nodeTypeManager)));

      itemsInspectionQuery.add(new InspectionQuery(jdbcDataContainer.multiDb
         ? "select * from JCR_MITEM N where N.I_CLASS=1 and NOT EXISTS "
            + "(select * from JCR_MITEM P where P.I_CLASS=2 and P.PARENT_ID=N.ID "
            + "and P.NAME='[http://www.jcp.org/jcr/1.0]primaryType')"
         : "select * from JCR_SITEM N where N.CONTAINER_NAME='" + jdbcDataContainer.containerName
            + "' and N.I_CLASS=1 and NOT EXISTS (select * from JCR_SITEM P "
            + "where P.I_CLASS=2 and P.PARENT_ID=N.ID and P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' "
            + "and P.CONTAINER_NAME='" + jdbcDataContainer.containerName + "')", new String[]{DBConstants.COLUMN_ID,
         DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME}, "A node that doesn't have primary type property",
         new NodeRemover(jdbcDataContainer.getConnectionFactory(), nodeTypeManager)));

      itemsInspectionQuery.add(new InspectionQuery(jdbcDataContainer.multiDb
         ? "select * from JCR_MVALUE V where NOT EXISTS(select * from JCR_MITEM P "
            + "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)"
         : "select * from JCR_SVALUE V where NOT EXISTS(select * from JCR_SITEM P "
            + "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)", new String[]{DBConstants.COLUMN_ID,
         DBConstants.COLUMN_VPROPERTY_ID}, "All value records that has not related property record",
         new ValueRecordsRemover(jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerName,
            jdbcDataContainer.multiDb)));

      // The differences in the queries by DB dialect.
      String statement;
      if (jdbcDataContainer.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE))
      {
         statement =
            jdbcDataContainer.multiDb
               ? "select * from JCR_MVALUE where (STORAGE_DESC is not null and not DATA like null)"
               : "select V.* from JCR_SVALUE V, JCR_SITEM I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
                  + jdbcDataContainer.containerName + "' AND ((STORAGE_DESC is not null and not DATA like null))";
      }
      else if (jdbcDataContainer.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLE)
         || jdbcDataContainer.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLEOCI))
      {
         statement =
            jdbcDataContainer.multiDb
               ? "select * from JCR_MVALUE where (STORAGE_DESC is not null and DATA is not null)"
               : "select V.* from JCR_SVALUE V, JCR_SITEM I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
                  + jdbcDataContainer.containerName + "' AND (STORAGE_DESC is not null and DATA is not null)";
      }
      else
      {
         statement =
            jdbcDataContainer.multiDb
               ? "select * from JCR_MVALUE where (STORAGE_DESC is not null and DATA is not null)"
               : "select V.* from JCR_SVALUE V, JCR_SITEM I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
                  + jdbcDataContainer.containerName + "' AND ((STORAGE_DESC is not null and DATA is not null))";
      }
      itemsInspectionQuery.add(new InspectionQuery(statement, new String[]{DBConstants.COLUMN_ID},
         "Incorrect VALUE records. Both fields STORAGE_DESC and DATA contain not null value.", new DummyRepair()));

      itemsInspectionQuery.add(new InspectionQuery(jdbcDataContainer.multiDb
         ? "select * from JCR_MITEM I where I.ID = I.PARENT_ID and I.NAME <> '" + Constants.ROOT_PARENT_NAME + "'"
         : "select * from JCR_SITEM I where I.ID = I.PARENT_ID and I.CONTAINER_NAME='"
            + jdbcDataContainer.containerName + "' and I.NAME <> '" + Constants.ROOT_PARENT_NAME + "'", new String[]{
         DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME}, "An item is its own parent.",
         new RootAsParentAssigner(jdbcDataContainer.getConnectionFactory())));

      itemsInspectionQuery
         .add(new InspectionQuery(
            jdbcDataContainer.multiDb
               ? "select * from JCR_MITEM I where EXISTS (select * from JCR_MITEM J"
                  + " WHERE I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
                  + " and I.VERSION != J.VERSION)"
               : "select * from JCR_SITEM I where I.CONTAINER_NAME='"
                  + jdbcDataContainer.containerName
                  + "' and EXISTS (select * from JCR_SITEM J WHERE I.CONTAINER_NAME = J.CONTAINER_NAME and"
                  + " I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
                  + " and I.VERSION != J.VERSION)",
            new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME,
               DBConstants.COLUMN_VERSION, DBConstants.COLUMN_CLASS, DBConstants.COLUMN_INDEX},
            "Several versions of same item.", new EarlierVersionsRemover(jdbcDataContainer.getConnectionFactory())));

      itemsInspectionQuery.add(new InspectionQuery(jdbcDataContainer.multiDb
         ? "select * from JCR_MITEM P, JCR_MVALUE V where P.ID=V.PROPERTY_ID and P.P_TYPE=9 and NOT EXISTS "
            + "(select * from JCR_MREF R where P.ID=R.PROPERTY_ID)"
         : "select * from JCR_SITEM P, JCR_SVALUE V where P.ID=V.PROPERTY_ID and P.CONTAINER_NAME='"
            + jdbcDataContainer.containerName
            + "' and P.P_TYPE=9 and NOT EXISTS (select * from JCR_SREF R where P.ID=R.PROPERTY_ID)", new String[]{
         DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME},
         "Reference properties without reference records", new PropertyRemover(jdbcDataContainer
            .getConnectionFactory(), nodeTypeManager)));
   }
View Full Code Here

         statement = statement.replace("?", "0");
      }

      itemsInspectionQuery.add(new InspectionQuery(statement, new String[]{DBConstants.COLUMN_ID,
         DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME},
         "A node that has a single valued properties with nothing declared in the VALUE table.", new PropertyRemover(
            jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerConfig, nodeTypeManager)));

      itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable
         + " N where N.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
         + "' and N.I_CLASS=1 and NOT EXISTS (select * from " + itemTable + " P "
         + "where P.I_CLASS=2 and P.PARENT_ID=N.ID and P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' "
         + "and P.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName + "')" : "select * from "
         + itemTable + " N where N.I_CLASS=1 and NOT EXISTS " + "(select * from " + itemTable
         + " P where P.I_CLASS=2 and P.PARENT_ID=N.ID " + "and P.NAME='[http://www.jcp.org/jcr/1.0]primaryType')",
         new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME},
         "A node that doesn't have primary type property", new NodeRemover(jdbcDataContainer.getConnectionFactory(),
            jdbcDataContainer.containerConfig, nodeTypeManager)));

      itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + valueTable
         + " V where NOT EXISTS(select * from " + itemTable + " P " + "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)"
         : "select * from " + valueTable + " V where NOT EXISTS(select * from " + itemTable + " P "
            + "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)", new String[]{DBConstants.COLUMN_ID,
         DBConstants.COLUMN_VPROPERTY_ID}, "All value records that has not related property record",
         new ValueRecordsRemover(jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerConfig)));

      // The differences in the queries by DB dialect.
      if (jdbcDataContainer.containerConfig.dbDialect.startsWith(DBConstants.DB_DIALECT_SYBASE))
      {
         statement =
            singleDatabase ? "select V.* from " + valueTable + " V, " + itemTable
               + " I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
               + jdbcDataContainer.containerConfig.containerName
               + "' AND ((STORAGE_DESC is not null and not DATA like null))" : "select * from " + valueTable
               + " where (STORAGE_DESC is not null and not DATA like null)";
      }
      else if (jdbcDataContainer.containerConfig.dbDialect.startsWith(DBConstants.DB_DIALECT_ORACLE))
      {
         statement =
            singleDatabase ? "select V.* from " + valueTable + " V, " + itemTable
               + " I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
               + jdbcDataContainer.containerConfig.containerName
               + "' AND (STORAGE_DESC is not null and DATA is not null)" : "select * from " + valueTable
               + " where (STORAGE_DESC is not null and DATA is not null)";
      }
      else
      {
         statement =
            singleDatabase ? "select V.* from " + valueTable + " V, " + itemTable
               + " I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
               + jdbcDataContainer.containerConfig.containerName
               + "' AND ((STORAGE_DESC is not null and DATA is not null))" : "select * from " + valueTable
               + " where (STORAGE_DESC is not null and DATA is not null)";
      }
      itemsInspectionQuery.add(new InspectionQuery(statement, new String[]{DBConstants.COLUMN_ID},
         "Incorrect VALUE records. Both fields STORAGE_DESC and DATA contain not null value.", new DummyRepair()));

      itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable
         + " I where I.ID = I.PARENT_ID and I.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
         + "' and I.NAME <> '" + Constants.ROOT_PARENT_NAME + "'" : "select * from " + itemTable
         + " I where I.ID = I.PARENT_ID and I.NAME <> '" + Constants.ROOT_PARENT_NAME + "'", new String[]{
         DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME}, "An item is its own parent.",
         new RootAsParentAssigner(jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerConfig)));

      itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable
         + " I where I.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
         + "' and EXISTS (select * from " + itemTable + " J WHERE I.CONTAINER_NAME = J.CONTAINER_NAME and"
         + " I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
         + " and I.VERSION != J.VERSION and I.I_CLASS = 2)" : "select * from " + itemTable
         + " I where EXISTS (select * from " + itemTable + " J"
         + " WHERE I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
         + " and I.VERSION != J.VERSION and I.I_CLASS = 2)", new String[]{DBConstants.COLUMN_ID,
         DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME, DBConstants.COLUMN_VERSION, DBConstants.COLUMN_CLASS,
         DBConstants.COLUMN_INDEX}, "Several versions of same item.", new EarlierVersionsRemover(jdbcDataContainer
         .getConnectionFactory(), jdbcDataContainer.containerConfig)));

      itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable + " P, " + valueTable
         + " V where P.ID=V.PROPERTY_ID and P.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
         + "' and P.P_TYPE=9 and NOT EXISTS (select * from " + refTable + " R where P.ID=R.PROPERTY_ID)"
         : "select * from " + itemTable + " P, " + valueTable
            + " V where P.ID=V.PROPERTY_ID and P.P_TYPE=9 and NOT EXISTS " + "(select * from " + refTable
            + " R where P.ID=R.PROPERTY_ID)", new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID,
         DBConstants.COLUMN_NAME}, "Reference properties without reference records", new PropertyRemover(
         jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerConfig, nodeTypeManager)));
   }
View Full Code Here

         statement = statement.replace("?", "0");
      }

      itemsInspectionQuery.add(new InspectionQuery(statement, new String[]{DBConstants.COLUMN_ID,
         DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME},
         "A node that has a single valued properties with nothing declared in the VALUE table.", new PropertyRemover(
            jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerConfig, nodeTypeManager)));

      itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable
         + " N where N.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
         + "' and N.I_CLASS=1 and NOT EXISTS (select * from " + itemTable + " P "
         + "where P.I_CLASS=2 and P.PARENT_ID=N.ID and P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' "
         + "and P.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName + "')" : "select * from "
         + itemTable + " N where N.I_CLASS=1 and NOT EXISTS " + "(select * from " + itemTable
         + " P where P.I_CLASS=2 and P.PARENT_ID=N.ID " + "and P.NAME='[http://www.jcp.org/jcr/1.0]primaryType')",
         new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME},
         "A node that doesn't have primary type property", new NodeRemover(jdbcDataContainer.getConnectionFactory(),
            jdbcDataContainer.containerConfig, nodeTypeManager)));

      itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + valueTable
         + " V where NOT EXISTS(select * from " + itemTable + " P " + "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)"
         : "select * from " + valueTable + " V where NOT EXISTS(select * from " + itemTable + " P "
            + "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)", new String[]{DBConstants.COLUMN_ID,
         DBConstants.COLUMN_VPROPERTY_ID}, "All value records that has not related property record",
         new ValueRecordsRemover(jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerConfig)));

      // The differences in the queries by DB dialect.
      if (jdbcDataContainer.containerConfig.dbDialect.startsWith(DBConstants.DB_DIALECT_SYBASE))
      {
         statement =
            singleDatabase ? "select V.* from " + valueTable + " V, " + itemTable
               + " I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
               + jdbcDataContainer.containerConfig.containerName
               + "' AND ((STORAGE_DESC is not null and not DATA like null))" : "select * from " + valueTable
               + " where (STORAGE_DESC is not null and not DATA like null)";
      }
      else if (jdbcDataContainer.containerConfig.dbDialect.startsWith(DBConstants.DB_DIALECT_ORACLE))
      {
         statement =
            singleDatabase ? "select V.* from " + valueTable + " V, " + itemTable
               + " I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
               + jdbcDataContainer.containerConfig.containerName
               + "' AND (STORAGE_DESC is not null and DATA is not null)" : "select * from " + valueTable
               + " where (STORAGE_DESC is not null and DATA is not null)";
      }
      else
      {
         statement =
            singleDatabase ? "select V.* from " + valueTable + " V, " + itemTable
               + " I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
               + jdbcDataContainer.containerConfig.containerName
               + "' AND ((STORAGE_DESC is not null and DATA is not null))" : "select * from " + valueTable
               + " where (STORAGE_DESC is not null and DATA is not null)";
      }
      itemsInspectionQuery.add(new InspectionQuery(statement, new String[]{DBConstants.COLUMN_ID},
         "Incorrect VALUE records. Both fields STORAGE_DESC and DATA contain not null value.", new DummyRepair()));

      itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable
         + " I where I.ID = I.PARENT_ID and I.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
         + "' and I.NAME <> '" + Constants.ROOT_PARENT_NAME + "'" : "select * from " + itemTable
         + " I where I.ID = I.PARENT_ID and I.NAME <> '" + Constants.ROOT_PARENT_NAME + "'", new String[]{
         DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME}, "An item is its own parent.",
         new RootAsParentAssigner(jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerConfig)));

      itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable
         + " I where I.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
         + "' and EXISTS (select * from " + itemTable + " J WHERE I.CONTAINER_NAME = J.CONTAINER_NAME and"
         + " I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
         + " and I.VERSION != J.VERSION and I.I_CLASS = 2)" : "select * from " + itemTable
         + " I where EXISTS (select * from " + itemTable + " J"
         + " WHERE I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
         + " and I.VERSION != J.VERSION and I.I_CLASS = 2)", new String[]{DBConstants.COLUMN_ID,
         DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME, DBConstants.COLUMN_VERSION, DBConstants.COLUMN_CLASS,
         DBConstants.COLUMN_INDEX}, "Several versions of same item.", new EarlierVersionsRemover(jdbcDataContainer
         .getConnectionFactory(), jdbcDataContainer.containerConfig)));

      itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable + " P, " + valueTable
         + " V where P.ID=V.PROPERTY_ID and P.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
         + "' and P.P_TYPE=9 and NOT EXISTS (select * from " + refTable + " R where P.ID=R.PROPERTY_ID)"
         : "select * from " + itemTable + " P, " + valueTable
            + " V where P.ID=V.PROPERTY_ID and P.P_TYPE=9 and NOT EXISTS " + "(select * from " + refTable
            + " R where P.ID=R.PROPERTY_ID)", new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID,
         DBConstants.COLUMN_NAME}, "Reference properties without reference records", new PropertyRemover(
         jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerConfig, nodeTypeManager)));
   }
View Full Code Here

         statement = statement.replace("?", "0");
      }

      itemsInspectionQuery.add(new InspectionQuery(statement, new String[]{DBConstants.COLUMN_ID,
         DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME},
         "A node that has a single valued properties with nothing declared in the VALUE table.", new PropertyRemover(
            jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerConfig, nodeTypeManager)));

      itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable
         + " N where N.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
         + "' and N.I_CLASS=1 and NOT EXISTS (select * from " + itemTable + " P "
         + "where P.I_CLASS=2 and P.PARENT_ID=N.ID and P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' "
         + "and P.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName + "')" : "select * from "
         + itemTable + " N where N.I_CLASS=1 and NOT EXISTS " + "(select * from " + itemTable
         + " P where P.I_CLASS=2 and P.PARENT_ID=N.ID " + "and P.NAME='[http://www.jcp.org/jcr/1.0]primaryType')",
         new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME},
         "A node that doesn't have primary type property", new NodeRemover(jdbcDataContainer.getConnectionFactory(),
            jdbcDataContainer.containerConfig, nodeTypeManager)));

      itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + valueTable
         + " V where NOT EXISTS(select * from " + itemTable + " P " + "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)"
         : "select * from " + valueTable + " V where NOT EXISTS(select * from " + itemTable + " P "
            + "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)", new String[]{DBConstants.COLUMN_ID,
         DBConstants.COLUMN_VPROPERTY_ID}, "All value records that has not related property record",
         new ValueRecordsRemover(jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerConfig)));

      // The differences in the queries by DB dialect.
      if (jdbcDataContainer.containerConfig.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE))
      {
         statement =
            singleDatabase ? "select V.* from " + valueTable + " V, " + itemTable
               + " I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
               + jdbcDataContainer.containerConfig.containerName
               + "' AND ((STORAGE_DESC is not null and not DATA like null))" : "select * from " + valueTable
               + " where (STORAGE_DESC is not null and not DATA like null)";
      }
      else if (jdbcDataContainer.containerConfig.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLE)
         || jdbcDataContainer.containerConfig.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLEOCI))
      {
         statement =
            singleDatabase ? "select V.* from " + valueTable + " V, " + itemTable
               + " I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
               + jdbcDataContainer.containerConfig.containerName
               + "' AND (STORAGE_DESC is not null and DATA is not null)" : "select * from " + valueTable
               + " where (STORAGE_DESC is not null and DATA is not null)";
      }
      else
      {
         statement =
            singleDatabase ? "select V.* from " + valueTable + " V, " + itemTable
               + " I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
               + jdbcDataContainer.containerConfig.containerName
               + "' AND ((STORAGE_DESC is not null and DATA is not null))" : "select * from " + valueTable
               + " where (STORAGE_DESC is not null and DATA is not null)";
      }
      itemsInspectionQuery.add(new InspectionQuery(statement, new String[]{DBConstants.COLUMN_ID},
         "Incorrect VALUE records. Both fields STORAGE_DESC and DATA contain not null value.", new DummyRepair()));

      itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable
         + " I where I.ID = I.PARENT_ID and I.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
         + "' and I.NAME <> '" + Constants.ROOT_PARENT_NAME + "'" : "select * from " + itemTable
         + " I where I.ID = I.PARENT_ID and I.NAME <> '" + Constants.ROOT_PARENT_NAME + "'", new String[]{
         DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME}, "An item is its own parent.",
         new RootAsParentAssigner(jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerConfig)));

      itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable
         + " I where I.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
         + "' and EXISTS (select * from " + itemTable + " J WHERE I.CONTAINER_NAME = J.CONTAINER_NAME and"
         + " I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
         + " and I.VERSION != J.VERSION and I.I_CLASS = 2)" : "select * from " + itemTable
         + " I where EXISTS (select * from " + itemTable + " J"
         + " WHERE I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
         + " and I.VERSION != J.VERSION and I.I_CLASS = 2)", new String[]{DBConstants.COLUMN_ID,
         DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME, DBConstants.COLUMN_VERSION, DBConstants.COLUMN_CLASS,
         DBConstants.COLUMN_INDEX}, "Several versions of same item.", new EarlierVersionsRemover(jdbcDataContainer
         .getConnectionFactory(), jdbcDataContainer.containerConfig)));

      itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable + " P, " + valueTable
         + " V where P.ID=V.PROPERTY_ID and P.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
         + "' and P.P_TYPE=9 and NOT EXISTS (select * from " + refTable + " R where P.ID=R.PROPERTY_ID)"
         : "select * from " + itemTable + " P, " + valueTable
            + " V where P.ID=V.PROPERTY_ID and P.P_TYPE=9 and NOT EXISTS " + "(select * from " + refTable
            + " R where P.ID=R.PROPERTY_ID)", new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID,
         DBConstants.COLUMN_NAME}, "Reference properties without reference records", new PropertyRemover(
         jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerConfig, nodeTypeManager)));
   }
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.impl.checker.PropertyRemover

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.