Package org.adfemg.datacontrol.xml.data

Examples of org.adfemg.datacontrol.xml.data.XMLDCElement$Attribute


        InsteadPutHandler putHandler = new InsteadPutHandler() {
            @Override
            public Object doInsteadPut(AttrChangeEvent attrChangeEvent) {
                TransientAttrAdopter.ValueHolder holder =
                    new TransientAttrAdopter.ValueHolder(attrChangeEvent.getNewValue());
                XMLDCElement element = attrChangeEvent.getElement();
                Map<String, Object> props = element.getProperties();
                props.put(propKey, holder);
                return attrChangeEvent.getOldValue();
            }

            @Override
            public boolean handlesAttribute(String input) {
                return attrName.equals(input);
            }
        };
        InsteadGetHandler getHandler = new InsteadGetHandler() {
            @Override
            public Object doInsteadGet(XMLDCElement element) {
                Map<String, Object> props = element.getProperties();
                if (!props.containsKey(propKey)) {
                    // no transient value known yet, invoke annotated method
                    Object value = AdopterUtil.invokeMethod(customizer, method, element);
                    TransientAttrAdopter.ValueHolder holder = new TransientAttrAdopter.ValueHolder(value);
                    props.put(propKey, holder);
View Full Code Here


        // check for situation where the operation comes from a customization-class
        // annotation
        final Object instance = resolveAsExpression(bindingContext, bindings, operationInfo.getInstanceName());
        if (instance instanceof XMLDCElement) {
            XMLDCElement xmldce = (XMLDCElement) instance;
            if (xmldce.hasMethod(methodName, action.getParamsMap())) {
                // TODO: logging
                logger.fine("invoking @Operation method {0} on {1}, new Object[]{methodName, instance}");
                Object result = xmldce.invokeMethod(methodName, action.getParamsMap());
                logger.fine("returning {0}", result);
                processResult(result, bindingContext, action);
                return true; // true to indicate we handled the operation
            }
        }

        // see if invoked method is any one of ours
        DataControlDefinitionNode invokedDef = null;
        for (DataControlDefinitionNode defNode : getDCDefinition().getDefinitionNodes()) {
            if (defNode.getDatacontrolOperation().equals(methodName)) {
                logger.fine("dataControl {0} is handling the {0} datacontrol operation", new Object[] {
                            mName, methodName });
                invokedDef = defNode;
                break;
            }
        }
        if (invokedDef == null) {
            return false; // false means we did not handle this call
        }

        // determine StructureDefinition we should return
        final String beanClassName =
            getDCDefinition().getReturnStructName(getDCDefinition().getStructure(), invokedDef);
        final StructureDefinition structDef = getDCDefinition().findStructure(beanClassName);
        if (structDef == null) {
            throw new IllegalStateException("StructureDefinition " + beanClassName +
                                            " not found in the DataControl Definition: " + getDCDefinition().getName());
        }

        // build DataRequest (clone dynamicParams so we don't alter the ones from binding layer)
        Map<String, Object> mutableParamValues =
            new LinkedHashMap<String, Object>((Map<String, Object>) action.getParamsMap());
        DataRequest dataRequest = new DataRequestImpl(structDef, mutableParamValues, invokedDef);

        // get root XML element from dataProvider
        final DataProvider dataProvider = invokedDef.getProviderInstance(DataProvider.class);
        Element element = dataProvider.getRootElement(dataRequest);
        if (logger.isFine() && !(dataProvider instanceof WSDataProvider)) {
            // TODO: look at root data-provider not most outer provider(filter)
            // TODO: shouldn't each filter log the element at finest so we can see work of each filter
            // WSDataProvider takes care of its own logging
            logger.fine("data-provider {0} returned XML:\n{1}", new Object[] {
                        dataProvider.getClass().getName(), Utils.xmlNodeToString(Utils.toXMLNode(element)) });
        }

        // create XMLDCElement from XML element
        if (element == null) {
            // returning null would cause refresh issues once parameters change and the DC no
            // longer returns null
            element = new EmptyElementProvider().getRootElement(dataRequest);
        }
        final XMLDCElement xmldce = new XMLDCElement(this, structDef, element);

        // write XMLDCElement result to the binding layer
        processResult(xmldce, map, action);

        return true; // true means we handled this call
View Full Code Here

    @Override
    public XMLDCAccessorTarget invokeAccessor(final RowContext rowCtx, final String name, final DataFilter filter) {
        final Object rowDataProvider = rowCtx.getRowDataProvider();
        if (rowDataProvider instanceof XMLDCElement) {
            XMLDCElement elem = (XMLDCElement) rowDataProvider;
            if (!elem.containsAccessor(name)) {
                throw new IllegalArgumentException("XMLDCElement does not have an accessor named : " + name);
            }
            XMLDCAccessorTarget target = (XMLDCAccessorTarget) elem.get(name);
            return target;
        } else {
            throw new IllegalStateException("Unsupported rowDataProvider: " + rowDataProvider);
        }
    }
View Full Code Here

                        ctx.getMasterRowDataProvider(), ctx.getMasterAccessorName(), ctx.getCurrentRowIndex(),
                        ctx.isNullContainer(), ctx.getRowDataContainer(), ctx.getRowDataProvider(),
                        ctx.getRowDataProviderType()
            });
        }
        XMLDCElement master = (XMLDCElement) ctx.getMasterRowDataProvider();
        String accessorName = ctx.getMasterAccessorName();
        XMLDCAccessorTarget newChild;
        if (master.isCollection(accessorName)) {
            if (ctx.isNullContainer()) {
                throw new UnsupportedOperationException("DataControl.createRowData for collection with NullContainer not (yet) supported.");
            }
            XMLDCCollection coll = (XMLDCCollection) ctx.getRowDataContainer();
            newChild = coll.createElement(ctx.getCurrentRowIndex(), master);
        } else {
            Object existingChild = master.get(accessorName);
            if (existingChild instanceof XMLDCAccessorTarget) {
                logger.warning("Ignore the create for {0}.{1} because it already exists.", new Object[] {
                               master, accessorName });
                newChild = (XMLDCAccessorTarget) existingChild;
            } else {
                newChild = master.createChild(accessorName);
            }
        }
        return newChild;
    }
