Dynamo implementation of project specific metadata spec
322171
def _update_spec_config(self, document_name, spec):
        '''
        

        '''
        # add the updated archive_metadata object to Dynamo
        self._spec_table.update_item(
            Key={'_id': '{}'.format(document_name)},
            UpdateExpression="SET config = :v",
            ExpressionAttributeValues={':v': spec},
            ReturnValues='ALL_NEW')
68390
private void setFromMetadata(Metadata md) {
        // TODO: add pom.properties support?
        String vendorkey = Attributes.Name.IMPLEMENTATION_VENDOR.toString();
        String versionkey = Attributes.Name.IMPLEMENTATION_VERSION.toString();
        String namekey = Attributes.Name.IMPLEMENTATION_TITLE.toString();
        if (this.vendor.equals(UNKNOWN) && md.containsKey(vendorkey)) {
            this.vendor = md.get(vendorkey);
        }
        if (this.version.equals(UNKNOWN) && md.containsKey(versionkey)) {
            this.version = md.get(versionkey);
        }
        if (this.name.equals(UNKNOWN) && md.containsKey(namekey)) {
            this.name = md.get(namekey);
        }
    }
92009
def delete
      if dynamo_tables.empty? && lambdas.empty? && api_gateways.empty?
        puts 'Nothing to Deleting.'
        return
      end

      deployment_start_message = 'Deleting '
      deployment_start_message += "#{dynamo_tables.length} Dynamo Tables, " unless dynamo_tables.empty?
      deployment_start_message += "#{lambdas.length} Lambdas, " unless lambdas.empty?
      deployment_start_message += "#{api_gateways.length} API Gateways " unless api_gateways.empty?
      puts deployment_start_message

      total_time_start = Time.now

      services_time_start = total_time_start
      dynamo_tables.each { |table| table.delete(@dynamo_client, @region) }
      services_time_end = Time.now

      unless dynamo_tables.empty?
        puts "Deleting #{dynamo_tables.length} Table(s) took: \
        #{Time.at(services_time_end - services_time_start).utc.strftime('%H:%M:%S')}"
      end

      services_time_start = Time.now
      lambdas.each { |lambda| lambda.delete(@lambda_client, @region) }
      services_time_end = Time.now

      unless lambdas.empty?
        puts "Deleting #{lambdas.length} Lambda(s) took: \
        #{Time.at(services_time_end - services_time_start).utc.strftime('%H:%M:%S')}"
      end

      services_time_start = Time.now
      api_gateways.each { |apig| apig.delete(@api_gateway_client, @region) }
      services_time_end = Time.now

      unless api_gateways.empty?
        puts "Deleting #{api_gateways.length} API Gateway(s) took: \
        #{Time.at(services_time_end - services_time_start).utc.strftime('%H:%M:%S')}"
      end

      total_time_end = Time.now

      puts "Total API Deletion took: \
      #{Time.at(total_time_end - total_time_start).utc.strftime('%H:%M:%S')}"
      puts 'Successful Deletion of API'

      true
    end
14685
function middlewareStrategy(metadata, dataAdapter, opts) {
    opts.filter = opts.filter || defaultFilter;
    const { filter } = opts;
    return async function magic(ctx, next) {
        const { name, key } = opts.filter.call(null, ctx);
        const obj = metadata[name];
        const { routeSwitch = {} } = obj;

        let middleware;
        if (routeSwitch[key] === true) {
            const { pres, posts } = getHooks(obj, key);
            const route = routes[key];
            middleware = route.call(null, name, dataAdapter, opts, pres, posts);
        }

        try {
            if (typeof middleware === 'function') {
                await middleware.call(null, ctx, next);
            } else {
                await next();
            }
        } catch (err) {
            throw err;
        }
    }
}
47885
def CreateEventMetadata(metric_name,
                        bins=None,
                        fields=None,
                        docstring=None,
                        units=None):
  """"""
  return rdf_stats.MetricMetadata(
      varname=metric_name,
      bins=bins or [],
      metric_type=rdf_stats.MetricMetadata.MetricType.EVENT,
      value_type=rdf_stats.MetricMetadata.ValueType.DISTRIBUTION,
      fields_defs=FieldDefinitionProtosFromTuples(fields or []),
      docstring=docstring,
      units=units)
