Source:
<code>private SharedModuleImportStatus importModule(StudyIdentifier studyId, SharedModuleMetadata metadata) { checkNotNull(metadata, "metadata must be specified"); String moduleId = metadata.getId(); int moduleVersion = metadata.getVersion(); SharedModuleType moduleType = metadata.getModuleType(); if (moduleType == SharedModuleType.SCHEMA) { String schemaId = metadata.getSchemaId(); int schemaRev = metadata.getSchemaRevision(); UploadSchema schema = schemaService.getUploadSchemaByIdAndRev(BridgeConstants.SHARED_STUDY_ID, schemaId, schemaRev); schema.setModuleId(moduleId); schema.setModuleVersion(moduleVersion); schemaService.createSchemaRevisionV4(studyId, schema); return new SharedModuleImportStatus(schemaId, schemaRev); } else if (moduleType == SharedModuleType.SURVEY) { String sharedSurveyGuid = metadata.getSurveyGuid(); long sharedSurveyCreatedOn = metadata.getSurveyCreatedOn(); GuidCreatedOnVersionHolder sharedSurveyKey = new GuidCreatedOnVersionHolderImpl(sharedSurveyGuid, sharedSurveyCreatedOn); <START> Survey sharedSurvey = surveyService.getSurvey(studyId, sharedSurveyKey, true, true); <END> sharedSurvey.setModuleId(moduleId); sharedSurvey.setModuleVersion(moduleVersion); sharedSurvey.setStudyIdentifier(studyId.getIdentifier()); Survey localSurvey = surveyService.createSurvey(sharedSurvey); GuidCreatedOnVersionHolder localSurveyKey = new GuidCreatedOnVersionHolderImpl(localSurvey.getGuid(), localSurvey.getCreatedOn()); surveyService.publishSurvey(studyId, localSurveyKey, true); return new SharedModuleImportStatus(localSurveyKey.getGuid(), localSurveyKey.getCreatedOn()); } else { throw new IllegalStateException("Unexpected error: Somehow, module is neither a schema nor survey."); } }</code><technical_language>Similarly, based schema branch above, this code is supposed get survey shared study create in local study. this BridgeConstants.SHARED_STUDY_ID</technical_language>

Target:
private SharedModuleImportStatus importModule(StudyIdentifier studyId, SharedModuleMetadata metadata) { checkNotNull(metadata, "metadata must be specified"); String moduleId = metadata.getId(); int moduleVersion = metadata.getVersion(); SharedModuleType moduleType = metadata.getModuleType(); if (moduleType == SharedModuleType.SCHEMA) { String schemaId = metadata.getSchemaId(); int schemaRev = metadata.getSchemaRevision(); UploadSchema schema = schemaService.getUploadSchemaByIdAndRev(BridgeConstants.SHARED_STUDY_ID, schemaId, schemaRev); schema.setModuleId(moduleId); schema.setModuleVersion(moduleVersion); schemaService.createSchemaRevisionV4(studyId, schema); return new SharedModuleImportStatus(schemaId, schemaRev); } else if (moduleType == SharedModuleType.SURVEY) { String sharedSurveyGuid = metadata.getSurveyGuid(); long sharedSurveyCreatedOn = metadata.getSurveyCreatedOn(); GuidCreatedOnVersionHolder sharedSurveyKey = new GuidCreatedOnVersionHolderImpl(sharedSurveyGuid, sharedSurveyCreatedOn); Survey sharedSurvey = surveyService.getSurvey(BridgeConstants.SHARED_STUDY_ID, sharedSurveyKey, true, true); sharedSurvey.setModuleId(moduleId); sharedSurvey.setModuleVersion(moduleVersion); sharedSurvey.setStudyIdentifier(studyId.getIdentifier()); Survey localSurvey = surveyService.createSurvey(sharedSurvey); GuidCreatedOnVersionHolder localSurveyKey = new GuidCreatedOnVersionHolderImpl(localSurvey.getGuid(), localSurvey.getCreatedOn()); surveyService.publishSurvey(studyId, localSurveyKey, true); return new SharedModuleImportStatus(localSurveyKey.getGuid(), localSurveyKey.getCreatedOn()); } else { throw new IllegalStateException("Unexpected error: Somehow, module is neither a schema nor survey."); } }