Package org.openquark.gems.client

Examples of org.openquark.gems.client.ReflectorGem


        Collection<MessagePropertyDescription> propertyInfos = jobDescription.getMessagePropertyDescriptions();
       
        int i=0;
        for (final MessagePropertyDescription propertyInfo : propertyInfos) {
            //create the message reflector
            ReflectorGem messageReflector = new ReflectorGem (messageGem);
            gemGraph.addGem(messageReflector);
           
            // Create a code gem to extract the ith property from the message list input
            // e.g. the code gem for the 5th message property would be:
            // List.map (\msg -> msg.#5) msg
            // which takes the input list of message tuples as input, and outputs a new list
            // containing the 5th element of every message.
            Gem propertyExtractorGem = new CodeGem(codeAnalyser, CAL_List.Functions.map.getQualifiedName() + " (\\msg -> msg.#" + ++i +") msg", Collections.<String>emptySet());
            gemGraph.addGem(propertyExtractorGem);
                    
            // create the collector gem for this message property
            CollectorGem propertyGem = new CollectorGem ();
            propertyGem.setName (makeCollectorName (propertyInfo.name));  
            gemGraph.addGem(propertyGem);
           
            gemGraph.connectGems(messageReflector.getOutputPart(), propertyExtractorGem.getInputPart(0));   
            gemGraph.connectGems(propertyExtractorGem.getOutputPart(), propertyGem.getInputPart(0));   

            bindingContext.addCollector(propertyInfo, propertyGem);
           
            assert graphIsValid() : gemGraph.toString();
View Full Code Here


     */
    private void addCollectorsForMetrics () {
        Collection<MetricDescription> metrics = jobDescription.getMetricDescriptions();
        for (final MetricDescription md : metrics) {
            //create the message reflector
            ReflectorGem messagePropertyReflector = new ReflectorGem (bindingContext.getCollector(md.getPropertyDescription()));
            gemGraph.addGem(messagePropertyReflector);

            //create the gem to compute this metric
            FunctionalAgentGem computeMetricGem = new FunctionalAgentGem(calServices.getGemEntity(md.getGemName()));
            gemGraph.addGem(computeMetricGem);
               
            //create the collector gem for this metric
            CollectorGem metricGem = new CollectorGem ();
            metricGem.setName(makeCollectorName(md.getInternalName()));
            gemGraph.addGem(metricGem);
           
            gemGraph.connectGems( messagePropertyReflector.getOutputPart(), computeMetricGem.getInputPart(0));
            gemGraph.connectGems( computeMetricGem.getOutputPart(), metricGem.getInputPart(0));
           
            bindingContext.addCollector(md, metricGem);
           
            assert graphIsValid() : gemGraph.toString();
View Full Code Here

    public Gem getOutputGem (BasicCALServices calServices, GemGraph gemGraph,
            BindingContext bindingContext) {

        CollectorGem metricCollector = bindingContext.getCollector(metricDescription);
       
        ReflectorGem reflectorGem = new ReflectorGem (metricCollector);
       
        gemGraph.addGem(reflectorGem);
       
        return reflectorGem;
    }
View Full Code Here

     */
    @Override
    public Gem getOutputGem (BasicCALServices calServices, GemGraph gemGraph, BindingContext bindingContext) {
        CollectorGem collectorGem = bindingContext.getCollector(propertyInfo);
       
        ReflectorGem reflectorGem = new ReflectorGem (collectorGem);
       
        gemGraph.addGem(reflectorGem);
       
        return reflectorGem;
    }
View Full Code Here

           
            Gem gem = explorerGemNode.getGem();
           
            if (gem instanceof CollectorGem) {
                CollectorGem collectorGem = (CollectorGem) gem;
                gem = new ReflectorGem(collectorGem);
            }
            tableTopExplorer.getExplorerOwner().beginUndoableEdit();
            dragGestureEvent.startDrag(null, null, mousePointOffset, new TableTopExplorerSelection(gem, tableTopExplorer), this);
                 
        }
View Full Code Here

        CollectorGem avgCollector = new CollectorGem();
        avgCollector.setName("avg");
        gemGraph.addGem(avgCollector);
       
        // a ReflectorGem provides as output the value that is collected by the corresponding CollectorGem
        ReflectorGem sourceDataReflector1 = new ReflectorGem(sourceDataCollector);
        gemGraph.addGem(sourceDataReflector1);
       
        Gem averageGem = gemFactory.makeFunctionalAgentGem(CAL_Summary.Functions.average);
        gemGraph.addGem(averageGem);
       
        gemGraph.connectGems(sourceDataReflector1.getOutputPart(), averageGem.getInputPart(0));
       
        gemGraph.connectGems(averageGem.getOutputPart(), avgCollector.getInputPart(0));
       
        // Local collector: stdDev
        // Corresponding source: stdDev = Summary.populationStandardDeviation sourceData;
        CollectorGem stdDevCollector = new CollectorGem();
        stdDevCollector.setName("stdDev");
        gemGraph.addGem(stdDevCollector);
       
        ReflectorGem sourceDataReflector2 = new ReflectorGem(sourceDataCollector);
        gemGraph.addGem(sourceDataReflector2);
       
        Gem populationStdDevGem = gemFactory.makeFunctionalAgentGem(CAL_Summary.Functions.populationStandardDeviation);
        gemGraph.addGem(populationStdDevGem);
       
        gemGraph.connectGems(sourceDataReflector2.getOutputPart(), populationStdDevGem.getInputPart(0));
       
        gemGraph.connectGems(populationStdDevGem.getOutputPart(), stdDevCollector.getInputPart(0));
       
        // Local collector: isPositiveOutlier
        // Corresponding source: isPositiveOutlier x_1 = x_1 - avg >= x_2 * stdDev;
        CollectorGem isPositiveOutlierCollector = new CollectorGem();
        isPositiveOutlierCollector.setName("isPositiveOutlier");
        gemGraph.addGem(isPositiveOutlierCollector);
       
        Gem subtractGem = gemFactory.makeFunctionalAgentGem(CAL_Prelude.Functions.subtract);
        gemGraph.addGem(subtractGem);
       
        ReflectorGem avgReflector = new ReflectorGem(avgCollector);
        gemGraph.addGem(avgReflector);
       
        // Retarget the first input of subtract to the isPositiveOutlier collector
        //
        // This means that the first input of subtract is no longer an argument for the overall Gem defined by the
        // GemGraph's target collector, but rather a local argument for the isPositiveOutlier collector.
        gemGraph.retargetInputArgument(subtractGem.getInputPart(0), isPositiveOutlierCollector, -1);
        gemGraph.connectGems(avgReflector.getOutputPart(), subtractGem.getInputPart(1));
       
        Gem multiplyGem = gemFactory.makeFunctionalAgentGem(CAL_Prelude.Functions.multiply);
        gemGraph.addGem(multiplyGem);
       
        ReflectorGem stdDevReflector = new ReflectorGem(stdDevCollector);
        gemGraph.addGem(stdDevReflector);
       
        // Leave the first input of multiply targeting the target collector (it will be an argument of the positiveOutlierDetector gem),
        // but hook up the second input of multiply to the stdDev reflector
        gemGraph.connectGems(stdDevReflector.getOutputPart(), multiplyGem.getInputPart(1));
       
        Gem greaterThanEqualsGem = gemFactory.makeFunctionalAgentGem(CAL_Prelude.Functions.greaterThanEquals);
        gemGraph.addGem(greaterThanEqualsGem);
       
        gemGraph.connectGems(subtractGem.getOutputPart(), greaterThanEqualsGem.getInputPart(0));
        gemGraph.connectGems(multiplyGem.getOutputPart(), greaterThanEqualsGem.getInputPart(1));
       
        gemGraph.connectGems(greaterThanEqualsGem.getOutputPart(), isPositiveOutlierCollector.getInputPart(0));
       
        // Update the reflected inputs of the collector because one of the inputs in the gem tree was retargeted
        isPositiveOutlierCollector.updateReflectedInputs();
       
        // Construct the gem tree connected to the target collector
        ReflectorGem isPositiveOutlierReflector = new ReflectorGem(isPositiveOutlierCollector);
        gemGraph.addGem(isPositiveOutlierReflector);

        isPositiveOutlierReflector.getInputPart(0).setBurnt(true);
       
        ReflectorGem sourceDataReflector3 = new ReflectorGem(sourceDataCollector);
        gemGraph.addGem(sourceDataReflector3);
       
        Gem filterGem = gemFactory.makeFunctionalAgentGem(CAL_List.Functions.filter);
        gemGraph.addGem(filterGem);
       
        gemGraph.connectGems(isPositiveOutlierReflector.getOutputPart(), filterGem.getInputPart(0));
        gemGraph.connectGems(sourceDataReflector3.getOutputPart(), filterGem.getInputPart(1));
       
        gemGraph.connectGems(filterGem.getOutputPart(), gemGraph.getTargetCollector().getInputPart(0));
       
        gemGraph.typeGemGraph(calServices.getTypeCheckInfo(GEM_GRAPH_TYPE_CHECKING_MODULE));
       
View Full Code Here

       
        // Construct the test for checking whether the 'list' value is the empty list.
        Gem isEmptyGem = gemFactory.makeFunctionalAgentGem(CAL_Prelude.Functions.isEmpty);
        gemGraph.addGem(isEmptyGem);
       
        ReflectorGem listReflector1 = new ReflectorGem(listCollector);
        gemGraph.addGem(listReflector1);

        // Construct the gem tree for the case when 'list' is not empty.
       
        // The head of the returned Cons is: mapFunction (List.head list)
        // which uses the apply gem to apply the mapFunction to its argument.
        gemGraph.connectGems(listReflector1.getOutputPart(), isEmptyGem.getInputPart(0));

        Gem headGem = gemFactory.makeFunctionalAgentGem(CAL_List.Functions.head);
        gemGraph.addGem(headGem);
       
        ReflectorGem listReflector2 = new ReflectorGem(listCollector);
        gemGraph.addGem(listReflector2);
       
        gemGraph.connectGems(listReflector2.getOutputPart(), headGem.getInputPart(0));
       
        Gem applyGem = gemFactory.makeFunctionalAgentGem(CAL_Prelude.Functions.apply);
        gemGraph.addGem(applyGem);
       
        ReflectorGem mapFunctionReflector1 = new ReflectorGem(mapFunctionCollector);
        gemGraph.addGem(mapFunctionReflector1);
       
        gemGraph.connectGems(mapFunctionReflector1.getOutputPart(), applyGem.getInputPart(0));
        gemGraph.connectGems(headGem.getOutputPart(), applyGem.getInputPart(1));
       
        // The tail of the returned Cons is: demoMap mapFunction (List.tail list)
        Gem tailGem = gemFactory.makeFunctionalAgentGem(CAL_List.Functions.tail);
        gemGraph.addGem(tailGem);

        ReflectorGem listReflector3 = new ReflectorGem(listCollector);
        gemGraph.addGem(listReflector3);
       
        gemGraph.connectGems(listReflector3.getOutputPart(), tailGem.getInputPart(0));
       
        ReflectorGem demoMapReflector = new ReflectorGem(gemGraph.getTargetCollector());
        gemGraph.addGem(demoMapReflector);
       
        ReflectorGem mapFunctionReflector2 = new ReflectorGem(mapFunctionCollector);
        gemGraph.addGem(mapFunctionReflector2);
       
        Gem consGem = gemFactory.makeFunctionalAgentGem(CAL_Prelude.DataConstructors.Cons);
        gemGraph.addGem(consGem);
       
        gemGraph.connectGems(applyGem.getOutputPart(), consGem.getInputPart(0));
        gemGraph.connectGems(demoMapReflector.getOutputPart(), consGem.getInputPart(1));
       
        // Construct the conditional branch (using the iff gem). The false case returns the value
        // generated by the gem tree defined above. In the true case, Nil (the empty list) is returned.
        Gem iffGem = gemFactory.makeFunctionalAgentGem(CAL_Prelude.Functions.iff);
        gemGraph.addGem(iffGem);
       
        Gem nilGem = gemFactory.makeFunctionalAgentGem(CAL_Prelude.DataConstructors.Nil);
        gemGraph.addGem(nilGem);
       
        gemGraph.connectGems(isEmptyGem.getOutputPart(), iffGem.getInputPart(0));
        gemGraph.connectGems(nilGem.getOutputPart(), iffGem.getInputPart(1));
        gemGraph.connectGems(consGem.getOutputPart(), iffGem.getInputPart(2));
       
        // Connect the gems to the target collector
        gemGraph.connectGems(iffGem.getOutputPart(), gemGraph.getTargetCollector().getInputPart(0));
       
        gemGraph.connectGems(mapFunctionReflector2.getOutputPart(), demoMapReflector.getInputPart(0));
       
        gemGraph.connectGems(tailGem.getOutputPart(), demoMapReflector.getInputPart(1));
       
        gemGraph.typeGemGraph(calServices.getTypeCheckInfo(GEM_GRAPH_TYPE_CHECKING_MODULE));
       
View Full Code Here

TOP

Related Classes of org.openquark.gems.client.ReflectorGem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.