865458
private <X extends Class, T extends Object> void populateMetadata(EntityMetadata metadata, Class<X> clazz,
            Map puProperties)
    {
        // process for metamodelImpl

        if (metadata.getPersistenceUnit() != null)
        {
            MetaModelBuilder<X, T> metaModelBuilder = kunderaMetadata.getApplicationMetadata().getMetaModelBuilder(
                    metadata.getPersistenceUnit());

            onBuildMetaModelSuperClass(clazz.getSuperclass(), metaModelBuilder);

            metaModelBuilder.process(clazz);

            for (Field f : clazz.getDeclaredFields())
            {
                if (f != null && !Modifier.isStatic(f.getModifiers()) && !Modifier.isTransient(f.getModifiers())
                        && !f.isAnnotationPresent(Transient.class))
                {
                    // construct metamodel.
                    metaModelBuilder.construct(clazz, f);

                    // on id attribute.
                    onIdAttribute(metaModelBuilder, metadata, clazz, f);

                    // determine if it is a column family or super column
                    // family.
                    onFamilyType(metadata, clazz, f);
                }
            }

            EntityType entityType = (EntityType) metaModelBuilder.getManagedTypes().get(metadata.getEntityClazz());

            validateAndSetId(metadata, clazz, metaModelBuilder);
            validateandSetEntityType(metadata, clazz, metaModelBuilder);
            MetadataUtils.onJPAColumnMapping(entityType, metadata);

            /* Scan for Relationship field */
            populateRelationMetaData(entityType, clazz, metadata);
        }
    }
1241297
private void fillMetaData() {
        metaDataBuffer.putInt(MONITOR_VERSION_OFFSET, MONITOR_VERSION);
        metaDataBuffer.putInt(GW_DATA_REFERENCE_OFFSET, GW_DATA_OFFSET);
        metaDataBuffer.putInt(SERVICE_DATA_REFERENCE_OFFSET, serviceDataOffset);
        metaDataBuffer.putStringUtf8(GW_ID_OFFSET, gatewayId, ByteOrder.nativeOrder());
        metaDataBuffer.putInt(gwCountersLblBuffersReferenceOffset, 0);
        metaDataBuffer.putInt(gwCountersLblBuffersLengthOffset, GATEWAY_COUNTER_LABELS_BUFFER_LENGTH);
        metaDataBuffer.putInt(gwCountersValueBuffersReferenceOffset, 0);
        metaDataBuffer.putInt(gwCountersValueBuffersLengthOffset, GATEWAY_COUNTER_VALUES_BUFFER_LENGTH);
        metaDataBuffer.putInt(noOfServicesOffset, 0);
    }
266215
@Override
    public void create(SchemaMigrationMetadata metadata) {
        session.execute(
                insertInto(METADATA_TABLE)
                        .ifNotExists()
                        .value(ID_COL, metadata.getId())
                        .value(INDEX_COL, metadata.getIndex())
                        .value(TOKEN_COL, metadata.getToken())
                        .value(STATUS_COL, metadata.getStatus().name())
                        .value(FINGERPRINT_COL, metadata.getFingerprint()));
    }
945539
private static ITag injectMetaData(IMetaData<?, ?> meta, ITag tag) {
        IoBuffer bb = IoBuffer.allocate(1000);
        bb.setAutoExpand(true);
        Output out = new Output(bb);
        Serializer.serialize(out, "onMetaData");
        Serializer.serialize(out, meta);
        IoBuffer tmpBody = out.buf().flip();
        int tmpBodySize = out.buf().limit();
        int tmpPreviousTagSize = tag.getPreviousTagSize();
        return new Tag(IoConstants.TYPE_METADATA, 0, tmpBodySize, tmpBody, tmpPreviousTagSize);
    }
708679
private void writeChunkMetaData(final BAMIndexMetaData metaData) {
      codec.writeInt(GenomicIndexUtil.MAX_BINS);
      final int nChunk = 2;
      codec.writeInt(nChunk);
      codec.writeLong(metaData.getFirstOffset());
      codec.writeLong(metaData.getLastOffset());
      codec.writeLong(metaData.getAlignedRecordCount());
      codec.writeLong(metaData.getUnalignedRecordCount());

  }