View Full Code Here

                        ctx.getMasterRowDataProvider(), ctx.getMasterAccessorName(), ctx.getCurrentRowIndex(),
                        ctx.isNullContainer(), ctx.getRowDataContainer(), ctx.getRowDataProvider(),
                        ctx.getRowDataProviderType()
            });
        }
        XMLDCElement master = (XMLDCElement) ctx.getMasterRowDataProvider();
        String accessorName = ctx.getMasterAccessorName();
        if (master.isCollection(accessorName)) {
            XMLDCCollection collection = (XMLDCCollection) master.get(accessorName);
            collection.remove(ctx.getCurrentRowIndex());
        } else {
            master.put(accessorName, null);
        }
        return true;
    }
View Full Code Here

                DynamicParameter dynamicParam = findDynamicParameter(paramName, request.getDynamicParams());
                if (dynamicParam.isXml()) {
                    Object dynParVal = request.getDynamicParamValues().get(paramName);
                    if (dynParVal instanceof XMLDCElement) {
                        // dynamic parameter is XMLDCElement, replace #{param.xxx} with org.w3c.dom.Element from XMLDCElement
                        XMLDCElement dcElem = (XMLDCElement) dynParVal;
                        Element elem = dcElem.getElement();
                        Node importedNode = document.importNode(elem, true); // import clones the source node
                        parent.insertBefore(importedNode, node);
                    } else if (dynParVal instanceof Node) {
                        // dynamic parameter is org.w3c.dom.Node (likely Element), replace #{param.xxx} with this Node
                        Node importedNode = document.importNode((Node) dynParVal, true); // import clones the source node
View Full Code Here

                                {
                                    skey.textToShow = trans.get(f);
                                    f = org.size();
                                }

                            Attribute a;
                            if ((a = keyEl.getAttribute(length)) != null)
                                skey.keyWidth = Integer.parseInt(a.getValue());

                            line.add(skey);
                        } else
                            line.add(SpecialKey.getKeyboardKey(fontName, special));
                    }
