Search in sources :

Example 1 with VersionableRelationship

use of org.vcell.util.document.VersionableRelationship in project vcell by virtualcell.

the class DbDriver method findAllReferences.

/**
 * This method was created in VisualAge.
 * @return java.util.Hashtable
 */
private static void findAllReferences(java.sql.Connection con, VersionableTypeVersion vtv, VersionableFamily refs) throws DataAccessException, SQLException {
    // Get VersionableTypes(tables) which possibly have references to argument vType
    Vector<VersionRef> possibleRefs = VersionTable.getReferencingVersionableTypes(vtv.getVType());
    Enumeration<VersionRef> enum1 = possibleRefs.elements();
    UserTable userTable = UserTable.table;
    while (enum1.hasMoreElements()) {
        VersionRef vr = enum1.nextElement();
        // BEGIN check VersionableType for references to versionKey
        String sql = null;
        VersionTable table = VersionTable.getVersionTable(vr.getVType());
        if (vr.getLinkField() == null) {
            // 
            // direct link between versionable types
            // 
            sql = "SELECT " + table.id.getQualifiedColName() + "," + table.name.getQualifiedColName() + "," + table.ownerRef.getQualifiedColName() + "," + table.privacy.getQualifiedColName() + "," + table.versionBranchPointRef.getQualifiedColName() + "," + table.versionDate.getQualifiedColName() + "," + table.versionFlag.getQualifiedColName() + "," + table.versionAnnot.getQualifiedColName() + "," + table.versionBranchID.getQualifiedColName() + "," + userTable.userid.getQualifiedColName() + " FROM " + table.getTableName() + "," + userTable.getTableName() + " WHERE " + vr.getRefField().getQualifiedColName() + " = " + vtv.getVersion().getVersionKey() + " AND " + table.ownerRef.getQualifiedColName() + " = " + userTable.getTableName() + "." + userTable.id;
        } else {
            // 
            // indirect link between versionable types (Link Table ... e.g. BioModelSimulationLinkTable)
            // 
            sql = "SELECT " + table.id.getQualifiedColName() + "," + table.name.getQualifiedColName() + "," + table.ownerRef.getQualifiedColName() + "," + table.privacy.getQualifiedColName() + "," + table.versionBranchPointRef.getQualifiedColName() + "," + table.versionDate.getQualifiedColName() + "," + table.versionFlag.getQualifiedColName() + "," + table.versionAnnot.getQualifiedColName() + "," + table.versionBranchID.getQualifiedColName() + "," + userTable.userid.getQualifiedColName() + " FROM " + table.getTableName() + "," + userTable.getTableName() + "," + vr.getLinkField().getTableName() + " WHERE " + vr.getRefField().getQualifiedColName() + " = " + vtv.getVersion().getVersionKey() + " AND " + vr.getLinkField().getQualifiedColName() + " = " + table.id.getQualifiedColName() + " AND " + table.ownerRef.getQualifiedColName() + " = " + userTable.id.getQualifiedColName();
        }
        java.sql.Statement stmt = con.createStatement();
        Vector<VersionableTypeVersion> allReferencingVTV = new Vector<VersionableTypeVersion>();
        try {
            // Get KeyValues from statement and put into Vector, so we can close statement(good idea because we are recursive)
            java.sql.ResultSet rset = stmt.executeQuery(sql);
            while (rset.next()) {
                try {
                    BigDecimal groupid = rset.getBigDecimal(VersionTable.privacy_ColumnName);
                    Version version = VersionTable.getVersion(rset, getGroupAccessFromGroupID(con, groupid));
                    VersionableTypeVersion referencingVTV = new VersionableTypeVersion(vr.getVType(), version);
                    allReferencingVTV.addElement(referencingVTV);
                } catch (Throwable e) {
                    throw new DataAccessException(e.getMessage());
                }
            }
        } finally {
            stmt.close();
        }
        // 
        for (int c = 0; c < allReferencingVTV.size(); c += 1) {
            VersionableTypeVersion referencingVTV = allReferencingVTV.elementAt(c);
            // 
            // Add VersionableRelationship to dependants of refs
            // 
            refs.addDependantRelationship(new VersionableRelationship(referencingVTV, vtv));
            // 
            // Check referencingVTV for references to it(Recursion)
            // 
            findAllReferences(con, referencingVTV, refs);
        }
    }
}
Also used : VersionableTypeVersion(org.vcell.util.document.VersionableTypeVersion) BigDecimal(java.math.BigDecimal) Version(org.vcell.util.document.Version) VersionableTypeVersion(org.vcell.util.document.VersionableTypeVersion) ResultSet(java.sql.ResultSet) Statement(java.sql.Statement) VersionableRelationship(org.vcell.util.document.VersionableRelationship) Vector(java.util.Vector) DataAccessException(org.vcell.util.DataAccessException)

