<commit_before>/*
  Copyright 2010-2017 BusinessCode GmbH, Germany

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
*/
"use strict";
/**
 * This namespace contains functionality directly related to BCD-UI cube
 * @namespace bcdui.component.cube
 */
bcdui.util.namespace("bcdui.component.cube");
bcdui.component.cube.CubeModel = bcdui._migPjs._classCreate( bcdui.core.ModelWrapper,
/**
 * @lends bcdui.component.cube.CubeModel.prototype
 */
{
  /**
   * @classdesc
   * Creates a cube model, provides data with calculations and col dimensions applied
   * @extends bcdui.core.ModelWrapper
   *
   * @constructs
   * @param {Object} args The parameter map contains the following properties:
   * @param {bcdui.core.DataProvider} [args.config] - The model containing the cube meta data (see cube-2.0.0.xsd). If it is not present, the configuration at './cubeConfiguration.xml' is used
   * @param {string}                  [args.cubeId] - When settings are to be derived from status model, this is the id in <cube:Layout cubeId="myCube">
   * @param {string}                  [args.id]     - The object's id, needed only when later accessing via id. If given the CubeModel registers itself at {@link bcdui.factory.objectRegistry}
   * @param {bcdui.core.DataProvider} [args.statusModel=bcdui.wkModels.guiStatusEstablished] - StatusModel, containing the filters as /SomeRoot/f:Filter and the layout definition at /SomeRoot//cube:Layout[@cubeId=args.cubeId]
   */
  initialize: function(args) {
    
    var isLeaf = ((typeof this.type == "undefined")  ? "" + (this.type = "bcdui.component.cube.CubeModel" ): "") != "";
    
    args = bcdui.factory._xmlArgs( args, bcdui.factory.validate.component._schema_createCubeModel_args );
    bcdui.factory.validate.jsvalidation._validateArgs(args, bcdui.factory.validate.component._schema_createCubeModel_args);

    args.id = args.id ? args.id : bcdui.factory.objectRegistry.generateTemporaryIdInScope("cubeModel");
    // param {bcdui.core.DataProvider} [args.chain=bcdui/component/cube/chain.xml] - Processing chain, usually the default chain does a good job and is required for support of cube-2.0.0.xsd
    args.chain = args.chain || new bcdui.core.SimpleModel( { id: args.id+"_bcdImpl_chain", url: bcdui.component.cube._cubeChain } );
    args.metaDataModel         = args.config || args.metaDataModel || new bcdui.core.SimpleModel( { id: args.id+"_bcdImpl_configuration", url: "cubeConfiguration.xml" } );
    args.statusModel           = args.statusModel           || bcdui.wkModels.guiStatusEstablished;
    args.enhancedConfiguration = args.enhancedConfiguration || new bcdui.core.ModelWrapper( {
      id: args.id+"_bcdImpl_enhancedConfiguration", inputModel: args.metaDataModel,
      chain: [ bcdui.contextPath+"/bcdui/js/component/cube/mergeLayout.xslt",
               bcdui.contextPath+"/bcdui/js/component/cube/serverCalc.xslt",
               bcdui.contextPath+"/bcdui/js/component/cube/configuration.xslt" ],
      parameters: {cubeId: args.cubeId, statusModel: args.statusModel } } );


    // We start with an empty DataProviderHolder until we known, whether a server request is to be done, which we only know once enhancedConfiguration is ready
    var reqHolder = new bcdui.core.DataProviderHolder();
    var inputModel = new bcdui.core.SimpleModel( { id: args.id+"_bcdImpl_inputModel", url: new bcdui.core.RequestDocumentDataProvider( { requestModel: reqHolder } ) } );
    bcdui.core.ModelWrapper.call( this, { id: args.id, inputModel: inputModel, chain: args.chain, parameters: { paramModel: args.enhancedConfiguration } } );

    bcdui.factory.objectRegistry.withReadyObjects( args.enhancedConfiguration, function() {

      // We only process a server request, if at least one measure or one dimension is selected, otherwise further execution is prevented
      var rqModel = null;
      if( ! bcdui.factory.objectRegistry.getObject(args.enhancedConfiguration).getData().selectSingleNode("/*/cube:Layout/cube:Measures//dm:MeasureRef | /*/cube:Layout/cube:Measures//dm:Measure")
       && ! bcdui.factory.objectRegistry.getObject(args.enhancedConfiguration).getData().selectSingleNode("/*/cube:Layout/cube:Dimensions//dm:LevelRef")
          ) {
        rqModel = new bcdui.core.StaticModel( "<Wrq xmlns='http://www.businesscode.de/schema/bcdui/wrs-request-1.0.0'></Wrq>" );
      } else {
        rqModel = new bcdui.core.ModelWrapper( { id: args.id+"_bcdImpl_requestDoc", inputModel: args.enhancedConfiguration,
          parameters: {statusModel: args.statusModel }, chain: bcdui.contextPath+"/bcdui/js/component/cube/request.xslt" } );
      }
      reqHolder.setSource(rqModel);
      reqHolder.execute();
    }.bind(this) );
    
    if (isLeaf)
      this._checkAutoRegister();
  }
});

//default layout renderer<commit_msg>Client / Cube / set uri for data model<commit_after>/*
  Copyright 2010-2017 BusinessCode GmbH, Germany

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
*/
"use strict";
/**
 * This namespace contains functionality directly related to BCD-UI cube
 * @namespace bcdui.component.cube
 */