View Full Code Here

    this.handleQCInformation();

    this.ncFile.addAttribute( null, qcFlagsAtt );

    // Add some general metadata in global attributes.
    this.ncFile.addAttribute( null, new Attribute( "title",
                                                   new StringBuffer("NGDC archived ")
                                                   .append( datasetIdAtt.getStringValue())
                                                   .append( " data with start time ")
                                                   .append( startDateAtt.getStringValue())
                                                   .toString()));
    this.ncFile.addAttribute( null, new Attribute( "Convention", _Coordinate.Convention));

    // Add some THREDDS specific metadata in global attributes.
    this.ncFile.addAttribute( null, new Attribute( "thredds_creator", "DOD/USAF/SMC > Space and Missile Systems Center (SMC), U.S. Air Force, U.S. Department of Defense"));
    this.ncFile.addAttribute( null, new Attribute( "thredds_contributor", "DOC/NOAA/NESDIS/NGDC > National Geophysical Data Center, NESDIS, NOAA, U.S. Department of Commerce"));
    this.ncFile.addAttribute( null, new Attribute( "thredds_contributor_role", "archive"));
    this.ncFile.addAttribute( null, new Attribute( "thredds_publisher", "DOC/NOAA/NESDIS/NGDC > National Geophysical Data Center, NESDIS, NOAA, U.S. Department of Commerce"));
    this.ncFile.addAttribute( null, new Attribute( "thredds_publisher_url", "http://dmsp.ngdc.noaa.gov/"));
    this.ncFile.addAttribute( null, new Attribute( "thredds_publisher_email", "ngdc.dmsp@noaa.gov"));
    this.ncFile.addAttribute( null, new Attribute( "thredds_summary",
                                                   new StringBuffer("This dataset contains data from the DMSP ").append( spacecraftIdAtt.getStringValue())
                                                   .append( " satellite OLS instrument and includes both visible smooth and thermal smooth imagery with 2.7km resolution.")
                                                   .append( " The start time for this data is ").append( startDateAtt.getStringValue())
                                                   .append( " and the northerly equatorial crossing longitude is ").append( startLongitudeAtt.getNumericValue())
                                                   .append( ".  The DMSP satellite is a polar-orbiting satellite crossing the equator, depending on the satellite, at either dawn/dusk or noon/midnight.")
                                                   .append( " This data is in the NOAA/NGDC DMSP archive format.")
                                                   .toString()));
    this.ncFile.addAttribute( null, new Attribute( "thredds_history", ""));
    this.ncFile.addAttribute( null, new Attribute( "thredds_timeCoverage_start", startDateAtt.getStringValue()));
    this.ncFile.addAttribute( null, new Attribute( "thredds_timeCoverage_end", endDateAtt.getStringValue()));
    this.ncFile.addAttribute( null, new Attribute( "thredds_geospatialCoverage",
                                                   new StringBuffer("Polar orbit with northerly equatorial crossing at longitude ")
                                                   .append( ascendingNodeAtt.getNumericValue()).append( ".")
                                                   .toString()));

View Full Code Here

   * @throws IOException if any problems reading the file (or validating the file).
   */
  private void handleFileInformation()
          throws IOException
  {
    fileIdAtt = new Attribute( this.fileIdAttName,
                               (String) headerInfo.get( HeaderInfoTitle.FILE_ID.toString() ) );
    datasetIdAtt = new Attribute( this.datasetIdAttName,
                                  (String) headerInfo.get( HeaderInfoTitle.DATA_SET_ID.toString() ) );
    recordSizeInBytes = Integer.parseInt( (String) headerInfo.get( HeaderInfoTitle.RECORD_BYTES.toString() ) );
    numRecords = Integer.parseInt( (String) headerInfo.get( HeaderInfoTitle.NUM_RECORDS.toString() ) );
    numHeaderRecords = Integer.parseInt( (String) headerInfo.get( HeaderInfoTitle.NUM_HEADER_RECORDS.toString() ) );
    numDataRecords = Integer.parseInt( (String) headerInfo.get( HeaderInfoTitle.NUM_DATA_RECORDS.toString() ) );
View Full Code Here

   * @throws IOException if any problems reading the file (or validating the file).
   */
  private void handleProcessingInformation()
          throws IOException
  {
    suborbitHistoryAtt = new Attribute( this.suborbitHistoryAttName,
                                        (String) headerInfo.get( HeaderInfoTitle.SUBORBIT_HISTORY.toString() ) );
    processingSystemAtt = new Attribute( this.processingSystemAttName,
                                         (String) headerInfo.get( HeaderInfoTitle.PROCESSING_SYSTEM.toString() ) );
    String processingDateString = (String) headerInfo.get( HeaderInfoTitle.PROCESSING_DATE.toString() );
    try
    {
      processingDate = DateFormatHandler.ALT_DATE_TIME.getDateFromDateTimeString( processingDateString );
    }
    catch ( ParseException e )
    {
      throw new IOException( "Invalid DMSP file: processing date string <" + processingDateString + "> not parseable: " + e.getMessage() );
    }
    processingDateAtt = new Attribute(
            this.processingDateAttName,
            DateFormatHandler.ISO_DATE_TIME.getDateTimeStringFromDate( processingDate ) );
  }
View Full Code Here

TOP

Related Classes of org.adfemg.datacontrol.xml.data.XMLDCElement$Attribute

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.