Example 2 with VersionableRelationship

use of org.vcell.util.document.VersionableRelationship in project vcell by virtualcell.

the class DependencyTest method main.

/**
 * Starts the application.
 * @param args an array of command-line arguments
 */
public static void main(java.lang.String[] args) {
    if (args.length != 2) {
        throw new RuntimeException("Usage: DependencyTest VersionableType.toString() keyValue.toString()");
    }
    java.sql.Connection con = null;
    try {
        String versionableTypeS = args[0];
        String keyValueS = args[1];
        // new cbit.sql.KeyValue("1368");
        org.vcell.util.document.KeyValue rootKey = new org.vcell.util.document.KeyValue(keyValueS);
        // cbit.sql.VersionableType.VCImage;
        org.vcell.util.document.VersionableType rootType = null;
        if (VersionableType.VCImage.toString().equals(versionableTypeS)) {
            rootType = VersionableType.VCImage;
        } else if (VersionableType.Geometry.toString().equals(versionableTypeS)) {
            rootType = VersionableType.Geometry;
        } else if (VersionableType.Model.toString().equals(versionableTypeS)) {
            rootType = VersionableType.Model;
        } else if (VersionableType.MathDescription.toString().equals(versionableTypeS)) {
            rootType = VersionableType.MathDescription;
        } else if (VersionableType.SimulationContext.toString().equals(versionableTypeS)) {
            rootType = VersionableType.SimulationContext;
        } else {
            throw new RuntimeException("Improper argument for VersionableType " + versionableTypeS);
        }
        Class.forName("oracle.jdbc.driver.OracleDriver");
        String url = "jdbc:oracle:thin:@nrcamdb.uchc.edu:1521:orc0";
        con = java.sql.DriverManager.getConnection(url, "nrcamdbdev", "bogus");
        System.out.println("Search for References to " + rootType.toString() + " id=" + rootKey.toString());
        VersionableFamily vf = cbit.vcell.modeldb.DbDriver.getAllReferences(con, rootType, rootKey);
        VersionableRelationship[] dependants = vf.getDependantRelationships();
        for (int c = 0; c < dependants.length; c += 1) {
            VersionableRelationship verrel = dependants[c];
            VersionableTypeVersion from = verrel.from();
            VersionableTypeVersion to = verrel.to();
            System.out.println(from.getVType() + " " + from.getVersion().getVersionKey() + "   ==>   " + to.getVType() + " " + to.getVersion().getVersionKey());
        }
        System.out.println("------------------Top Down List-------------------");
        VersionableTypeVersion[] topDown = vf.getDependantsTopDown();
        byte[] spaces = { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 };
        for (int c = 0; c < topDown.length; c += 1) {
            System.out.print(topDown[c].getVType());
            System.out.write(spaces, 0, 30 - topDown[c].getVType().toString().length());
            System.out.print(topDown[c].getVersion().getName());
            System.out.write(spaces, 0, 40 - topDown[c].getVersion().getName().length());
            System.out.println(topDown[c].getVersion().getVersionKey());
        }
    } catch (Throwable e) {
        e.printStackTrace(System.out);
    } finally {
        try {
            if (con != null) {
                con.close();
            }
        } catch (java.sql.SQLException e) {
        }
    }
}
Also used : VersionableFamily(org.vcell.util.document.VersionableFamily) VersionableTypeVersion(org.vcell.util.document.VersionableTypeVersion) VersionableType(org.vcell.util.document.VersionableType) VersionableRelationship(org.vcell.util.document.VersionableRelationship)

