idx
int64 0
41.2k
| question
stringlengths 74
4.04k
| target
stringlengths 7
750
|
|---|---|---|
35,400
|
private Status executeDebug ( Stmt . Debug stmt , CallStack frame , EnclosingScope scope ) { RValue . Array arr = executeExpression ( ARRAY_T , stmt . getOperand ( ) , frame ) ; for ( RValue item : arr . getElements ( ) ) { RValue . Int i = ( RValue . Int ) item ; char c = ( char ) i . intValue ( ) ; debug . print ( c ) ; } return Status . NEXT ; }
|
Execute a Debug statement at a given point in the function or method body . This will write the provided string out to the debug stream .
|
35,401
|
private Status executeFail ( Stmt . Fail stmt , CallStack frame , EnclosingScope scope ) { throw new AssertionError ( "Runtime fault occurred" ) ; }
|
Execute a fail statement at a given point in the function or method body . This will generate a runtime fault .
|
35,402
|
private Status executeIf ( Stmt . IfElse stmt , CallStack frame , EnclosingScope scope ) { RValue . Bool operand = executeExpression ( BOOL_T , stmt . getCondition ( ) , frame ) ; if ( operand == RValue . True ) { return executeBlock ( stmt . getTrueBranch ( ) , frame , scope ) ; } else if ( stmt . hasFalseBranch ( ) ) { return executeBlock ( stmt . getFalseBranch ( ) , frame , scope ) ; } else { return Status . NEXT ; } }
|
Execute an if statement at a given point in the function or method body . This will proceed done either the true or false branch .
|
35,403
|
private Status executeNamedBlock ( Stmt . NamedBlock stmt , CallStack frame , EnclosingScope scope ) { return executeBlock ( stmt . getBlock ( ) , frame , scope ) ; }
|
Execute a named block which is simply a block of statements .
|
35,404
|
private Status executeWhile ( Stmt . While stmt , CallStack frame , EnclosingScope scope ) { Status r ; do { RValue . Bool operand = executeExpression ( BOOL_T , stmt . getCondition ( ) , frame ) ; if ( operand == RValue . False ) { return Status . NEXT ; } r = executeBlock ( stmt . getBody ( ) , frame , scope ) ; } while ( r == Status . NEXT || r == Status . CONTINUE ) ; if ( r == Status . BREAK ) { return Status . NEXT ; } else { return r ; } }
|
Execute a While statement at a given point in the function or method body . This will loop over the body zero or more times .
|
35,405
|
private Status executeReturn ( Stmt . Return stmt , CallStack frame , EnclosingScope scope ) { Decl . Callable context = scope . getEnclosingScope ( FunctionOrMethodScope . class ) . getContext ( ) ; Tuple < Decl . Variable > returns = context . getReturns ( ) ; RValue [ ] values = executeExpressions ( stmt . getReturns ( ) , frame ) ; for ( int i = 0 ; i != returns . size ( ) ; ++ i ) { frame . putLocal ( returns . get ( i ) . getName ( ) , values [ i ] ) ; } return Status . RETURN ; }
|
Execute a Return statement at a given point in the function or method body
|
35,406
|
private Status executeSkip ( Stmt . Skip stmt , CallStack frame , EnclosingScope scope ) { return Status . NEXT ; }
|
Execute a skip statement at a given point in the function or method body
|
35,407
|
private Status executeSwitch ( Stmt . Switch stmt , CallStack frame , EnclosingScope scope ) { Tuple < Stmt . Case > cases = stmt . getCases ( ) ; Object value = executeExpression ( ANY_T , stmt . getCondition ( ) , frame ) ; for ( int i = 0 ; i != cases . size ( ) ; ++ i ) { Stmt . Case c = cases . get ( i ) ; Stmt . Block body = c . getBlock ( ) ; if ( c . isDefault ( ) ) { return executeBlock ( body , frame , scope ) ; } else { RValue [ ] values = executeExpressions ( c . getConditions ( ) , frame ) ; for ( RValue v : values ) { if ( v . equals ( value ) ) { return executeBlock ( body , frame , scope ) ; } } } } return Status . NEXT ; }
|
Execute a Switch statement at a given point in the function or method body
|
35,408
|
private Status executeVariableDeclaration ( Decl . Variable stmt , CallStack frame ) { if ( stmt . hasInitialiser ( ) ) { RValue value = executeExpression ( ANY_T , stmt . getInitialiser ( ) , frame ) ; frame . putLocal ( stmt . getName ( ) , value ) ; } return Status . NEXT ; }
|
Execute a variable declaration statement at a given point in the function or method body
|
35,409
|
private RValue executeConst ( Expr . Constant expr , CallStack frame ) { Value v = expr . getValue ( ) ; switch ( v . getOpcode ( ) ) { case ITEM_null : return RValue . Null ; case ITEM_bool : { Value . Bool b = ( Value . Bool ) v ; if ( b . get ( ) ) { return RValue . True ; } else { return RValue . False ; } } case ITEM_byte : { Value . Byte b = ( Value . Byte ) v ; return semantics . Byte ( b . get ( ) ) ; } case ITEM_int : { Value . Int i = ( Value . Int ) v ; return semantics . Int ( i . get ( ) ) ; } case ITEM_utf8 : { Value . UTF8 s = ( Value . UTF8 ) v ; byte [ ] bytes = s . get ( ) ; RValue [ ] elements = new RValue [ bytes . length ] ; for ( int i = 0 ; i != elements . length ; ++ i ) { elements [ i ] = semantics . Int ( BigInteger . valueOf ( bytes [ i ] ) ) ; } return semantics . Array ( elements ) ; } default : throw new RuntimeException ( "unknown value encountered (" + expr + ")" ) ; } }
|
Execute a Constant expression at a given point in the function or method body
|
35,410
|
private RValue executeConvert ( Expr . Cast expr , CallStack frame ) { RValue operand = executeExpression ( ANY_T , expr . getOperand ( ) , frame ) ; return operand . convert ( expr . getType ( ) ) ; }
|
Execute a type conversion at a given point in the function or method body
|
35,411
|
private boolean executeQuantifier ( int index , Expr . Quantifier expr , CallStack frame ) { Tuple < Decl . Variable > vars = expr . getParameters ( ) ; if ( index == vars . size ( ) ) { RValue . Bool r = executeExpression ( BOOL_T , expr . getOperand ( ) , frame ) ; boolean q = ( expr instanceof Expr . UniversalQuantifier ) ; return r . boolValue ( ) == q ; } else { Decl . Variable var = vars . get ( index ) ; RValue . Array range = executeExpression ( ARRAY_T , var . getInitialiser ( ) , frame ) ; RValue [ ] elements = range . getElements ( ) ; for ( int i = 0 ; i != elements . length ; ++ i ) { frame . putLocal ( var . getName ( ) , elements [ i ] ) ; boolean r = executeQuantifier ( index + 1 , expr , frame ) ; if ( ! r ) { return r ; } } return true ; } }
|
Execute one range of the quantifier or the body if no ranges remain .
|
35,412
|
private RValue executeVariableAccess ( Expr . VariableAccess expr , CallStack frame ) { Decl . Variable decl = expr . getVariableDeclaration ( ) ; return frame . getLocal ( decl . getName ( ) ) ; }
|
Execute a variable access expression at a given point in the function or method body . This simply loads the value of the given variable from the frame .
|
35,413
|
private RValue [ ] executeExpressions ( Tuple < Expr > expressions , CallStack frame ) { RValue [ ] [ ] results = new RValue [ expressions . size ( ) ] [ ] ; int count = 0 ; for ( int i = 0 ; i != expressions . size ( ) ; ++ i ) { results [ i ] = executeMultiReturnExpression ( expressions . get ( i ) , frame ) ; count += results [ i ] . length ; } RValue [ ] rs = new RValue [ count ] ; int j = 0 ; for ( int i = 0 ; i != expressions . size ( ) ; ++ i ) { Object [ ] r = results [ i ] ; System . arraycopy ( r , 0 , rs , j , r . length ) ; j += r . length ; } return rs ; }
|
Execute one or more expressions . This is slightly more complex than for the single expression case because of the potential to encounter positional operands . That is severals which arise from executing the same expression .
|
35,414
|
private RValue [ ] executeMultiReturnExpression ( Expr expr , CallStack frame ) { switch ( expr . getOpcode ( ) ) { case WyilFile . EXPR_indirectinvoke : return executeIndirectInvoke ( ( Expr . IndirectInvoke ) expr , frame ) ; case WyilFile . EXPR_invoke : return executeInvoke ( ( Expr . Invoke ) expr , frame ) ; case WyilFile . EXPR_constant : case WyilFile . EXPR_cast : case WyilFile . EXPR_recordaccess : case WyilFile . EXPR_recordborrow : case WyilFile . DECL_lambda : case WyilFile . EXPR_logicalexistential : case WyilFile . EXPR_logicaluniversal : default : RValue val = executeExpression ( ANY_T , expr , frame ) ; return new RValue [ ] { val } ; } }
|
Execute an expression which has the potential to return more than one result . Thus the return type must accommodate this by allowing zero or more returned values .
|
35,415
|
private RValue [ ] executeIndirectInvoke ( Expr . IndirectInvoke expr , CallStack frame ) { RValue . Lambda src = executeExpression ( LAMBDA_T , expr . getSource ( ) , frame ) ; RValue [ ] arguments = executeExpressions ( expr . getArguments ( ) , frame ) ; frame = src . getFrame ( ) ; extractParameters ( frame , arguments , src . getContext ( ) ) ; Stmt body = src . getBody ( ) ; if ( body instanceof Stmt . Block ) { executeBlock ( ( Stmt . Block ) body , frame , new FunctionOrMethodScope ( src . getContext ( ) ) ) ; return packReturns ( frame , src . getContext ( ) ) ; } else { RValue retval = executeExpression ( ANY_T , ( Expr ) body , frame ) ; return new RValue [ ] { retval } ; } }
|
Execute an IndirectInvoke bytecode instruction at a given point in the function or method body . This first checks the operand is a function reference and then generates a recursive call to execute the given function . If the function does not exist or is provided with the wrong number of arguments then a runtime fault will occur .
|
35,416
|
private RValue [ ] executeInvoke ( Expr . Invoke expr , CallStack frame ) { Decl . Callable decl = expr . getLink ( ) . getTarget ( ) ; RValue [ ] arguments = executeExpressions ( expr . getOperands ( ) , frame ) ; RValue [ ] rs = execute ( decl . getQualifiedName ( ) , decl . getType ( ) , frame , arguments ) ; return rs ; }
|
Execute an Invoke bytecode instruction at a given point in the function or method body . This generates a recursive call to execute the given function . If the function does not exist or is provided with the wrong number of arguments then a runtime fault will occur .
|
35,417
|
private LValue constructLVal ( Expr expr , CallStack frame ) { switch ( expr . getOpcode ( ) ) { case EXPR_arrayborrow : case EXPR_arrayaccess : { Expr . ArrayAccess e = ( Expr . ArrayAccess ) expr ; LValue src = constructLVal ( e . getFirstOperand ( ) , frame ) ; RValue . Int index = executeExpression ( INT_T , e . getSecondOperand ( ) , frame ) ; return new LValue . Array ( src , index ) ; } case EXPR_dereference : { Expr . Dereference e = ( Expr . Dereference ) expr ; LValue src = constructLVal ( e . getOperand ( ) , frame ) ; return new LValue . Dereference ( src ) ; } case EXPR_recordaccess : case EXPR_recordborrow : { Expr . RecordAccess e = ( Expr . RecordAccess ) expr ; LValue src = constructLVal ( e . getOperand ( ) , frame ) ; return new LValue . Record ( src , e . getField ( ) ) ; } case EXPR_variablemove : case EXPR_variablecopy : { Expr . VariableAccess e = ( Expr . VariableAccess ) expr ; Decl . Variable decl = e . getVariableDeclaration ( ) ; return new LValue . Variable ( decl . getName ( ) ) ; } } deadCode ( expr ) ; return null ; }
|
This method constructs a mutable representation of the lval . This is a bit strange but is necessary because values in the frame are currently immutable .
|
35,418
|
public static < T extends RValue > T checkType ( RValue operand , SyntacticItem context , Class < T > ... types ) { for ( int i = 0 ; i != types . length ; ++ i ) { if ( types [ i ] . isInstance ( operand ) ) { return ( T ) operand ; } } if ( operand == null ) { error ( "null operand" , context ) ; } else { error ( "operand returned " + operand . getClass ( ) . getName ( ) + ", expecting one of " + Arrays . toString ( types ) , context ) ; } return null ; }
|
Check that a given operand value matches an expected type .
|
35,419
|
public String getCompileTargetVersion ( ) { String javaVersion = "1.5" ; if ( mavenProject != null ) { String mavenCompilerTargetProperty = mavenProject . getProperties ( ) . getProperty ( "maven.compiler.target" ) ; if ( mavenCompilerTargetProperty != null ) { javaVersion = mavenCompilerTargetProperty ; } else { Plugin compilerPlugin = mavenProject . getPlugin ( "org.apache.maven.plugins:maven-compiler-plugin" ) ; if ( compilerPlugin != null ) { Xpp3Dom config = ( Xpp3Dom ) compilerPlugin . getConfiguration ( ) ; if ( config != null ) { Xpp3Dom domVersion = config . getChild ( "target" ) ; if ( domVersion != null ) { javaVersion = domVersion . getValue ( ) ; } } } } } return javaVersion ; }
|
Determines the Java compiler target version by inspecting the project s maven - compiler - plugin configuration .
|
35,420
|
public void run ( ) throws MojoExecutionException { try { runMojo . getAppEngineFactory ( ) . devServerRunSync ( ) . run ( configBuilder . buildRunConfiguration ( processServices ( ) , processProjectId ( ) ) ) ; } catch ( AppEngineException ex ) { throw new MojoExecutionException ( "Failed to run devappserver" , ex ) ; } }
|
Run the dev appserver .
|
35,421
|
public void runAsync ( int startSuccessTimeout ) throws MojoExecutionException { runMojo . getLog ( ) . info ( "Waiting " + startSuccessTimeout + " seconds for the Dev App Server to start." ) ; try { runMojo . getAppEngineFactory ( ) . devServerRunAsync ( startSuccessTimeout ) . run ( configBuilder . buildRunConfiguration ( processServices ( ) , processProjectId ( ) ) ) ; } catch ( AppEngineException ex ) { throw new RuntimeException ( ex ) ; } runMojo . getLog ( ) . info ( "Dev App Server started." ) ; runMojo . getLog ( ) . info ( "Use the 'mvn appengine:stop' command to stop the server." ) ; }
|
Run the dev appserver in async mode .
|
35,422
|
public String getProjectId ( ) { if ( project != null ) { if ( projectId != null ) { throw new IllegalArgumentException ( "Configuring <project> and <projectId> is not allowed, please use only <projectId>" ) ; } getLog ( ) . warn ( "Configuring <project> is deprecated," + " use <projectId> to set your Google Cloud ProjectId" ) ; return project ; } return projectId ; }
|
Return projectId from either projectId or project . Show deprecation message if configured as project and throw error if both specified .
|
35,423
|
public String getProjectId ( ) { try { String gcloudProject = gcloud . getConfig ( ) . getProject ( ) ; if ( gcloudProject == null || gcloudProject . trim ( ) . isEmpty ( ) ) { throw new RuntimeException ( "Project was not found in gcloud config" ) ; } return gcloudProject ; } catch ( CloudSdkNotFoundException | CloudSdkOutOfDateException | CloudSdkVersionFileException | IOException | ProcessHandlerException ex ) { throw new RuntimeException ( "Failed to read project from gcloud config" , ex ) ; } }
|
Return gcloud config property for project or error out if not found .
|
35,424
|
public void checkCloudSdk ( CloudSdk cloudSdk , String version ) throws CloudSdkVersionFileException , CloudSdkNotFoundException , CloudSdkOutOfDateException { if ( ! version . equals ( cloudSdk . getVersion ( ) . toString ( ) ) ) { throw new RuntimeException ( "Specified Cloud SDK version (" + version + ") does not match installed version (" + cloudSdk . getVersion ( ) + ")." ) ; } cloudSdk . validateCloudSdk ( ) ; }
|
Validates the cloud SDK installation
|
35,425
|
public Gcloud getGcloud ( ) { return Gcloud . builder ( buildCloudSdkMinimal ( ) ) . setMetricsEnvironment ( mojo . getArtifactId ( ) , mojo . getArtifactVersion ( ) ) . setCredentialFile ( mojo . getServiceAccountKeyFile ( ) ) . build ( ) ; }
|
Return a Gcloud instance using global configuration .
|
35,426
|
public List < Path > getServices ( ) { return ( services == null ) ? null : services . stream ( ) . map ( File :: toPath ) . collect ( Collectors . toList ( ) ) ; }
|
Return a list of Paths but can return also return an empty list or null .
|
35,427
|
public void deployAll ( ) throws MojoExecutionException { stager . stage ( ) ; ImmutableList . Builder < Path > computedDeployables = ImmutableList . builder ( ) ; Path appYaml = deployMojo . getStagingDirectory ( ) . resolve ( "app.yaml" ) ; if ( ! Files . exists ( appYaml ) ) { throw new MojoExecutionException ( "Failed to deploy all: could not find app.yaml." ) ; } deployMojo . getLog ( ) . info ( "deployAll: Preparing to deploy app.yaml" ) ; computedDeployables . add ( appYaml ) ; String [ ] configYamls = { "cron.yaml" , "dispatch.yaml" , "dos.yaml" , "index.yaml" , "queue.yaml" } ; for ( String yamlName : configYamls ) { Path yaml = appengineDirectory . resolve ( yamlName ) ; if ( Files . exists ( yaml ) ) { deployMojo . getLog ( ) . info ( "deployAll: Preparing to deploy " + yamlName ) ; computedDeployables . add ( yaml ) ; } } DeployConfiguration config = configBuilder . buildDeployConfiguration ( computedDeployables . build ( ) ) ; try { deployMojo . getAppEngineFactory ( ) . deployment ( ) . deploy ( config ) ; } catch ( AppEngineException ex ) { throw new MojoExecutionException ( "Failed to deploy" , ex ) ; } }
|
Deploy a single application and any found yaml configuration files .
|
35,428
|
public void deployCron ( ) throws MojoExecutionException { stager . stage ( ) ; try { deployMojo . getAppEngineFactory ( ) . deployment ( ) . deployCron ( configBuilder . buildDeployProjectConfigurationConfiguration ( appengineDirectory ) ) ; } catch ( AppEngineException ex ) { throw new MojoExecutionException ( "Failed to deploy" , ex ) ; } }
|
Deploy only cron . yaml .
|
35,429
|
static Function < String , ManagedCloudSdk > newManagedSdkFactory ( ) { return ( version ) -> { try { if ( Strings . isNullOrEmpty ( version ) ) { return ManagedCloudSdk . newManagedSdk ( ) ; } else { return ManagedCloudSdk . newManagedSdk ( new Version ( version ) ) ; } } catch ( UnsupportedOsException | BadCloudSdkVersionException ex ) { throw new RuntimeException ( ex ) ; } } ; }
|
for delayed instantiation because it can error unnecessarily
|
35,430
|
public List < Path > getExtraFilesDirectories ( ) { return extraFilesDirectories == null ? null : extraFilesDirectories . stream ( ) . map ( File :: toPath ) . collect ( Collectors . toList ( ) ) ; }
|
Returns a nullable list of Path to user configured extra files directories .
|
35,431
|
public String getUrl ( ) { if ( getRepositoryUrl ( ) == null ) return null ; return getRepositoryUrl ( ) + "/" + getGroupId ( ) . replace ( '.' , '/' ) + "/" + getArtifactId ( ) + "/" + getVersion ( ) + "/" + getFileNameWithBaseVersion ( ) ; }
|
URL of the artifact on the maven repository on which it has been deployed if it has been deployed .
|
35,432
|
public void stop ( Throwable cause ) throws Exception { stopping = true ; if ( task != null ) { task . cancel ( true ) ; } super . stop ( cause ) ; }
|
If the computation is going synchronously try to cancel that .
|
35,433
|
public static List < MavenArtifact > isSameCause ( MavenDependencyCause newMavenCause , Cause oldMavenCause ) { if ( ! ( oldMavenCause instanceof MavenDependencyCause ) ) { return Collections . emptyList ( ) ; } List < MavenArtifact > newCauseArtifacts = Preconditions . checkNotNull ( newMavenCause . getMavenArtifacts ( ) , "newMavenCause.mavenArtifacts should not be null" ) ; List < MavenArtifact > oldCauseArtifacts = Preconditions . checkNotNull ( ( ( MavenDependencyCause ) oldMavenCause ) . getMavenArtifacts ( ) , "oldMavenCause.mavenArtifacts should not be null" ) ; List < MavenArtifact > matchingArtifacts = new ArrayList < > ( ) ; for ( MavenArtifact newCauseArtifact : newCauseArtifacts ) { if ( newCauseArtifact . isSnapshot ( ) && newCauseArtifact . getVersion ( ) . contains ( "SNAPSHOT" ) ) { } else { for ( MavenArtifact oldCauseArtifact : oldCauseArtifacts ) { if ( Objects . equals ( newCauseArtifact . getGroupId ( ) , oldCauseArtifact . getGroupId ( ) ) && Objects . equals ( newCauseArtifact . getArtifactId ( ) , oldCauseArtifact . getArtifactId ( ) ) && Objects . equals ( newCauseArtifact . getVersion ( ) , oldCauseArtifact . getVersion ( ) ) && Objects . equals ( newCauseArtifact . getBaseVersion ( ) , oldCauseArtifact . getBaseVersion ( ) ) && Objects . equals ( newCauseArtifact . getClassifier ( ) , oldCauseArtifact . getClassifier ( ) ) && Objects . equals ( newCauseArtifact . getType ( ) , oldCauseArtifact . getType ( ) ) ) { matchingArtifacts . add ( newCauseArtifact ) ; } } } } return matchingArtifacts ; }
|
Return matching artifact if the given causes refer to common Maven artifact . Empty list if there are no matching artifact
|
35,434
|
private void setupJDK ( ) throws AbortException , IOException , InterruptedException { String jdkInstallationName = step . getJdk ( ) ; if ( StringUtils . isEmpty ( jdkInstallationName ) ) { console . println ( "[withMaven] using JDK installation provided by the build agent" ) ; return ; } if ( withContainer ) { LOGGER . log ( Level . FINE , "Ignoring JDK installation parameter: {0}" , jdkInstallationName ) ; console . println ( "WARNING: \"withMaven(){...}\" step running within a container," + " tool installations are not available see https://issues.jenkins-ci.org/browse/JENKINS-36159. " + "You have specified a JDK installation \"" + jdkInstallationName + "\", which will be ignored." ) ; return ; } console . println ( "[withMaven] using JDK installation " + jdkInstallationName ) ; JDK jdk = Jenkins . getInstance ( ) . getJDK ( jdkInstallationName ) ; if ( jdk == null ) { throw new AbortException ( "Could not find the JDK installation: " + jdkInstallationName + ". Make sure it is configured on the Global Tool Configuration page" ) ; } Node node = getComputer ( ) . getNode ( ) ; if ( node == null ) { throw new AbortException ( "Could not obtain the Node for the computer: " + getComputer ( ) . getName ( ) ) ; } jdk = jdk . forNode ( node , listener ) . forEnvironment ( env ) ; jdk . buildEnvVars ( envOverride ) ; }
|
Setup the selected JDK . If none is provided nothing is done .
|
35,435
|
private String readFromProcess ( String ... args ) throws InterruptedException { try ( ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ) { ProcStarter ps = launcher . launch ( ) ; Proc p = launcher . launch ( ps . cmds ( args ) . stdout ( baos ) ) ; int exitCode = p . join ( ) ; if ( exitCode == 0 ) { return baos . toString ( getComputer ( ) . getDefaultCharset ( ) . name ( ) ) . replaceAll ( "[\t\r\n]+" , " " ) . trim ( ) ; } else { return null ; } } catch ( IOException e ) { e . printStackTrace ( console . format ( "Error executing command '%s' : %s%n" , Arrays . toString ( args ) , e . getMessage ( ) ) ) ; } return null ; }
|
Executes a command and reads the result to a string . It uses the launcher to run the command to make sure the launcher decorator is used ie . docker . image step
|
35,436
|
private FilePath createWrapperScript ( FilePath tempBinDir , String name , String content ) throws IOException , InterruptedException { FilePath scriptFile = tempBinDir . child ( name ) ; envOverride . put ( MVN_CMD , scriptFile . getRemote ( ) ) ; scriptFile . write ( content , getComputer ( ) . getDefaultCharset ( ) . name ( ) ) ; scriptFile . chmod ( 0755 ) ; return scriptFile ; }
|
Creates the actual wrapper script file and sets the permissions .
|
35,437
|
private String setupMavenLocalRepo ( ) throws IOException , InterruptedException { String expandedMavenLocalRepo ; if ( StringUtils . isEmpty ( step . getMavenLocalRepo ( ) ) ) { expandedMavenLocalRepo = null ; } else { String expandedPath = envOverride . expand ( env . expand ( step . getMavenLocalRepo ( ) ) ) ; if ( FileUtils . isAbsolutePath ( expandedPath ) ) { expandedMavenLocalRepo = expandedPath ; } else { FilePath repoPath = new FilePath ( ws , expandedPath ) ; repoPath . mkdirs ( ) ; expandedMavenLocalRepo = repoPath . getRemote ( ) ; } } LOGGER . log ( Level . FINEST , "setupMavenLocalRepo({0}): {1}" , new Object [ ] { step . getMavenLocalRepo ( ) , expandedMavenLocalRepo } ) ; return expandedMavenLocalRepo ; }
|
Sets the maven repo location according to the provided parameter on the agent
|
35,438
|
private void globalSettingsFromConfig ( String mavenGlobalSettingsConfigId , FilePath mavenGlobalSettingsFile , Collection < Credentials > credentials ) throws AbortException { Config c = ConfigFiles . getByIdOrNull ( build , mavenGlobalSettingsConfigId ) ; if ( c == null ) { throw new AbortException ( "Could not find the Maven global settings.xml config file id:" + mavenGlobalSettingsFile + ". Make sure it exists on Managed Files" ) ; } if ( StringUtils . isBlank ( c . content ) ) { throw new AbortException ( "Could not create Maven global settings.xml config file id:" + mavenGlobalSettingsFile + ". Content of the file is empty" ) ; } GlobalMavenSettingsConfig mavenGlobalSettingsConfig ; if ( c instanceof GlobalMavenSettingsConfig ) { mavenGlobalSettingsConfig = ( GlobalMavenSettingsConfig ) c ; } else { mavenGlobalSettingsConfig = new GlobalMavenSettingsConfig ( c . id , c . name , c . comment , c . content , MavenSettingsConfig . isReplaceAllDefault , null ) ; } try { final Map < String , StandardUsernameCredentials > resolvedCredentialsByMavenServerId = resolveCredentials ( mavenGlobalSettingsConfig . getServerCredentialMappings ( ) , " Global Maven settings" ) ; String mavenGlobalSettingsFileContent ; if ( resolvedCredentialsByMavenServerId . isEmpty ( ) ) { mavenGlobalSettingsFileContent = mavenGlobalSettingsConfig . content ; console . println ( "[withMaven] using Maven global settings.xml '" + mavenGlobalSettingsConfig . id + "' with NO Maven servers credentials provided by Jenkins" ) ; } else { credentials . addAll ( resolvedCredentialsByMavenServerId . values ( ) ) ; List < String > tempFiles = new ArrayList < > ( ) ; mavenGlobalSettingsFileContent = CredentialsHelper . fillAuthentication ( mavenGlobalSettingsConfig . content , mavenGlobalSettingsConfig . isReplaceAll , resolvedCredentialsByMavenServerId , tempBinDir , tempFiles ) ; console . println ( "[withMaven] using Maven global settings.xml '" + mavenGlobalSettingsConfig . id + "' with Maven servers credentials provided by Jenkins " + "(replaceAll: " + mavenGlobalSettingsConfig . isReplaceAll + "): " + resolvedCredentialsByMavenServerId . entrySet ( ) . stream ( ) . map ( new MavenServerToCredentialsMappingToStringFunction ( ) ) . sorted ( ) . collect ( Collectors . joining ( ", " ) ) ) ; } mavenGlobalSettingsFile . write ( mavenGlobalSettingsFileContent , getComputer ( ) . getDefaultCharset ( ) . name ( ) ) ; LOGGER . log ( Level . FINE , "Created global config file {0}" , new Object [ ] { mavenGlobalSettingsFile } ) ; } catch ( Exception e ) { throw new IllegalStateException ( "Exception injecting Maven settings.xml " + mavenGlobalSettingsConfig . id + " during the build: " + build + ": " + e . getMessage ( ) , e ) ; } }
|
Reads the global config file from Config File Provider expands the credentials and stores it in a file on the temp folder to use it with the maven wrapper script
|
35,439
|
private Computer getComputer ( ) throws AbortException { if ( computer != null ) { return computer ; } String node = null ; Jenkins j = Jenkins . getInstance ( ) ; for ( Computer c : j . getComputers ( ) ) { if ( c . getChannel ( ) == launcher . getChannel ( ) ) { node = c . getName ( ) ; break ; } } if ( node == null ) { throw new AbortException ( "Could not find computer for the job" ) ; } computer = j . getComputer ( node ) ; if ( computer == null ) { throw new AbortException ( "No such computer " + node ) ; } if ( LOGGER . isLoggable ( Level . FINE ) ) { LOGGER . log ( Level . FINE , "Computer: {0}" , computer . getName ( ) ) ; try { LOGGER . log ( Level . FINE , "Env: {0}" , computer . getEnvironment ( ) ) ; } catch ( IOException | InterruptedException e ) { } } return computer ; }
|
Gets the computer for the current launcher .
|
35,440
|
protected DialectFactory createDialectFactory ( ) { DialectFactoryImpl factory = new DialectFactoryImpl ( ) ; factory . injectServices ( new ServiceRegistryImplementor ( ) { public < R extends Service > R getService ( Class < R > serviceRole ) { if ( serviceRole == DialectResolver . class ) { return ( R ) new StandardDialectResolver ( ) ; } else if ( serviceRole == StrategySelector . class ) { return ( R ) new StrategySelectorImpl ( new ClassLoaderServiceImpl ( Thread . currentThread ( ) . getContextClassLoader ( ) ) ) ; } return null ; } public < R extends Service > ServiceBinding < R > locateServiceBinding ( Class < R > serviceRole ) { return null ; } public void destroy ( ) { } public void registerChild ( ServiceRegistryImplementor child ) { } public void deRegisterChild ( ServiceRegistryImplementor child ) { } public ServiceRegistry getParentServiceRegistry ( ) { return null ; } } ) ; return factory ; }
|
should be using the ServiceRegistry but getting it from the SessionFactory at startup fails in Spring
|
35,441
|
protected boolean matchesFilter ( MetadataReader reader , MetadataReaderFactory readerFactory ) throws IOException { for ( TypeFilter filter : ENTITY_TYPE_FILTERS ) { if ( filter . match ( reader , readerFactory ) ) { return true ; } } return false ; }
|
Check whether any of the configured entity type filters matches the current class descriptor contained in the metadata reader .
|
35,442
|
public long deleteAll ( final QueryableCriteria criteria ) { return getHibernateTemplate ( ) . execute ( ( GrailsHibernateTemplate . HibernateCallback < Integer > ) session -> { JpaQueryBuilder builder = new JpaQueryBuilder ( criteria ) ; builder . setConversionService ( getMappingContext ( ) . getConversionService ( ) ) ; builder . setHibernateCompatible ( true ) ; JpaQueryInfo jpaQueryInfo = builder . buildDelete ( ) ; org . hibernate . query . Query query = session . createQuery ( jpaQueryInfo . getQuery ( ) ) ; getHibernateTemplate ( ) . applySettings ( query ) ; List parameters = jpaQueryInfo . getParameters ( ) ; if ( parameters != null ) { for ( int i = 0 , count = parameters . size ( ) ; i < count ; i ++ ) { query . setParameter ( JpaQueryBuilder . PARAMETER_NAME_PREFIX + ( i + 1 ) , parameters . get ( i ) ) ; } } HibernateHqlQuery hqlQuery = new HibernateHqlQuery ( HibernateSession . this , criteria . getPersistentEntity ( ) , query ) ; ApplicationEventPublisher applicationEventPublisher = datastore . getApplicationEventPublisher ( ) ; applicationEventPublisher . publishEvent ( new PreQueryEvent ( datastore , hqlQuery ) ) ; int result = query . executeUpdate ( ) ; applicationEventPublisher . publishEvent ( new PostQueryEvent ( datastore , hqlQuery , Collections . singletonList ( result ) ) ) ; return result ; } ) ; }
|
Deletes all objects matching the given criteria .
|
35,443
|
public long updateAll ( final QueryableCriteria criteria , final Map < String , Object > properties ) { return getHibernateTemplate ( ) . execute ( ( GrailsHibernateTemplate . HibernateCallback < Integer > ) session -> { JpaQueryBuilder builder = new JpaQueryBuilder ( criteria ) ; builder . setConversionService ( getMappingContext ( ) . getConversionService ( ) ) ; builder . setHibernateCompatible ( true ) ; PersistentEntity targetEntity = criteria . getPersistentEntity ( ) ; PersistentProperty lastUpdated = targetEntity . getPropertyByName ( GormProperties . LAST_UPDATED ) ; if ( lastUpdated != null && targetEntity . getMapping ( ) . getMappedForm ( ) . isAutoTimestamp ( ) ) { if ( timestampProvider == null ) { timestampProvider = new DefaultTimestampProvider ( ) ; } properties . put ( GormProperties . LAST_UPDATED , timestampProvider . createTimestamp ( lastUpdated . getType ( ) ) ) ; } JpaQueryInfo jpaQueryInfo = builder . buildUpdate ( properties ) ; org . hibernate . query . Query query = session . createQuery ( jpaQueryInfo . getQuery ( ) ) ; getHibernateTemplate ( ) . applySettings ( query ) ; List parameters = jpaQueryInfo . getParameters ( ) ; if ( parameters != null ) { for ( int i = 0 , count = parameters . size ( ) ; i < count ; i ++ ) { query . setParameter ( JpaQueryBuilder . PARAMETER_NAME_PREFIX + ( i + 1 ) , parameters . get ( i ) ) ; } } HibernateHqlQuery hqlQuery = new HibernateHqlQuery ( HibernateSession . this , targetEntity , query ) ; ApplicationEventPublisher applicationEventPublisher = datastore . getApplicationEventPublisher ( ) ; applicationEventPublisher . publishEvent ( new PreQueryEvent ( datastore , hqlQuery ) ) ; int result = query . executeUpdate ( ) ; applicationEventPublisher . publishEvent ( new PostQueryEvent ( datastore , hqlQuery , Collections . singletonList ( result ) ) ) ; return result ; } ) ; }
|
Updates all objects matching the given criteria and property values .
|
35,444
|
public static boolean isAtLeastVersion ( String required ) { String hibernateVersion = Hibernate . class . getPackage ( ) . getImplementationVersion ( ) ; if ( hibernateVersion != null ) { return GrailsVersion . isAtLeast ( hibernateVersion , required ) ; } else { return false ; } }
|
Check the current hibernate version
|
35,445
|
public static Query createQuery ( Session session , String query ) { return session . createQuery ( query ) ; }
|
Creates a query
|
35,446
|
private static PersistentProperty getGrailsDomainClassProperty ( AbstractHibernateDatastore datastore , Class < ? > targetClass , String propertyName ) { PersistentEntity grailsClass = datastore != null ? datastore . getMappingContext ( ) . getPersistentEntity ( targetClass . getName ( ) ) : null ; if ( grailsClass == null ) { throw new IllegalArgumentException ( "Unexpected: class is not a domain class:" + targetClass . getName ( ) ) ; } return grailsClass . getPropertyByName ( propertyName ) ; }
|
Get hold of the GrailsDomainClassProperty represented by the targetClass propertyName assuming targetClass corresponds to a GrailsDomainClass .
|
35,447
|
public static void cacheCriteriaByMapping ( Class < ? > targetClass , Criteria criteria ) { Mapping m = GrailsDomainBinder . getMapping ( targetClass ) ; if ( m != null && m . getCache ( ) != null && m . getCache ( ) . getEnabled ( ) ) { criteria . setCacheable ( true ) ; } }
|
Configures the criteria instance to cache based on the configured mapping .
|
35,448
|
public static FetchMode getFetchMode ( Object object ) { String name = object != null ? object . toString ( ) : "default" ; if ( name . equalsIgnoreCase ( FetchMode . JOIN . toString ( ) ) || name . equalsIgnoreCase ( "eager" ) ) { return FetchMode . JOIN ; } if ( name . equalsIgnoreCase ( FetchMode . SELECT . toString ( ) ) || name . equalsIgnoreCase ( "lazy" ) ) { return FetchMode . SELECT ; } return FetchMode . DEFAULT ; }
|
Retrieves the fetch mode for the specified instance ; otherwise returns the default FetchMode .
|
35,449
|
public static void setObjectToReadyOnly ( Object target , SessionFactory sessionFactory ) { Object resource = TransactionSynchronizationManager . getResource ( sessionFactory ) ; if ( resource != null ) { Session session = sessionFactory . getCurrentSession ( ) ; if ( canModifyReadWriteState ( session , target ) ) { if ( target instanceof HibernateProxy ) { target = ( ( HibernateProxy ) target ) . getHibernateLazyInitializer ( ) . getImplementation ( ) ; } session . setReadOnly ( target , true ) ; session . setHibernateFlushMode ( FlushMode . MANUAL ) ; } } }
|
Sets the target object to read - only using the given SessionFactory instance . This avoids Hibernate performing any dirty checking on the object
|
35,450
|
public static void setObjectToReadWrite ( final Object target , SessionFactory sessionFactory ) { Session session = sessionFactory . getCurrentSession ( ) ; if ( ! canModifyReadWriteState ( session , target ) ) { return ; } SessionImplementor sessionImpl = ( SessionImplementor ) session ; EntityEntry ee = sessionImpl . getPersistenceContext ( ) . getEntry ( target ) ; if ( ee == null || ee . getStatus ( ) != Status . READ_ONLY ) { return ; } Object actualTarget = target ; if ( target instanceof HibernateProxy ) { actualTarget = ( ( HibernateProxy ) target ) . getHibernateLazyInitializer ( ) . getImplementation ( ) ; } session . setReadOnly ( actualTarget , false ) ; session . setHibernateFlushMode ( FlushMode . AUTO ) ; incrementVersion ( target ) ; }
|
Sets the target object to read - write allowing Hibernate to dirty check it and auto - flush changes .
|
35,451
|
public static void incrementVersion ( Object target ) { MetaClass metaClass = GroovySystem . getMetaClassRegistry ( ) . getMetaClass ( target . getClass ( ) ) ; if ( metaClass . hasProperty ( target , GormProperties . VERSION ) != null ) { Object version = metaClass . getProperty ( target , GormProperties . VERSION ) ; if ( version instanceof Long ) { Long newVersion = ( Long ) version + 1 ; metaClass . setProperty ( target , GormProperties . VERSION , newVersion ) ; } } }
|
Increments the entities version number in order to force an update
|
35,452
|
public static void ensureCorrectGroovyMetaClass ( Object target , Class < ? > persistentClass ) { if ( target instanceof GroovyObject ) { GroovyObject go = ( ( GroovyObject ) target ) ; if ( ! go . getMetaClass ( ) . getTheClass ( ) . equals ( persistentClass ) ) { go . setMetaClass ( GroovySystem . getMetaClassRegistry ( ) . getMetaClass ( persistentClass ) ) ; } } }
|
Ensures the meta class is correct for a given class
|
35,453
|
public static HibernateProxy getAssociationProxy ( Object obj , String associationName ) { return proxyHandler . getAssociationProxy ( obj , associationName ) ; }
|
Returns the proxy for a given association or null if it is not proxied
|
35,454
|
public void enableMultiTenancyFilter ( ) { Serializable currentId = Tenants . currentId ( this ) ; if ( ConnectionSource . DEFAULT . equals ( currentId ) ) { disableMultiTenancyFilter ( ) ; } else { getHibernateTemplate ( ) . getSessionFactory ( ) . getCurrentSession ( ) . enableFilter ( GormProperties . TENANT_IDENTITY ) . setParameter ( GormProperties . TENANT_IDENTITY , currentId ) ; } }
|
Enable the tenant id filter for the given datastore and entity
|
35,455
|
public static void configureNamingStrategy ( final Object strategy ) throws ClassNotFoundException , InstantiationException , IllegalAccessException { configureNamingStrategy ( ConnectionSource . DEFAULT , strategy ) ; }
|
Override the default naming strategy for the default datasource given a Class or a full class name .
|
35,456
|
public static void configureNamingStrategy ( final String datasourceName , final Object strategy ) throws ClassNotFoundException , InstantiationException , IllegalAccessException { Class < ? > namingStrategyClass = null ; NamingStrategy namingStrategy ; if ( strategy instanceof Class < ? > ) { namingStrategyClass = ( Class < ? > ) strategy ; } else if ( strategy instanceof CharSequence ) { namingStrategyClass = Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( strategy . toString ( ) ) ; } if ( namingStrategyClass == null ) { namingStrategy = ( NamingStrategy ) strategy ; } else { namingStrategy = ( NamingStrategy ) namingStrategyClass . newInstance ( ) ; } NAMING_STRATEGIES . put ( datasourceName , namingStrategy ) ; }
|
Override the default naming strategy given a Class or a full class name or an instance of a NamingStrategy .
|
35,457
|
protected boolean isUnidirectionalOneToMany ( PersistentProperty property ) { return ( ( property instanceof org . grails . datastore . mapping . model . types . OneToMany ) && ! ( ( Association ) property ) . isBidirectional ( ) ) ; }
|
Checks whether a property is a unidirectional non - circular one - to - many
|
35,458
|
protected void bindDependentKeyValue ( PersistentProperty property , DependantValue key , InFlightMetadataCollector mappings , String sessionFactoryBeanName ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "[GrailsDomainBinder] binding [" + property . getName ( ) + "] with dependant key" ) ; } PersistentEntity refDomainClass = property . getOwner ( ) ; final Mapping mapping = getMapping ( refDomainClass . getJavaClass ( ) ) ; boolean hasCompositeIdentifier = hasCompositeIdentifier ( mapping ) ; if ( ( shouldCollectionBindWithJoinColumn ( ( ToMany ) property ) && hasCompositeIdentifier ) || ( hasCompositeIdentifier && ( property instanceof ManyToMany ) ) ) { CompositeIdentity ci = ( CompositeIdentity ) mapping . getIdentity ( ) ; bindCompositeIdentifierToManyToOne ( ( Association ) property , key , ci , refDomainClass , EMPTY_PATH , sessionFactoryBeanName ) ; } else { bindSimpleValue ( property , null , key , EMPTY_PATH , mappings , sessionFactoryBeanName ) ; } }
|
Binds the primary key value column
|
35,459
|
protected DependantValue createPrimaryKeyValue ( InFlightMetadataCollector mappings , PersistentProperty property , Collection collection , Map < ? , ? > persistentClasses ) { KeyValue keyValue ; DependantValue key ; String propertyRef = collection . getReferencedPropertyName ( ) ; if ( propertyRef == null ) { keyValue = collection . getOwner ( ) . getIdentifier ( ) ; } else { keyValue = ( KeyValue ) collection . getOwner ( ) . getProperty ( propertyRef ) . getValue ( ) ; } if ( LOG . isDebugEnabled ( ) ) LOG . debug ( "[GrailsDomainBinder] creating dependant key value to table [" + keyValue . getTable ( ) . getName ( ) + "]" ) ; key = new DependantValue ( metadataBuildingContext , collection . getCollectionTable ( ) , keyValue ) ; key . setTypeName ( null ) ; key . setNullable ( true ) ; key . setUpdateable ( false ) ; return key ; }
|
Creates the DependentValue object that forms a primary key reference for the collection .
|
35,460
|
protected void bindUnidirectionalOneToMany ( org . grails . datastore . mapping . model . types . OneToMany property , InFlightMetadataCollector mappings , Collection collection ) { Value v = collection . getElement ( ) ; v . createForeignKey ( ) ; String entityName ; if ( v instanceof ManyToOne ) { ManyToOne manyToOne = ( ManyToOne ) v ; entityName = manyToOne . getReferencedEntityName ( ) ; } else { entityName = ( ( OneToMany ) v ) . getReferencedEntityName ( ) ; } collection . setInverse ( false ) ; PersistentClass referenced = mappings . getEntityBinding ( entityName ) ; Backref prop = new Backref ( ) ; PersistentEntity owner = property . getOwner ( ) ; prop . setEntityName ( owner . getName ( ) ) ; prop . setName ( UNDERSCORE + addUnderscore ( owner . getJavaClass ( ) . getSimpleName ( ) , property . getName ( ) ) + "Backref" ) ; prop . setUpdateable ( false ) ; prop . setInsertable ( true ) ; prop . setCollectionRole ( collection . getRole ( ) ) ; prop . setValue ( collection . getKey ( ) ) ; prop . setOptional ( true ) ; referenced . addProperty ( prop ) ; }
|
Binds a unidirectional one - to - many creating a psuedo back reference property in the process .
|
35,461
|
protected void linkBidirectionalOneToMany ( Collection collection , PersistentClass associatedClass , DependantValue key , PersistentProperty otherSide ) { collection . setInverse ( true ) ; Iterator < ? > mappedByColumns = getProperty ( associatedClass , otherSide . getName ( ) ) . getValue ( ) . getColumnIterator ( ) ; while ( mappedByColumns . hasNext ( ) ) { Column column = ( Column ) mappedByColumns . next ( ) ; linkValueUsingAColumnCopy ( otherSide , column , key ) ; } }
|
Links a bidirectional one - to - many configuring the inverse side and using a column copy to perform the link
|
35,462
|
protected void bindCollection ( ToMany property , Collection collection , PersistentClass owner , InFlightMetadataCollector mappings , String path , String sessionFactoryBeanName ) { String propertyName = getNameForPropertyAndPath ( property , path ) ; collection . setRole ( qualify ( property . getOwner ( ) . getName ( ) , propertyName ) ) ; PropertyConfig pc = getPropertyConfig ( property ) ; final FetchMode fetchMode = pc . getFetchMode ( ) ; if ( fetchMode == FetchMode . JOIN ) { collection . setFetchMode ( FetchMode . JOIN ) ; } else if ( pc . getFetchMode ( ) != null ) { collection . setFetchMode ( pc . getFetchMode ( ) ) ; } else { collection . setFetchMode ( FetchMode . DEFAULT ) ; } if ( pc . getCascade ( ) != null ) { collection . setOrphanDelete ( pc . getCascade ( ) . equals ( CASCADE_ALL_DELETE_ORPHAN ) ) ; } if ( shouldBindCollectionWithForeignKey ( property ) ) { OneToMany oneToMany = new OneToMany ( metadataBuildingContext , collection . getOwner ( ) ) ; collection . setElement ( oneToMany ) ; bindOneToMany ( ( org . grails . datastore . mapping . model . types . OneToMany ) property , oneToMany , mappings ) ; } else { bindCollectionTable ( property , mappings , collection , owner . getTable ( ) , sessionFactoryBeanName ) ; if ( ! property . isOwningSide ( ) ) { collection . setInverse ( true ) ; } } if ( pc . getBatchSize ( ) != null ) { collection . setBatchSize ( pc . getBatchSize ( ) ) ; } if ( collection instanceof org . hibernate . mapping . Set ) { mappings . addSecondPass ( new GrailsCollectionSecondPass ( property , mappings , collection , sessionFactoryBeanName ) ) ; } else if ( collection instanceof org . hibernate . mapping . List ) { mappings . addSecondPass ( new ListSecondPass ( property , mappings , collection , sessionFactoryBeanName ) ) ; } else if ( collection instanceof org . hibernate . mapping . Map ) { mappings . addSecondPass ( new MapSecondPass ( property , mappings , collection , sessionFactoryBeanName ) ) ; } else { mappings . addSecondPass ( new GrailsCollectionSecondPass ( property , mappings , collection , sessionFactoryBeanName ) ) ; } }
|
First pass to bind collection to Hibernate metamodel sets up second pass
|
35,463
|
protected String calculateTableForMany ( ToMany property , String sessionFactoryBeanName ) { NamingStrategy namingStrategy = getNamingStrategy ( sessionFactoryBeanName ) ; String propertyColumnName = namingStrategy . propertyToColumnName ( property . getName ( ) ) ; PropertyConfig config = getPropertyConfig ( property ) ; JoinTable jt = config != null ? config . getJoinTable ( ) : null ; boolean hasJoinTableMapping = jt != null && jt . getName ( ) != null ; String left = getTableName ( property . getOwner ( ) , sessionFactoryBeanName ) ; if ( Map . class . isAssignableFrom ( property . getType ( ) ) ) { if ( hasJoinTableMapping ) { return jt . getName ( ) ; } return addUnderscore ( left , propertyColumnName ) ; } if ( property instanceof Basic ) { if ( hasJoinTableMapping ) { return jt . getName ( ) ; } return addUnderscore ( left , propertyColumnName ) ; } if ( property . getAssociatedEntity ( ) == null ) { throw new MappingException ( "Expected an entity to be associated with the association (" + property + ") and none was found. " ) ; } String right = getTableName ( property . getAssociatedEntity ( ) , sessionFactoryBeanName ) ; if ( property instanceof ManyToMany ) { if ( hasJoinTableMapping ) { return jt . getName ( ) ; } if ( property . isOwningSide ( ) ) { return addUnderscore ( left , propertyColumnName ) ; } return addUnderscore ( right , namingStrategy . propertyToColumnName ( ( ( ManyToMany ) property ) . getInversePropertyName ( ) ) ) ; } if ( shouldCollectionBindWithJoinColumn ( property ) ) { if ( hasJoinTableMapping ) { return jt . getName ( ) ; } left = trimBackTigs ( left ) ; right = trimBackTigs ( right ) ; return addUnderscore ( left , right ) ; } if ( property . isOwningSide ( ) ) { return addUnderscore ( left , right ) ; } return addUnderscore ( right , left ) ; }
|
Calculates the mapping table for a many - to - many . One side of the relationship has to own the relationship so that there is not a situation where you have two mapping tables for left_right and right_left
|
35,464
|
protected String getTableName ( PersistentEntity domainClass , String sessionFactoryBeanName ) { Mapping m = getMapping ( domainClass ) ; String tableName = null ; if ( m != null && m . getTableName ( ) != null ) { tableName = m . getTableName ( ) ; } if ( tableName == null ) { String shortName = domainClass . getJavaClass ( ) . getSimpleName ( ) ; PersistentEntityNamingStrategy namingStrategy = this . namingStrategy ; if ( namingStrategy != null ) { tableName = namingStrategy . resolveTableName ( domainClass ) ; } if ( tableName == null ) { tableName = getNamingStrategy ( sessionFactoryBeanName ) . classToTableName ( shortName ) ; } } return tableName ; }
|
Evaluates the table name for the given property
|
35,465
|
public void bindClass ( PersistentEntity entity , InFlightMetadataCollector mappings , String sessionFactoryBeanName ) throws MappingException { if ( entity . isRoot ( ) ) { bindRoot ( ( HibernatePersistentEntity ) entity , mappings , sessionFactoryBeanName ) ; } }
|
Binds a Grails domain class to the Hibernate runtime meta model
|
35,466
|
protected void trackCustomCascadingSaves ( Mapping mapping , Iterable < PersistentProperty > persistentProperties ) { for ( PersistentProperty property : persistentProperties ) { PropertyConfig propConf = mapping . getPropertyConfig ( property . getName ( ) ) ; if ( propConf != null && propConf . getCascade ( ) != null ) { propConf . setExplicitSaveUpdateCascade ( isSaveUpdateCascade ( propConf . getCascade ( ) ) ) ; } } }
|
Checks for any custom cascading saves set up via the mapping DSL and records them within the persistent property .
|
35,467
|
protected boolean isSaveUpdateCascade ( String cascade ) { String [ ] cascades = cascade . split ( "," ) ; for ( String cascadeProp : cascades ) { String trimmedProp = cascadeProp . trim ( ) ; if ( CASCADE_SAVE_UPDATE . equals ( trimmedProp ) || CASCADE_ALL . equals ( trimmedProp ) || CASCADE_ALL_DELETE_ORPHAN . equals ( trimmedProp ) ) { return true ; } } return false ; }
|
Check if a save - update cascade is defined within the Hibernate cascade properties string .
|
35,468
|
protected void bindClass ( PersistentEntity domainClass , PersistentClass persistentClass , InFlightMetadataCollector mappings ) { persistentClass . setLazy ( true ) ; final String entityName = domainClass . getName ( ) ; persistentClass . setEntityName ( entityName ) ; persistentClass . setJpaEntityName ( unqualify ( entityName ) ) ; persistentClass . setProxyInterfaceName ( entityName ) ; persistentClass . setClassName ( entityName ) ; persistentClass . setDynamicInsert ( false ) ; persistentClass . setDynamicUpdate ( false ) ; persistentClass . setSelectBeforeUpdate ( false ) ; String en = persistentClass . getEntityName ( ) ; if ( mappings . getMetadataBuildingOptions ( ) . getMappingDefaults ( ) . isAutoImportEnabled ( ) && en . indexOf ( '.' ) > 0 ) { String unqualified = unqualify ( en ) ; mappings . addImport ( unqualified , en ) ; } }
|
Binds the specified persistant class to the runtime model based on the properties defined in the domain class
|
35,469
|
protected void addMultiTenantFilterIfNecessary ( HibernatePersistentEntity entity , PersistentClass persistentClass , InFlightMetadataCollector mappings , String sessionFactoryBeanName ) { if ( entity . isMultiTenant ( ) ) { TenantId tenantId = entity . getTenantId ( ) ; if ( tenantId != null ) { String filterCondition = getMultiTenantFilterCondition ( sessionFactoryBeanName , entity ) ; persistentClass . addFilter ( GormProperties . TENANT_IDENTITY , filterCondition , true , Collections . emptyMap ( ) , Collections . emptyMap ( ) ) ; mappings . addFilterDefinition ( new FilterDefinition ( GormProperties . TENANT_IDENTITY , filterCondition , Collections . singletonMap ( GormProperties . TENANT_IDENTITY , persistentClass . getProperty ( tenantId . getName ( ) ) . getType ( ) ) ) ) ; } } }
|
Add a Hibernate filter for multitenancy if the persistent class is multitenant
|
35,470
|
protected void bindSubClasses ( HibernatePersistentEntity domainClass , PersistentClass parent , InFlightMetadataCollector mappings , String sessionFactoryBeanName ) { final java . util . Collection < PersistentEntity > subClasses = domainClass . getMappingContext ( ) . getDirectChildEntities ( domainClass ) ; for ( PersistentEntity sub : subClasses ) { final Class javaClass = sub . getJavaClass ( ) ; if ( javaClass . getSuperclass ( ) . equals ( domainClass . getJavaClass ( ) ) && ConnectionSourcesSupport . usesConnectionSource ( sub , dataSourceName ) ) { bindSubClass ( ( HibernatePersistentEntity ) sub , parent , mappings , sessionFactoryBeanName ) ; } } }
|
Binds the sub classes of a root class using table - per - heirarchy inheritance mapping
|
35,471
|
protected void bindSubClass ( HibernatePersistentEntity sub , PersistentClass parent , InFlightMetadataCollector mappings , String sessionFactoryBeanName ) { evaluateMapping ( sub , defaultMapping ) ; Mapping m = getMapping ( parent . getMappedClass ( ) ) ; Subclass subClass ; boolean tablePerSubclass = m != null && ! m . getTablePerHierarchy ( ) && ! m . isTablePerConcreteClass ( ) ; boolean tablePerConcreteClass = m != null && m . isTablePerConcreteClass ( ) ; final String fullName = sub . getName ( ) ; if ( tablePerSubclass ) { subClass = new JoinedSubclass ( parent , this . metadataBuildingContext ) ; } else if ( tablePerConcreteClass ) { subClass = new UnionSubclass ( parent , this . metadataBuildingContext ) ; } else { subClass = new SingleTableSubclass ( parent , this . metadataBuildingContext ) ; Mapping subMapping = getMapping ( sub ) ; DiscriminatorConfig discriminatorConfig = subMapping != null ? subMapping . getDiscriminator ( ) : null ; subClass . setDiscriminatorValue ( discriminatorConfig != null && discriminatorConfig . getValue ( ) != null ? discriminatorConfig . getValue ( ) : fullName ) ; if ( subMapping != null ) { configureDerivedProperties ( sub , subMapping ) ; } } Integer bs = m . getBatchSize ( ) ; if ( bs != null ) { subClass . setBatchSize ( bs ) ; } if ( m . getDynamicUpdate ( ) ) { subClass . setDynamicUpdate ( true ) ; } if ( m . getDynamicInsert ( ) ) { subClass . setDynamicInsert ( true ) ; } subClass . setAbstract ( sub . isAbstract ( ) ) ; subClass . setEntityName ( fullName ) ; subClass . setJpaEntityName ( unqualify ( fullName ) ) ; parent . addSubclass ( subClass ) ; mappings . addEntityBinding ( subClass ) ; if ( tablePerSubclass ) { bindJoinedSubClass ( sub , ( JoinedSubclass ) subClass , mappings , m , sessionFactoryBeanName ) ; } else if ( tablePerConcreteClass ) { bindUnionSubclass ( sub , ( UnionSubclass ) subClass , mappings , sessionFactoryBeanName ) ; } else { bindSubClass ( sub , subClass , mappings , sessionFactoryBeanName ) ; } addMultiTenantFilterIfNecessary ( sub , subClass , mappings , sessionFactoryBeanName ) ; final java . util . Collection < PersistentEntity > childEntities = sub . getMappingContext ( ) . getDirectChildEntities ( sub ) ; if ( ! childEntities . isEmpty ( ) ) { bindSubClasses ( sub , subClass , mappings , sessionFactoryBeanName ) ; } }
|
Binds a sub class .
|
35,472
|
protected void bindJoinedSubClass ( HibernatePersistentEntity sub , JoinedSubclass joinedSubclass , InFlightMetadataCollector mappings , Mapping gormMapping , String sessionFactoryBeanName ) { bindClass ( sub , joinedSubclass , mappings ) ; String schemaName = getSchemaName ( mappings ) ; String catalogName = getCatalogName ( mappings ) ; Table mytable = mappings . addTable ( schemaName , catalogName , getJoinedSubClassTableName ( sub , joinedSubclass , null , mappings , sessionFactoryBeanName ) , null , false ) ; joinedSubclass . setTable ( mytable ) ; LOG . info ( "Mapping joined-subclass: " + joinedSubclass . getEntityName ( ) + " -> " + joinedSubclass . getTable ( ) . getName ( ) ) ; SimpleValue key = new DependantValue ( metadataBuildingContext , mytable , joinedSubclass . getIdentifier ( ) ) ; joinedSubclass . setKey ( key ) ; final PersistentProperty identifier = sub . getIdentity ( ) ; String columnName = getColumnNameForPropertyAndPath ( identifier , EMPTY_PATH , null , sessionFactoryBeanName ) ; bindSimpleValue ( identifier . getType ( ) . getName ( ) , key , false , columnName , mappings ) ; joinedSubclass . createPrimaryKey ( ) ; createClassProperties ( sub , joinedSubclass , mappings , sessionFactoryBeanName ) ; }
|
Binds a joined sub - class mapping using table - per - subclass
|
35,473
|
protected void bindSubClass ( HibernatePersistentEntity sub , Subclass subClass , InFlightMetadataCollector mappings , String sessionFactoryBeanName ) { bindClass ( sub , subClass , mappings ) ; if ( LOG . isDebugEnabled ( ) ) LOG . debug ( "Mapping subclass: " + subClass . getEntityName ( ) + " -> " + subClass . getTable ( ) . getName ( ) ) ; createClassProperties ( sub , subClass , mappings , sessionFactoryBeanName ) ; }
|
Binds a sub - class using table - per - hierarchy inheritance mapping
|
35,474
|
protected void bindDiscriminatorProperty ( Table table , RootClass entity , InFlightMetadataCollector mappings ) { Mapping m = getMapping ( entity . getMappedClass ( ) ) ; SimpleValue d = new SimpleValue ( metadataBuildingContext , table ) ; entity . setDiscriminator ( d ) ; DiscriminatorConfig discriminatorConfig = m != null ? m . getDiscriminator ( ) : null ; boolean hasDiscriminatorConfig = discriminatorConfig != null ; entity . setDiscriminatorValue ( hasDiscriminatorConfig ? discriminatorConfig . getValue ( ) : entity . getClassName ( ) ) ; if ( hasDiscriminatorConfig ) { if ( discriminatorConfig . getInsertable ( ) != null ) { entity . setDiscriminatorInsertable ( discriminatorConfig . getInsertable ( ) ) ; } Object type = discriminatorConfig . getType ( ) ; if ( type != null ) { if ( type instanceof Class ) { d . setTypeName ( ( ( Class ) type ) . getName ( ) ) ; } else { d . setTypeName ( type . toString ( ) ) ; } } } if ( hasDiscriminatorConfig && discriminatorConfig . getFormula ( ) != null ) { Formula formula = new Formula ( ) ; formula . setFormula ( discriminatorConfig . getFormula ( ) ) ; d . addFormula ( formula ) ; } else { bindSimpleValue ( STRING_TYPE , d , false , RootClass . DEFAULT_DISCRIMINATOR_COLUMN_NAME , mappings ) ; ColumnConfig cc = ! hasDiscriminatorConfig ? null : discriminatorConfig . getColumn ( ) ; if ( cc != null ) { Column c = ( Column ) d . getColumnIterator ( ) . next ( ) ; if ( cc . getName ( ) != null ) { c . setName ( cc . getName ( ) ) ; } bindColumnConfigToColumn ( null , c , cc ) ; } } entity . setPolymorphic ( true ) ; }
|
Creates and binds the discriminator property used in table - per - hierarchy inheritance to discriminate between sub class instances
|
35,475
|
protected void bindComponent ( Component component , Embedded property , boolean isNullable , InFlightMetadataCollector mappings , String sessionFactoryBeanName ) { component . setEmbedded ( true ) ; Class < ? > type = property . getType ( ) ; String role = qualify ( type . getName ( ) , property . getName ( ) ) ; component . setRoleName ( role ) ; component . setComponentClassName ( type . getName ( ) ) ; PersistentEntity domainClass = property . getAssociatedEntity ( ) ; evaluateMapping ( domainClass , defaultMapping ) ; final List < PersistentProperty > properties = domainClass . getPersistentProperties ( ) ; Table table = component . getOwner ( ) . getTable ( ) ; PersistentClass persistentClass = component . getOwner ( ) ; String path = property . getName ( ) ; Class < ? > propertyType = property . getOwner ( ) . getJavaClass ( ) ; for ( PersistentProperty currentGrailsProp : properties ) { if ( currentGrailsProp . equals ( domainClass . getIdentity ( ) ) ) continue ; if ( currentGrailsProp . getName ( ) . equals ( GormProperties . VERSION ) ) continue ; if ( currentGrailsProp . getType ( ) . equals ( propertyType ) ) { component . setParentProperty ( currentGrailsProp . getName ( ) ) ; continue ; } bindComponentProperty ( component , property , currentGrailsProp , persistentClass , path , table , mappings , sessionFactoryBeanName ) ; } }
|
Binds a Hibernate component type using the given GrailsDomainClassProperty instance
|
35,476
|
@ SuppressWarnings ( "unchecked" ) protected void bindManyToOne ( Association property , ManyToOne manyToOne , String path , InFlightMetadataCollector mappings , String sessionFactoryBeanName ) { NamingStrategy namingStrategy = getNamingStrategy ( sessionFactoryBeanName ) ; bindManyToOneValues ( property , manyToOne ) ; PersistentEntity refDomainClass = property instanceof ManyToMany ? property . getOwner ( ) : property . getAssociatedEntity ( ) ; Mapping mapping = getMapping ( refDomainClass ) ; boolean isComposite = hasCompositeIdentifier ( mapping ) ; if ( isComposite ) { CompositeIdentity ci = ( CompositeIdentity ) mapping . getIdentity ( ) ; bindCompositeIdentifierToManyToOne ( property , manyToOne , ci , refDomainClass , path , sessionFactoryBeanName ) ; } else { if ( property . isCircular ( ) && ( property instanceof ManyToMany ) ) { PropertyConfig pc = getPropertyConfig ( property ) ; if ( pc . getColumns ( ) . isEmpty ( ) ) { mapping . getColumns ( ) . put ( property . getName ( ) , pc ) ; } if ( ! hasJoinKeyMapping ( pc ) ) { JoinTable jt = new JoinTable ( ) ; final ColumnConfig columnConfig = new ColumnConfig ( ) ; columnConfig . setName ( namingStrategy . propertyToColumnName ( property . getName ( ) ) + UNDERSCORE + FOREIGN_KEY_SUFFIX ) ; jt . setKey ( columnConfig ) ; pc . setJoinTable ( jt ) ; } bindSimpleValue ( property , manyToOne , path , pc , sessionFactoryBeanName ) ; } else { bindSimpleValue ( property , null , manyToOne , path , mappings , sessionFactoryBeanName ) ; } } PropertyConfig config = getPropertyConfig ( property ) ; if ( ( property instanceof org . grails . datastore . mapping . model . types . OneToOne ) && ! isComposite ) { manyToOne . setAlternateUniqueKey ( true ) ; Column c = getColumnForSimpleValue ( manyToOne ) ; if ( config != null && ! config . isUniqueWithinGroup ( ) ) { c . setUnique ( config . isUnique ( ) ) ; } else if ( property . isBidirectional ( ) && isHasOne ( property . getInverseSide ( ) ) ) { c . setUnique ( true ) ; } } }
|
Binds a many - to - one relationship to the
|
35,477
|
private int calculateForeignKeyColumnCount ( PersistentEntity refDomainClass , String [ ] propertyNames ) { int expectedForeignKeyColumnLength = 0 ; for ( String propertyName : propertyNames ) { PersistentProperty referencedProperty = refDomainClass . getPropertyByName ( propertyName ) ; if ( referencedProperty instanceof ToOne ) { ToOne toOne = ( ToOne ) referencedProperty ; PersistentProperty [ ] compositeIdentity = toOne . getAssociatedEntity ( ) . getCompositeIdentity ( ) ; if ( compositeIdentity != null ) { expectedForeignKeyColumnLength += compositeIdentity . length ; } else { expectedForeignKeyColumnLength ++ ; } } else { expectedForeignKeyColumnLength ++ ; } } return expectedForeignKeyColumnLength ; }
|
number of columns required for a column key we have to perform the calculation here
|
35,478
|
protected void bindProperty ( PersistentProperty grailsProperty , Property prop , InFlightMetadataCollector mappings ) { prop . setName ( grailsProperty . getName ( ) ) ; if ( isBidirectionalManyToOneWithListMapping ( grailsProperty , prop ) ) { prop . setInsertable ( false ) ; prop . setUpdateable ( false ) ; } else { prop . setInsertable ( getInsertableness ( grailsProperty ) ) ; prop . setUpdateable ( getUpdateableness ( grailsProperty ) ) ; } AccessType accessType = AccessType . getAccessStrategy ( grailsProperty . getMapping ( ) . getMappedForm ( ) . getAccessType ( ) ) ; if ( accessType == AccessType . FIELD ) { EntityReflector . PropertyReader reader = grailsProperty . getReader ( ) ; Method getter = reader != null ? reader . getter ( ) : null ; if ( getter != null && getter . getAnnotation ( Traits . Implemented . class ) != null ) { prop . setPropertyAccessorName ( TraitPropertyAccessStrategy . class . getName ( ) ) ; } else { prop . setPropertyAccessorName ( accessType . getType ( ) ) ; } } else { prop . setPropertyAccessorName ( accessType . getType ( ) ) ; } prop . setOptional ( grailsProperty . isNullable ( ) ) ; setCascadeBehaviour ( grailsProperty , prop ) ; final boolean isToOne = grailsProperty instanceof ToOne && ! ( grailsProperty instanceof Embedded ) ; PersistentEntity propertyOwner = grailsProperty . getOwner ( ) ; boolean isLazyable = isToOne || ! ( grailsProperty instanceof Association ) && ! grailsProperty . equals ( propertyOwner . getIdentity ( ) ) ; if ( isLazyable ) { final boolean isLazy = getLaziness ( grailsProperty ) ; prop . setLazy ( isLazy ) ; if ( isLazy && isToOne && ! ( PersistentAttributeInterceptable . class . isAssignableFrom ( propertyOwner . getJavaClass ( ) ) ) ) { } } }
|
Binds a property to Hibernate runtime meta model . Deals with cascade strategy based on the Grails domain model
|
35,479
|
protected void bindSimpleValue ( PersistentProperty property , PersistentProperty parentProperty , SimpleValue simpleValue , String path , InFlightMetadataCollector mappings , String sessionFactoryBeanName ) { bindSimpleValue ( property , parentProperty , simpleValue , path , getPropertyConfig ( property ) , sessionFactoryBeanName ) ; }
|
Binds a simple value to the Hibernate metamodel . A simple value is any type within the Hibernate type system
|
35,480
|
protected void bindSimpleValue ( String type , SimpleValue simpleValue , boolean nullable , String columnName , InFlightMetadataCollector mappings ) { simpleValue . setTypeName ( type ) ; Table t = simpleValue . getTable ( ) ; Column column = new Column ( ) ; column . setNullable ( nullable ) ; column . setValue ( simpleValue ) ; column . setName ( columnName ) ; if ( t != null ) t . addColumn ( column ) ; simpleValue . addColumn ( column ) ; }
|
Binds a value for the specified parameters to the meta model .
|
35,481
|
protected void bindStringColumnConstraints ( Column column , PersistentProperty constrainedProperty ) { final org . grails . datastore . mapping . config . Property mappedForm = constrainedProperty . getMapping ( ) . getMappedForm ( ) ; Number columnLength = mappedForm . getMaxSize ( ) ; List < ? > inListValues = mappedForm . getInList ( ) ; if ( columnLength != null ) { column . setLength ( columnLength . intValue ( ) ) ; } else if ( inListValues != null ) { column . setLength ( getMaxSize ( inListValues ) ) ; } }
|
Interrogates the specified constraints looking for any constraints that would limit the length of the property s value . If such constraints exist this method adjusts the length of the column accordingly .
|
35,482
|
public org . grails . datastore . mapping . query . api . ProjectionList property ( String propertyName , String alias ) { final PropertyProjection propertyProjection = Projections . property ( calculatePropertyName ( propertyName ) ) ; addProjectionToList ( propertyProjection , alias ) ; return this ; }
|
A projection that selects a property name
|
35,483
|
protected void addProjectionToList ( Projection propertyProjection , String alias ) { if ( alias != null ) { projectionList . add ( propertyProjection , alias ) ; } else { projectionList . add ( propertyProjection ) ; } }
|
Adds a projection to the projectList for the given alias
|
35,484
|
public org . grails . datastore . mapping . query . api . ProjectionList distinct ( String propertyName , String alias ) { final Projection proj = Projections . distinct ( Projections . property ( calculatePropertyName ( propertyName ) ) ) ; addProjectionToList ( proj , alias ) ; return this ; }
|
A projection that selects a distince property name
|
35,485
|
public BuildableCriteria join ( String associationPath ) { criteria . setFetchMode ( calculatePropertyName ( associationPath ) , FetchMode . JOIN ) ; return this ; }
|
Use a join query
|
35,486
|
public void lock ( boolean shouldLock ) { String lastAlias = getLastAlias ( ) ; if ( shouldLock ) { if ( lastAlias != null ) { criteria . setLockMode ( lastAlias , LockMode . PESSIMISTIC_WRITE ) ; } else { criteria . setLockMode ( LockMode . PESSIMISTIC_WRITE ) ; } } else { if ( lastAlias != null ) { criteria . setLockMode ( lastAlias , LockMode . NONE ) ; } else { criteria . setLockMode ( LockMode . NONE ) ; } } }
|
Whether a pessimistic lock should be obtained .
|
35,487
|
public BuildableCriteria select ( String associationPath ) { criteria . setFetchMode ( calculatePropertyName ( associationPath ) , FetchMode . SELECT ) ; return this ; }
|
Use a select query
|
35,488
|
protected String calculatePropertyName ( String propertyName ) { String lastAlias = getLastAlias ( ) ; if ( lastAlias != null ) { return lastAlias + '.' + propertyName ; } return propertyName ; }
|
Calculates the property name including any alias paths
|
35,489
|
@ SuppressWarnings ( { "rawtypes" , "unchecked" } ) protected Object calculatePropertyValue ( Object propertyValue ) { if ( propertyValue instanceof CharSequence ) { return propertyValue . toString ( ) ; } if ( propertyValue instanceof QueryableCriteria ) { propertyValue = convertToHibernateCriteria ( ( QueryableCriteria < ? > ) propertyValue ) ; } else if ( propertyValue instanceof Closure ) { propertyValue = convertToHibernateCriteria ( new grails . gorm . DetachedCriteria ( targetClass ) . build ( ( Closure < ? > ) propertyValue ) ) ; } return propertyValue ; }
|
Calculates the property value converting GStrings if necessary
|
35,490
|
public void count ( String propertyName , String alias ) { final CountProjection proj = Projections . count ( calculatePropertyName ( propertyName ) ) ; addProjectionToList ( proj , alias ) ; }
|
Adds a projection that allows the criteria to return the property count
|
35,491
|
public org . grails . datastore . mapping . query . api . ProjectionList groupProperty ( String propertyName , String alias ) { final PropertyProjection proj = Projections . groupProperty ( calculatePropertyName ( propertyName ) ) ; addProjectionToList ( proj , alias ) ; return this ; }
|
Adds a projection that allows the criteria s result to be grouped by a property
|
35,492
|
public org . grails . datastore . mapping . query . api . ProjectionList min ( String propertyName , String alias ) { final AggregateProjection aggregateProjection = Projections . min ( calculatePropertyName ( propertyName ) ) ; addProjectionToList ( aggregateProjection , alias ) ; return this ; }
|
Adds a projection that allows the criteria to retrieve a minimum property value
|
35,493
|
public org . grails . datastore . mapping . query . api . ProjectionList sum ( String propertyName , String alias ) { final AggregateProjection proj = Projections . sum ( calculatePropertyName ( propertyName ) ) ; addProjectionToList ( proj , alias ) ; return this ; }
|
Adds a projection that allows the criteria to retrieve the sum of the results of a property
|
35,494
|
public void fetchMode ( String associationPath , FetchMode fetchMode ) { if ( criteria != null ) { criteria . setFetchMode ( associationPath , fetchMode ) ; } }
|
Sets the fetch mode of an associated path
|
35,495
|
public Criteria createAlias ( String associationPath , String alias ) { return criteria . createAlias ( associationPath , alias ) ; }
|
Join an association assigning an alias to the joined association .
|
35,496
|
public org . grails . datastore . mapping . query . api . Criteria geProperty ( String propertyName , String otherPropertyName ) { if ( ! validateSimpleExpression ( ) ) { throwRuntimeException ( new IllegalArgumentException ( "Call to [geProperty] with propertyName [" + propertyName + "] and other property name [" + otherPropertyName + "] not allowed here." ) ) ; } propertyName = calculatePropertyName ( propertyName ) ; otherPropertyName = calculatePropertyName ( otherPropertyName ) ; addToCriteria ( Restrictions . geProperty ( propertyName , otherPropertyName ) ) ; return this ; }
|
Creates a Criterion that tests if the first property is greater than or equal to the second property
|
35,497
|
public org . grails . datastore . mapping . query . api . Criteria le ( String propertyName , Object propertyValue ) { if ( ! validateSimpleExpression ( ) ) { throwRuntimeException ( new IllegalArgumentException ( "Call to [le] with propertyName [" + propertyName + "] and value [" + propertyValue + "] not allowed here." ) ) ; } propertyName = calculatePropertyName ( propertyName ) ; propertyValue = calculatePropertyValue ( propertyValue ) ; Criterion le ; if ( propertyValue instanceof org . hibernate . criterion . DetachedCriteria ) { le = Property . forName ( propertyName ) . le ( ( org . hibernate . criterion . DetachedCriteria ) propertyValue ) ; } else { le = Restrictions . le ( propertyName , propertyValue ) ; } addToCriteria ( le ) ; return this ; }
|
Creates a less than or equal to Criterion based on the specified property name and value
|
35,498
|
@ SuppressWarnings ( "rawtypes" ) public org . grails . datastore . mapping . query . api . Criteria inList ( String propertyName , Collection values ) { return in ( propertyName , values ) ; }
|
Delegates to in as in is a Groovy keyword
|
35,499
|
public org . grails . datastore . mapping . query . api . Criteria order ( String propertyName , String direction ) { if ( criteria == null ) { throwRuntimeException ( new IllegalArgumentException ( "Call to [order] with propertyName [" + propertyName + "]not allowed here." ) ) ; } propertyName = calculatePropertyName ( propertyName ) ; Order o ; if ( direction . equals ( ORDER_DESCENDING ) ) { o = Order . desc ( propertyName ) ; } else { o = Order . asc ( propertyName ) ; } if ( paginationEnabledList ) { orderEntries . add ( o ) ; } else { criteria . addOrder ( o ) ; } return this ; }
|
Orders by the specified property name and direction
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.