/** * Return the proper instance of the interactor if the database is recognized. It returns null otherwise. * @param database : the database * @param name : the name * @return the proper instance of the interactor if the database is recognized. It returns null otherwise. */ public Interactor createInteractorFromDatabase(CvTerm database, String name){ if (database == null){ return null; } String databaseName = database.getShortName().toLowerCase().trim(); String databaseMI = database.getMIIdentifier(); if (databaseMI != null && this.deterministicInteractorIdMap.containsKey(databaseMI)){ InteractorCategory recognizedType = this.deterministicInteractorIdMap.get(databaseMI); return createInteractorFromRecognizedCategory(recognizedType, name, null); } else if (databaseMI == null && this.deterministicInteractorNameMap.containsKey(databaseName)){ InteractorCategory recognizedType = this.deterministicInteractorNameMap.get(databaseName); return createInteractorFromRecognizedCategory(recognizedType, name, null); } return null; }
/** * Return the proper instance of the interactor if the type is recognized and not null. It returns null otherwise. * @param type : the interactor type * @param name : shortName * @return the proper instance of the interactor if the type is recognized. It returns null otherwise. */ public Interactor createInteractorFromInteractorType(CvTerm type, String name){ if (type == null){ return null; } String typeName = type.getShortName().toLowerCase().trim(); String typeMI = type.getMIIdentifier(); if (typeMI != null && this.deterministicInteractorIdMap.containsKey(typeMI)){ InteractorCategory recognizedType = this.deterministicInteractorIdMap.get(typeMI); return createInteractorFromRecognizedCategory(recognizedType, name, type); } else if (typeMI == null && this.deterministicInteractorNameMap.containsKey(typeName)){ InteractorCategory recognizedType = this.deterministicInteractorNameMap.get(typeName); return createInteractorFromRecognizedCategory(recognizedType, name, type); } // we have a valid type that is not unknown or null else { return createInteractor(name, type); } }