1053435
def BuildCloudMetadataRequests():
  """"""
  amazon_collection_map = {
      "/".join((AMAZON_URL_BASE, "instance-id")): "instance_id",
      "/".join((AMAZON_URL_BASE, "ami-id")): "ami_id",
      "/".join((AMAZON_URL_BASE, "hostname")): "hostname",
      "/".join((AMAZON_URL_BASE, "public-hostname")): "public_hostname",
      "/".join((AMAZON_URL_BASE, "instance-type")): "instance_type",
  }
  google_collection_map = {
      "/".join((GOOGLE_URL_BASE, "instance/id")): "instance_id",
      "/".join((GOOGLE_URL_BASE, "instance/zone")): "zone",
      "/".join((GOOGLE_URL_BASE, "project/project-id")): "project_id",
      "/".join((GOOGLE_URL_BASE, "instance/hostname")): "hostname",
      "/".join((GOOGLE_URL_BASE, "instance/machine-type")): "machine_type",
  }

  return CloudMetadataRequests(requests=_MakeArgs(amazon_collection_map,
                                                  google_collection_map))
1058202
def cli(config, server, api_key, all, credentials, project):
    """"""
    # Check first for the pybossa.rc file to configure server and api-key
    home = expanduser("~")
    if os.path.isfile(os.path.join(home, '.pybossa.cfg')):
        config.parser.read(os.path.join(home, '.pybossa.cfg'))
        config.server = config.parser.get(credentials,'server')
        config.api_key = config.parser.get(credentials, 'apikey')
        try:
            config.all = config.parser.get(credentials, 'all')
        except ConfigParser.NoOptionError:
            config.all = None
    if server:
        config.server = server
    if api_key:
        config.api_key = api_key
    if all:
        config.all = all
    try:
        config.project = json.loads(project.read())
    except JSONDecodeError as e:
        click.secho("Error: invalid JSON format in project.json:", fg='red')
        if e.msg == 'Expecting value':
            e.msg += " (if string enclose it with double quotes)"
        click.echo("%s\n%s: line %s column %s" % (e.doc, e.msg, e.lineno, e.colno))
        raise click.Abort()
    try:
        project_schema = {
            "type": "object",
            "properties": {
                "name": {"type": "string"},
                "short_name": {"type": "string"},
                "description": {"type": "string"}
            }
        }
        jsonschema.validate(config.project, project_schema)
    except jsonschema.exceptions.ValidationError as e:
        click.secho("Error: invalid type in project.json", fg='red')
        click.secho("'%s': %s" % (e.path[0], e.message), fg='yellow')
        click.echo("'%s' must be a %s" % (e.path[0], e.validator_value))
        raise click.Abort()

    config.pbclient = pbclient
    config.pbclient.set('endpoint', config.server)
    config.pbclient.set('api_key', config.api_key)
202886
def compile_swagger_schema(schema_dir, resource_listing):
    
    mapping = build_schema_mapping(schema_dir, resource_listing)
    resource_validators = ingest_resources(mapping, schema_dir)
    endpoints = list(build_swagger_12_endpoints(resource_listing, mapping))
    return SwaggerSchema(endpoints, resource_validators)
1329493
function DataManager(hoist, type, bucket) {
    this.type = type;
    this.hoist = hoist;
    this.url = hoist._configs.data + "/" + type;
    this.bucket = bucket;
  }
289142
private void ensureIndex(DS session, EntityTypeMetadata<NodeMetadata<L>> entityTypeMetadata,
            IndexedPropertyMethodMetadata<IndexedPropertyMetadata> indexedProperty) {
        if (indexedProperty != null) {
            IndexedPropertyMetadata datastoreMetadata = indexedProperty.getDatastoreMetadata();
            if (datastoreMetadata.isCreate()) {
                L label = entityTypeMetadata.getDatastoreMetadata().getDiscriminator();
                PrimitivePropertyMethodMetadata<PropertyMetadata> propertyMethodMetadata = indexedProperty.getPropertyMethodMetadata();
                if (label != null && propertyMethodMetadata != null) {
                    ensureIndex(session, label, propertyMethodMetadata, datastoreMetadata.isUnique());
                }
            }
        }
    }
227267
public Operation setMetadata(Metadata metadata, OperationOption... options) {
    return compute.setMetadata(getInstanceId(), metadata, options);
  }
1084813
def generatemetadata(self, parameters, parentfile, relevantinputfiles, provenancedata = None):
        """"""
        assert isinstance(provenancedata,CLAMProvenanceData) or provenancedata is None

        data = {}

        if self.copymetadata:
            #Copy parent metadata
            for key, value in parentfile.metadata.items():
                data[key] = value

        for metafield in self.metafields:
            if isinstance(metafield, ParameterCondition):
                metafield = metafield.evaluate(parameters)
                if not metafield:
                    continue
            assert isinstance(metafield, AbstractMetaField)
            metafield.resolve(data, parameters, parentfile, relevantinputfiles)

        if provenancedata:
            data['provenance'] = provenancedata

        return self.formatclass(None, **data)