bcdui.util.namespace("bcdui.component.cube");
bcdui.component.cube.CubeModel = bcdui._migPjs._classCreate( bcdui.core.ModelWrapper,
/**
 * @lends bcdui.component.cube.CubeModel.prototype
 */
{
  /**
   * @classdesc
   * Creates a cube model, provides data with calculations and col dimensions applied
   * @extends bcdui.core.ModelWrapper
   *
   * @constructs
   * @param {Object} args The parameter map contains the following properties:
   * @param {bcdui.core.DataProvider} [args.config] - The model containing the cube meta data (see cube-2.0.0.xsd). If it is not present, the configuration at './cubeConfiguration.xml' is used
   * @param {string}                  [args.cubeId] - When settings are to be derived from status model, this is the id in <cube:Layout cubeId="myCube">
   * @param {string}                  [args.id]     - The object's id, needed only when later accessing via id. If given the CubeModel registers itself at {@link bcdui.factory.objectRegistry}
   * @param {bcdui.core.DataProvider} [args.statusModel=bcdui.wkModels.guiStatusEstablished] - StatusModel, containing the filters as /SomeRoot/f:Filter and the layout definition at /SomeRoot//cube:Layout[@cubeId=args.cubeId]
   */
  initialize: function(args) {
    
    var isLeaf = ((typeof this.type == "undefined")  ? "" + (this.type = "bcdui.component.cube.CubeModel" ): "") != "";
    
    args = bcdui.factory._xmlArgs( args, bcdui.factory.validate.component._schema_createCubeModel_args );
    bcdui.factory.validate.jsvalidation._validateArgs(args, bcdui.factory.validate.component._schema_createCubeModel_args);

    args.id = args.id ? args.id : bcdui.factory.objectRegistry.generateTemporaryIdInScope("cubeModel");
    // param {bcdui.core.DataProvider} [args.chain=bcdui/component/cube/chain.xml] - Processing chain, usually the default chain does a good job and is required for support of cube-2.0.0.xsd
    args.chain = args.chain || new bcdui.core.SimpleModel( { id: args.id+"_bcdImpl_chain", url: bcdui.component.cube._cubeChain } );
    args.metaDataModel         = args.config || args.metaDataModel || new bcdui.core.SimpleModel( { id: args.id+"_bcdImpl_configuration", url: "cubeConfiguration.xml" } );
    args.statusModel           = args.statusModel           || bcdui.wkModels.guiStatusEstablished;
    args.enhancedConfiguration = args.enhancedConfiguration || new bcdui.core.ModelWrapper( {
      id: args.id+"_bcdImpl_enhancedConfiguration", inputModel: args.metaDataModel,
      chain: [ bcdui.contextPath+"/bcdui/js/component/cube/mergeLayout.xslt",
               bcdui.contextPath+"/bcdui/js/component/cube/serverCalc.xslt",
               bcdui.contextPath+"/bcdui/js/component/cube/configuration.xslt" ],
      parameters: {cubeId: args.cubeId, statusModel: args.statusModel } } );


    // We start with an empty DataProviderHolder until we known, whether a server request is to be done, which we only know once enhancedConfiguration is ready
    var reqHolder = new bcdui.core.DataProviderHolder();
    var inputModel = new bcdui.core.SimpleModel( { id: args.id+"_bcdImpl_inputModel", url: new bcdui.core.RequestDocumentDataProvider( { uri: "cube_" + args.id, requestModel: reqHolder } ) } );
    bcdui.core.ModelWrapper.call( this, { id: args.id, inputModel: inputModel, chain: args.chain, parameters: { paramModel: args.enhancedConfiguration } } );

    bcdui.factory.objectRegistry.withReadyObjects( args.enhancedConfiguration, function() {

      // We only process a server request, if at least one measure or one dimension is selected, otherwise further execution is prevented
      var rqModel = null;
      if( ! bcdui.factory.objectRegistry.getObject(args.enhancedConfiguration).getData().selectSingleNode("/*/cube:Layout/cube:Measures//dm:MeasureRef | /*/cube:Layout/cube:Measures//dm:Measure")
       && ! bcdui.factory.objectRegistry.getObject(args.enhancedConfiguration).getData().selectSingleNode("/*/cube:Layout/cube:Dimensions//dm:LevelRef")
          ) {
        rqModel = new bcdui.core.StaticModel( "<Wrq xmlns='http://www.businesscode.de/schema/bcdui/wrs-request-1.0.0'></Wrq>" );
      } else {
        rqModel = new bcdui.core.ModelWrapper( { id: args.id+"_bcdImpl_requestDoc", inputModel: args.enhancedConfiguration,
          parameters: {statusModel: args.statusModel }, chain: bcdui.contextPath+"/bcdui/js/component/cube/request.xslt" } );
      }
      reqHolder.setSource(rqModel);
      reqHolder.execute();
    }.bind(this) );
    
    if (isLeaf)
      this._checkAutoRegister();
  }
});

//default layout renderer
{'fraction_non_alphanumeric': 0.11637322286037097, 'fraction_numerical': 0.003954429903022315, 'mean_word_length': 3.836976320582878, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5096105', 'n_tokens_mistral': 3268, 'n_tokens_neox': 3182, 'n_words': 794}