Example 3 with VersionableRelationship

use of org.vcell.util.document.VersionableRelationship in project vcell by virtualcell.

the class DatabaseWindowManager method findModelsUsingSelectedGeometry.

/**
 * Insert the method's description here.
 * Creation date: (11/6/2005 9:15:25 AM)
 */
public void findModelsUsingSelectedGeometry() {
    AsynchClientTask findModelsTask = new AsynchClientTask("Finding Models...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            VCDocumentInfo selectedDocument = getPanelSelection();
            if (!(selectedDocument instanceof GeometryInfo)) {
                PopupGenerator.showErrorDialog(DatabaseWindowManager.this, "DatabaseWindowManager.findModelsUsingSelectedGeometry expected a GeometryInfo\nbut got type=" + selectedDocument.getClass().getName() + " instead");
                return;
            }
            ReferenceQuerySpec rqs = new ReferenceQuerySpec(VersionableType.Geometry, selectedDocument.getVersion().getVersionKey());
            // try{
            ReferenceQueryResult rqr = getRequestManager().getDocumentManager().findReferences(rqs);
            // cbit.vcell.modeldb.VersionableTypeVersion[] children = (rqr.getVersionableFamily().bChildren()?rqr.getVersionableFamily().getUniqueChildren():null);
            VersionableTypeVersion[] dependants = (rqr.getVersionableFamily().bDependants() ? rqr.getVersionableFamily().getUniqueDependants() : null);
            // System.out.println("\n");
            // if(children != null){
            // for(int i=0;i<children.length;i+= 1){
            // if( children[i] != rqr.getVersionableFamily().getTarget()){
            // System.out.println("Children "+children[i]+" key="+children[i].getVersion().getVersionKey()+" date="+children[i].getVersion().getDate());
            // }
            // }
            // }else{
            // System.out.println("No Children");
            // }
            // if(dependants != null){
            // for(int i=0;i<dependants.length;i+= 1){
            // if( dependants[i] != rqr.getVersionableFamily().getTarget()){
            // System.out.println("Dependants "+dependants[i]+" key="+dependants[i].getVersion().getVersionKey()+" date="+dependants[i].getVersion().getDate());
            // }
            // }
            // }else{
            // System.out.println("No Dependants");
            // }
            // System.out.println("\nVersionableRelationships");
            // cbit.vcell.modeldb.VersionableRelationship[] vrArr = rqr.getVersionableFamily().getDependantRelationships();
            // for(int i=0;i<vrArr.length;i+= 1){
            // System.out.println(vrArr[i].from() +" -> "+vrArr[i].to());
            // }
            Hashtable<String, Object> choices = new Hashtable<String, Object>();
            if (dependants != null) {
                // System.out.println("\nMajor Relationships");
                for (int i = 0; i < dependants.length; i += 1) {
                    boolean isBioModel = dependants[i].getVType().equals(VersionableType.BioModelMetaData);
                    boolean isTop = isBioModel || dependants[i].getVType().equals(VersionableType.MathModelMetaData);
                    if (isTop) {
                        VersionableRelationship[] vrArr2 = rqr.getVersionableFamily().getDependantRelationships();
                        for (int j = 0; j < vrArr2.length; j += 1) {
                            if ((vrArr2[j].from() == dependants[i]) && vrArr2[j].to().getVType().equals((isBioModel ? VersionableType.SimulationContext : VersionableType.MathDescription))) {
                                for (int k = 0; k < vrArr2.length; k += 1) {
                                    if ((vrArr2[k].from() == vrArr2[j].to()) && vrArr2[k].to().getVType().equals(VersionableType.Geometry)) {
                                        String s = (isBioModel ? "BioModel" : "MathModel") + "  " + "\"" + dependants[i].getVersion().getName() + "\"  (" + dependants[i].getVersion().getDate() + ")" + (isBioModel ? " (App=\"" + vrArr2[k].from().getVersion().getName() + "\")" : /*+" -> "*/
                                        "");
                                        // +" Geometry="+vrArr2[k].to().getVersion().getName()+" "+vrArr2[k].to().getVersion().getDate();
                                        choices.put(s, dependants[i]);
                                    // System.out.println(s);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (choices.size() > 0) {
                Object[] listObj = choices.keySet().toArray();
                Object o = DialogUtils.showListDialog(getComponent(), listObj, "Models Referencing Geometry (Select To Open) " + selectedDocument.getVersion().getName() + " " + selectedDocument.getVersion().getDate());
                if (o != null) {
                    VersionableTypeVersion v = (VersionableTypeVersion) choices.get(o);
                    // System.out.println(v);
                    if (v.getVType().equals(VersionableType.BioModelMetaData)) {
                        BioModelInfo bmi = getRequestManager().getDocumentManager().getBioModelInfo(v.getVersion().getVersionKey());
                        getRequestManager().openDocument(bmi, DatabaseWindowManager.this, true);
                    } else if (v.getVType().equals(VersionableType.MathModelMetaData)) {
                        MathModelInfo mmi = getRequestManager().getDocumentManager().getMathModelInfo(v.getVersion().getVersionKey());
                        getRequestManager().openDocument(mmi, DatabaseWindowManager.this, true);
                    }
                }
            } else {
                if (dependants == null) {
                    DialogUtils.showInfoDialog(getComponent(), "No Model references found.\n" + (rqr.getVersionableFamily().getTarget().getVersion().getFlag().isArchived() ? "Info: Not Deletable (key=" + rqr.getVersionableFamily().getTarget().getVersion().getVersionKey() + ") because legacy ARCHIVE set" : ""));
                } else {
                    DialogUtils.showInfoDialog(getComponent(), "No current Model references found.\n" + "Geometry has internal database references from\n" + "previously linked Model(s).\n" + "Not Deletable until database is culled (daily).");
                }
            // return;
            }
        // }catch(DataAccessException e){
        // DialogUtils.showErrorDialog(getComponent(), "Error find Geometry Model references\n"+e.getClass().getName()+"\n"+e.getMessage());
        // }
        }
    };
    ClientTaskDispatcher.dispatch(getComponent(), new Hashtable<String, Object>(), new AsynchClientTask[] { findModelsTask }, false);
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) VersionableTypeVersion(org.vcell.util.document.VersionableTypeVersion) ReferenceQueryResult(org.vcell.util.document.ReferenceQueryResult) Hashtable(java.util.Hashtable) BioModelInfo(org.vcell.util.document.BioModelInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) GeometryInfo(cbit.vcell.geometry.GeometryInfo) VersionableRelationship(org.vcell.util.document.VersionableRelationship) ReferenceQuerySpec(org.vcell.util.document.ReferenceQuerySpec)

Example 4 with VersionableRelationship

use of org.vcell.util.document.VersionableRelationship in project vcell by virtualcell.

the class FieldDataWindowManager method findReferencingModels.

public boolean findReferencingModels(final ExternalDataIdentifier targetExtDataID, boolean bShowReferencingModelsList) throws DataAccessException, UserCancelException {
    ReferenceQuerySpec rqs = new ReferenceQuerySpec(targetExtDataID);
    ReferenceQueryResult rqr = getRequestManager().getDocumentManager().findReferences(rqs);
    VersionableTypeVersion[] dependants = null;
    Hashtable<VersionableTypeVersion, String[]> choices = new Hashtable<VersionableTypeVersion, String[]>();
    boolean bDanglingReferences = false;
    VersionableType bioModelType = VersionableType.BioModelMetaData;
    VersionableType mathModelType = VersionableType.MathModelMetaData;
    if (rqr != null) {
        dependants = (rqr.getVersionableFamily().bDependants() ? rqr.getVersionableFamily().getUniqueDependants() : null);
        if (dependants != null) {
            for (int i = 0; i < dependants.length; i += 1) {
                boolean isBioModel = dependants[i].getVType().equals(bioModelType);
                boolean isTop = isBioModel || dependants[i].getVType().equals(mathModelType);
                if (isTop) {
                    VersionableRelationship[] vrArr2 = rqr.getVersionableFamily().getDependantRelationships();
                    for (int j = 0; j < vrArr2.length; j += 1) {
                        if ((vrArr2[j].from() == dependants[i]) && vrArr2[j].to().getVType().equals((isBioModel ? VersionableType.SimulationContext : VersionableType.MathDescription))) {
                            for (int k = 0; k < vrArr2.length; k += 1) {
                                boolean bAdd = false;
                                if (k == j && vrArr2[k].from().getVType().equals(mathModelType)) {
                                    bAdd = true;
                                }
                                if ((vrArr2[k].from() == vrArr2[j].to()) && vrArr2[k].to().getVType().equals(VersionableType.MathDescription)) {
                                    bAdd = true;
                                }
                                if (bAdd) {
                                    choices.put(dependants[i], new String[] { dependants[i].getVersion().getName(), (isBioModel ? bioModelType.getTypeName() : mathModelType.getTypeName()), (isBioModel ? vrArr2[k].from().getVersion().getName() : ""), dependants[i].getVersion().getVersionKey().toString() });
                                }
                            }
                        }
                    }
                }
            }
            bDanglingReferences = (choices.size() == 0);
        } else {
            bDanglingReferences = true;
        }
    }
    // FieldDataFileOperationResults fdfor = getRequestManager().getDocumentManager().fieldDataFileOperation(
    // FieldDataFileOperationSpec.createDependantFuncsFieldDataFileOperationSpec(targetExtDataID));
    FieldDataFileOperationResults fdfor = null;
    boolean bHasReferences = false;
    if (choices.size() > 0 || fdfor != null) {
        bHasReferences = true;
        if (bShowReferencingModelsList) {
            String[] columnNames = new String[] { "Model", "Type", "Description" };
            Vector<VersionableType> varTypeV = new Vector<VersionableType>();
            Vector<KeyValue> keyValV = new Vector<KeyValue>();
            Vector<String[]> choicesV = new Vector<String[]>();
            String[][] modelListData = choices.values().toArray(new String[0][0]);
            for (int i = 0; i < modelListData.length; i++) {
                choicesV.add(new String[] { modelListData[i][0], modelListData[i][1], "Model Variable - " + (modelListData[i][2].length() == 0 ? "" : "App='" + modelListData[i][2] + "'") + " version[" + modelListData[i][3] + "]" });
                varTypeV.add((modelListData[i][1].equals(bioModelType.getTypeName()) ? bioModelType : mathModelType));
                keyValV.add(new KeyValue(modelListData[i][3]));
            }
            for (int i = 0; fdfor != null && i < fdfor.dependantFunctionInfo.length; i++) {
                String functionNames = "";
                for (int j = 0; j < fdfor.dependantFunctionInfo[i].funcNames.length; j++) {
                    functionNames += (j > 0 ? "," : "") + fdfor.dependantFunctionInfo[i].funcNames[j];
                }
                choicesV.add(new String[] { fdfor.dependantFunctionInfo[i].referenceSourceName, fdfor.dependantFunctionInfo[i].referenceSourceType, "Data Viewer Function(s) '" + functionNames + "' - " + (fdfor.dependantFunctionInfo[i].applicationName == null ? "" : "App='" + fdfor.dependantFunctionInfo[i].applicationName + "' ") + (fdfor.dependantFunctionInfo[i].simulationName == null ? "" : "Sim='" + fdfor.dependantFunctionInfo[i].simulationName + "' ") + "version[" + fdfor.dependantFunctionInfo[i].refSourceVersionDate + "]" });
                if (fdfor.dependantFunctionInfo[i].referenceSourceType.equals(FieldDataFileOperationResults.FieldDataReferenceInfo.FIELDDATATYPENAME)) {
                    varTypeV.add(null);
                } else if (fdfor.dependantFunctionInfo[i].referenceSourceType.equals(bioModelType.getTypeName())) {
                    varTypeV.add(bioModelType);
                } else if (fdfor.dependantFunctionInfo[i].referenceSourceType.equals(mathModelType.getTypeName())) {
                    varTypeV.add(mathModelType);
                } else {
                    throw new IllegalArgumentException("Unknown reference source type " + fdfor.dependantFunctionInfo[i].referenceSourceType);
                }
                keyValV.add(fdfor.dependantFunctionInfo[i].refSourceVersionKey);
            }
            int[] selectionArr = PopupGenerator.showComponentOKCancelTableList(getComponent(), "References to Field Data (Select To Open) " + targetExtDataID.getName(), columnNames, choicesV.toArray(new String[0][0]), ListSelectionModel.SINGLE_SELECTION);
            if (selectionArr != null && selectionArr.length > 0) {
                if (varTypeV.elementAt(selectionArr[0]) != null) {
                    if (varTypeV.elementAt(selectionArr[0]).equals(bioModelType)) {
                        BioModelInfo bmi = getRequestManager().getDocumentManager().getBioModelInfo(keyValV.elementAt(selectionArr[0]));
                        getRequestManager().openDocument(bmi, FieldDataWindowManager.this, true);
                    } else if (varTypeV.elementAt(selectionArr[0]).equals(mathModelType)) {
                        MathModelInfo mmi = getRequestManager().getDocumentManager().getMathModelInfo(keyValV.elementAt(selectionArr[0]));
                        getRequestManager().openDocument(mmi, FieldDataWindowManager.this, true);
                    } else {
                        throw new IllegalArgumentException("Not expecting varType " + varTypeV.elementAt(selectionArr[0]));
                    }
                } else {
                    PopupGenerator.showInfoDialog(this, "use FiledDataManager to view FieldData '" + choicesV.elementAt(selectionArr[0])[0] + "'");
                }
            }
        }
    } else {
        if (!bDanglingReferences) {
            bHasReferences = false;
            if (bShowReferencingModelsList) {
                PopupGenerator.showInfoDialog(this, "No Model references found for Field Data " + targetExtDataID.getName());
            }
        } else {
            bHasReferences = true;
            if (bShowReferencingModelsList) {
                PopupGenerator.showInfoDialog(this, "No current Model references found.\n" + "Field Data has internal database references from\n" + "previously linked Model(s) that have been deleted.\n" + "Note: Field Data '" + targetExtDataID.getName() + "' is not deletable\n" + "until database is culled (daily).");
            }
        }
    }
    return bHasReferences;
}
Also used : FieldDataFileOperationResults(cbit.vcell.field.io.FieldDataFileOperationResults) KeyValue(org.vcell.util.document.KeyValue) VersionableTypeVersion(org.vcell.util.document.VersionableTypeVersion) ReferenceQueryResult(org.vcell.util.document.ReferenceQueryResult) Hashtable(java.util.Hashtable) BioModelInfo(org.vcell.util.document.BioModelInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) VersionableType(org.vcell.util.document.VersionableType) VersionableRelationship(org.vcell.util.document.VersionableRelationship) ReferenceQuerySpec(org.vcell.util.document.ReferenceQuerySpec) Vector(java.util.Vector)

Example 5 with VersionableRelationship

use of org.vcell.util.document.VersionableRelationship in project vcell by virtualcell.

the class DBTopLevel method findReferences.

/**
 * Insert the method's description here.
 * Creation date: (11/6/2005 10:16:41 AM)
 * @return cbit.vcell.modeldb.ReferenceQueryResult
 * @param user cbit.vcell.server.User
 * @param rqs cbit.vcell.modeldb.ReferenceQuerySpec
 */
ReferenceQueryResult findReferences(User user, ReferenceQuerySpec rqs2, boolean bEnableRetry) throws DataAccessException, java.sql.SQLException {
    Object lock = new Object();
    Connection con = conFactory.getConnection(lock);
    try {
        // Use MathDescription for search if ExternalData
        VersionableType rqsVType = null;
        KeyValue[] vTypeKeys = null;
        if (rqs2.isVersionableType()) {
            rqsVType = rqs2.getVersionableType();
            vTypeKeys = new KeyValue[] { rqs2.getKeyValue() };
        } else if (rqs2.isExternalDataIdentiferType()) {
            DbDriver.cleanupDeletedReferences(con, user, rqs2.getExternalDataIdentifier(), false);
            con.commit();
            rqsVType = VersionableType.MathDescription;
            vTypeKeys = getMathDescKeysForExternalData(rqs2.getKeyValue(), user, true);
            if (vTypeKeys == null || vTypeKeys.length == 0) {
                return null;
            }
        }
        if (rqsVType == null) {
            throw new DataAccessException("findAllReferences error: Couldn't determine Query type");
        }
        VersionableFamily finalVersionalbeFamily = null;
        for (int k = 0; k < vTypeKeys.length; k += 1) {
            // Find references
            VersionableFamily vf = getAllReferences(user, vTypeKeys[k], rqsVType, true);
            // Check permission
            if (vf.bDependants()) {
                VersionableTypeVersion[] vtvArr = vf.getUniqueDependants();
                for (int i = 0; i < vtvArr.length; i += 1) {
                    if (vtvArr[i].getVType().equals(VersionableType.BioModelMetaData)) {
                        Vector<VersionInfo> checkedVInfos = getVersionableInfos(user, vtvArr[i].getVersion().getVersionKey(), VersionableType.BioModelMetaData, false, true, true);
                        if (checkedVInfos == null || checkedVInfos.size() == 0) {
                            throw new DataAccessException("References Not Accessible");
                        }
                    } else if (vtvArr[i].getVType().equals(VersionableType.MathModelMetaData)) {
                        Vector<VersionInfo> checkedVInfos = getVersionableInfos(user, vtvArr[i].getVersion().getVersionKey(), VersionableType.MathModelMetaData, false, true, true);
                        if (checkedVInfos == null || checkedVInfos.size() == 0) {
                            throw new DataAccessException("References Not Accessible");
                        }
                    }
                }
            }
            if (finalVersionalbeFamily == null) {
                finalVersionalbeFamily = vf;
            } else {
                VersionableRelationship[] versRelArr = vf.getDependantRelationships();
                for (int r = 0; r < versRelArr.length; r += 1) {
                    finalVersionalbeFamily.addDependantRelationship(versRelArr[r]);
                }
            }
        }
        return new ReferenceQueryResult(finalVersionalbeFamily);
    } catch (Throwable e) {
        lg.error(e.getMessage(), e);
        if (bEnableRetry && isBadConnection(con)) {
            conFactory.failed(con, lock);
            return findReferences(user, rqs2, false);
        } else {
            handle_DataAccessException_SQLException(e);
            // never gets here;
            return null;
        }
    } finally {
        conFactory.release(con, lock);
    }
}
Also used : KeyValue(org.vcell.util.document.KeyValue) VersionableFamily(org.vcell.util.document.VersionableFamily) VersionableTypeVersion(org.vcell.util.document.VersionableTypeVersion) ReferenceQueryResult(org.vcell.util.document.ReferenceQueryResult) Connection(java.sql.Connection) VersionableType(org.vcell.util.document.VersionableType) VersionInfo(org.vcell.util.document.VersionInfo) VersionableRelationship(org.vcell.util.document.VersionableRelationship) Vector(java.util.Vector) DataAccessException(org.vcell.util.DataAccessException)

Aggregations

VersionableRelationship (org.vcell.util.document.VersionableRelationship)6 VersionableTypeVersion (org.vcell.util.document.VersionableTypeVersion)6 Vector (java.util.Vector)4 DataAccessException (org.vcell.util.DataAccessException)3 ReferenceQueryResult (org.vcell.util.document.ReferenceQueryResult)3 VersionableType (org.vcell.util.document.VersionableType)3 BigDecimal (java.math.BigDecimal)2 ResultSet (java.sql.ResultSet)2 Statement (java.sql.Statement)2 Hashtable (java.util.Hashtable)2 BioModelInfo (org.vcell.util.document.BioModelInfo)2 KeyValue (org.vcell.util.document.KeyValue)2 MathModelInfo (org.vcell.util.document.MathModelInfo)2 ReferenceQuerySpec (org.vcell.util.document.ReferenceQuerySpec)2 Version (org.vcell.util.document.Version)2 VersionableFamily (org.vcell.util.document.VersionableFamily)2 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1 FieldDataFileOperationResults (cbit.vcell.field.io.FieldDataFileOperationResults)1 GeometryInfo (cbit.vcell.geometry.GeometryInfo)1 Connection (java.sql.Connection)1