text:
================

## Overview

This module implements the request/response pattern needed for C2D method handling over AMQP for a specific device.

## Exposed API

```c
typedef struct IOTHUBTRANSPORT_AMQP_METHOD_TAG* IOTHUBTRANSPORT_AMQP_METHOD_HANDLE;
typedef struct IOTHUBTRANSPORT_AMQP_METHODS_TAG* IOTHUBTRANSPORT_AMQP_METHODS_HANDLE;
typedef void(*ON_METHODS_ERROR)(void* context);
typedef void(*ON_METHOD_REQUEST_RECEIVED)(void* context, const char* method_name, const unsigned char* request, size_t request_size, IOTHUBTRANSPORT_AMQP_METHOD_HANDLE response);

MOCKABLE_FUNCTION(, IOTHUBTRANSPORT_AMQP_METHODS_HANDLE, iothubtransportamqp_methods_create, const char*, hostname, const char*, device_id);
MOCKABLE_FUNCTION(, void, iothubtransportamqp_methods_destroy, IOTHUBTRANSPORT_AMQP_METHODS_HANDLE, iothubtransport_amqp_methods_handle);
MOCKABLE_FUNCTION(, int, iothubtransportamqp_methods_subscribe, IOTHUBTRANSPORT_AMQP_METHODS_HANDLE, iothubtransport_amqp_methods_handle,
    SESSION_HANDLE, session_handle, ON_METHODS_ERROR, on_methods_error, void*, on_methods_error_context,
    ON_METHOD_REQUEST_RECEIVED, on_method_request_received, void*, on_method_request_received_context);
MOCKABLE_FUNCTION(, int, iothubtransportamqp_methods_respond, IOTHUBTRANSPORT_AMQP_METHOD_HANDLE, method_handle,
        const unsigned char*, response, size_t, response_size, int, status_code);
MOCKABLE_FUNCTION(, void, iothubtransportamqp_methods_unsubscribe, IOTHUBTRANSPORT_AMQP_METHODS_HANDLE, iothubtransport_amqp_methods_handle);
```

### iothubtransportamqp_methods_create

```c
IOTHUBTRANSPORT_AMQP_METHODS_HANDLE iothubtransportamqp_methods_create(const char* hostname, const char* device_id)
```

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_001: [** `iothubtransportamqp_methods_create` shall instantiate a new handler for C2D methods over AMQP for device `device_id` and on success return a non-NULL handle to it. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_002: [** If any argument is NULL, `iothubtransportamqp_methods_create` shall return NULL. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_003: [** `iothubtransportamqp_methods_create` shall allocate memory for the new instance. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_004: [** If allocating memory fails, `iothubtransportamqp_methods_create` shall return NULL. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_115: [** `iothubtransportamqp_methods_create` shall save the device id for later use by using `mallocAndStrcpy_s`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_139: [** `iothubtransportamqp_methods_create` shall save the `hostname` for later use by using `mallocAndStrcpy_s`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_116: [** If `mallocAndStrcpy_s` fails, `iothubtransportamqp_methods_create` shall return NULL. **]**

### iothubtransportamqp_methods_destroy

```c
void iothubtransportamqp_methods_destroy(IOTHUBTRANSPORT_AMQP_METHODS_HANDLE iothubtransport_amqp_methods_handle)
```

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_005: [** `iothubtransportamqp_methods_destroy` shall free all resources allocated by `iothubtransportamqp_methods_create` for the handle `iothubtransport_amqp_methods_handle`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_006: [** If `iothubtransport_amqp_methods_handle` is NULL, `iothubtransportamqp_methods_destroy` shall do nothing. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_007: [** If the instance pointed to by `iothubtransport_amqp_methods_handle` is subscribed to receive C2D methods, `iothubtransportamqp_methods_destroy` shall free all resources allocated by the subscribe. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_110: [** `iothubtransportamqp_methods_destroy` shall free all tracked method handles indicated to the user via the callback `on_method_request_received` and than have not yet been completed by calls to `iothubtransportamqp_methods_respond`. **]**

### iothubtransportamqp_methods_subscribe

```c
int iothubtransportamqp_methods_subscribe(IOTHUBTRANSPORT_AMQP_METHODS_HANDLE iothubtransport_amqp_methods_handle,
    SESSION_HANDLE session_handle, ON_METHODS_ERROR on_methods_error, void* on_methods_error_context,
    ON_METHOD_REQUEST_RECEIVED on_method_request_received, void* on_method_request_received_context);
```

`iothubtransportamqp_methods_subscribe` creates the links needed for the request/response pattern for C2D methods.

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_008: [** On success it shall return 0. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_137: [** `iothubtransportamqp_methods_subscribe` after another succesfull `iothubtransportamqp_methods_subscribe` without any unsubscribe shall return a non-zero value without performing any subscribe action. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_009: [** If any of the argument `iothubtransport_amqp_methods_handle`, `session_handle`, `on_methods_error` or `on_method_request_received` is NULL, `iothubtransportamqp_methods_subscribe` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_010: [** `iothubtransportamqp_methods_subscribe` shall create a receiver link by calling `link_create` with the following arguments: **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_011: [** - `session_handle` shall be the session_handle argument passed to iothubtransportamqp_methods_subscribe **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_012: [** - `name` shall be in the format `methods_requests_link-{device_id}`, where device_id is the `device_id` argument passed to `iothubtransportamqp_methods_create`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_153: [** If constructing the requests link name fails, `iothubtransportamqp_methods_subscribe` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_013: [** - `role` shall be role_receiver. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_014: [** - `source` shall be the a source value created by calling `messaging_create_source`. **]** **SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_015: [** The address string used to create the source shall be of the form `/devices/{device id}/methods/devicebound`. **]** **SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_016: [** The string shall be created by using `STRING_construct_sprintf`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_017: [** - `target` shall be the a target value created by calling `messaging_create_target`. **]** **SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_117: [** The address string used to create the target shall be `requests`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_018: [** If `STRING_construct_sprintf` fails `iothubtransportamqp_methods_subscribe` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_019: [** If creating the target or source values fails `iothubtransportamqp_methods_subscribe` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_020: [** If creating the receiver link fails `iothubtransportamqp_methods_subscribe` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_021: [** `iothubtransportamqp_methods_subscribe` shall create a sender link by calling `link_create` with the following arguments: **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_022: [** - `session_handle` shall be the session_handle argument passed to iothubtransportamqp_methods_subscribe **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_023: [** - `name` shall be format `methods_responses_link-{device_id}`, where device_id is the `device_id` argument passed to `iothubtransportamqp_methods_create`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_154: [** If constructing the responses link name fails, `iothubtransportamqp_methods_subscribe` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_024: [** - `role` shall be role_sender. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_025: [** - `source` shall be the a source value created by calling `messaging_create_source`. **]** **SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_026: [** The address string used to create the target shall be `responses`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_027: [** - `target` shall be the a target value created by calling `messaging_create_target`. **]** **SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_028: [** The address string used to create the source shall be of the form `/devices/{device id}/methods/devicebound`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_031: [** If creating the target or source values fails `iothubtransportamqp_methods_subscribe` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_032: [** If creating the receiver link fails `iothubtransportamqp_methods_subscribe` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_140: [** A link attach properties map shall be created by calling `amqpvalue_create_map`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_141: [** A property key which shall be a symbol named `com.microsoft:channel-correlation-id` shall be created by calling `amqp_create_symbol`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_142: [** A property value of type string that shall contain the device id shall be created by calling `amqpvalue_create_string`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_143: [** The `com.microsoft:channel-correlation-id` shall be added to the link attach properties by calling `amqpvalue_set_map_value`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_150: [** A property key which shall be a symbol named `com.microsoft:api-version` shall be created by calling `amqp_create_symbol`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_151: [** A property value of type string that shall contain the `2016-11-14` shall be created by calling `amqpvalue_create_string`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_152: [** The `com.microsoft:api-version` shall be added to the link attach properties by calling `amqpvalue_set_map_value`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_144: [** The link attach properties shall be set on the receiver and sender link by calling `link_set_attach_properties`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_145: [** If any call for creating or setting the link attach properties fails `iothubtransportamqp_methods_subscribe` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_146: [** The link attach properties and all associated values shall be freed by calling `amqpvalue_destroy` after setting the link attach properties. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_105: [** The string created in order to hold the source and target addresses shall be freed by calling `STRING_delete`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_033: [** `iothubtransportamqp_methods_subscribe` shall create a message receiver associated with the receiver link by calling `messagereceiver_create` and passing the receiver link handle to it. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_118: [** An `on_message_receiver_state_changed` callback together with its context shall be passed to `messagereceiver_create`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_034: [** If `messagereceiver_create` fails, `iothubtransportamqp_methods_subscribe` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_035: [** `iothubtransportamqp_methods_subscribe` shall create a message sender associated with the sender link by calling `messagesender_create` and passing the sender link handle to it. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_106: [** An `on_message_sender_state_changed` callback together with its context shall be passed to `messagesender_create`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_036: [** If `messagesender_create` fails, `iothubtransportamqp_methods_subscribe` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_037: [** `iothubtransportamqp_methods_subscribe` shall open the message sender by calling `messagesender_open`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_038: [** If `messagesender_open` fails, `iothubtransportamqp_methods_subscribe` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_039: [** `iothubtransportamqp_methods_subscribe` shall open the message sender by calling `messagereceiver_open`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_104: [** An `on_message_received` callback together with its context shall be passed to `messagereceiver_open`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_040: [** If `messagereceiver_open` fails, `iothubtransportamqp_methods_subscribe` shall fail and return a non-zero value. **]**

### message_received callback

```c
AMQP_VALUE on_message_received(const void* context, MESSAGE_HANDLE message);
```

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_041: [** If `message` is NULL, the RELEASED outcome shall be returned and an error shall be indicated. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_043: [** When `on_message_received` is called (to indicate a new message being received over the receiver link), the message shall be processed as below: **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_044: [** - The message properties shall be obtained by calling `message_get_properties`. **]**
**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_045: [** If `message_get_properties` fails, the REJECTED outcome with `amqp:decode-error` shall be returned. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_046: [** - The correlation id shall be obtained by calling `properties_get_correlation_id` on the message properties. **]**
**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_047: [** If `properties_get_correlation_id` fails the REJECTED outcome with `amqp:decode-error` shall be returned. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_121: [** The uuid value for the correlation ID shall be obtained by calling `amqpvalue_get_uuid`. **]**
**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_122: [** If `amqpvalue_get_uuid` fails the REJECTED outcome with `amqp:decode-error` shall be returned. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_048: [** - The message payload shall be obtained by calling `message_get_body_amqp_data` with the index argument being 0. **]**
**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_049: [** If `message_get_body_amqp_data` fails the REJECTED outcome with `amqp:decode-error` shall be returned. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_099: [** The application properties for the received message shall be obtained by calling `message_get_application_properties`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_133: [** If `message_get_application_properties` fails the REJECTED outcome with `amqp:decode-error` shall be returned. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_123: [** The AMQP map shall be retrieve from the application properties by calling `amqpvalue_get_inplace_described_value`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_134: [** If `amqpvalue_get_inplace_described_value` fails the RELEASED outcome with `amqp:decode-error` shall be returned. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_100: [** A property key `IoThub-methodname` shall be created by calling `amqpvalue_create_string`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_132: [** If `amqpvalue_create_string` fails the RELEASED outcome shall be returned. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_101: [** The method name property value shall be found in the map by calling `amqpvalue_get_map_value`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_103: [** If `amqpvalue_get_map_value` fails the REJECTED outcome with `amqp:decode-error` shall be returned. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_102: [** The string contained by the property value shall be obtained by calling `amqpvalue_get_string`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_131: [** If `amqpvalue_get_string` fails the REJECTED outcome with `amqp:decode-error` shall be returned. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_050: [** The binary message payload shall be indicated by calling the `on_method_request_received` callback passed to `iothubtransportamqp_methods_subscribe` with the arguments: **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_051: [** - `context` shall be set to the `on_method_request_received_context` argument passed to `iothubtransportamqp_methods_subscribe`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_098: [** - `method_name` shall be set to the application property value for `IoThub-methodname`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_052: [** - `request` shall be set to the payload bytes obtained by calling `message_get_body_amqp_data`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_053: [** - `request_size` shall be set to the payload size obtained by calling `message_get_body_amqp_data`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_054: [** - `method_handle` shall be set to a newly created `IOTHUBTRANSPORT_AMQP_METHOD_HANDLE` that can be passed later as an argument to `iothubtransportamqp_methods_respond`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_112: [** Memory shall be allocated for the `IOTHUBTRANSPORT_AMQP_METHOD_HANDLE` to hold the correlation-id, so that it can be used in the `iothubtransportamqp_methods_respond` function. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_130: [** If allocating memory for the `IOTHUBTRANSPORT_AMQP_METHOD_HANDLE` handle fails, the RELEASED outcome shall be returned and an error shall be indicated. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_147: [** If `on_method_request_received` fails, the REJECTED outcome shall be returned with `amqp:internal-error`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_113: [** All `IOTHUBTRANSPORT_AMQP_METHOD_HANDLE` handles shall be tracked in an array of handles that shall be resized accordingly when a method handle is added to it. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_138: [** If resizing the tracked method handles array fails, the RELEASED outcome shall be returned and an error shall be indicated. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_056: [** On success the `on_message_received` callback shall return a newly constructed delivery state obtained by calling `messaging_delivery_accepted`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_057: [** If `messaging_delivery_accepted` fails the RELEASED outcome with `amqp:decode-error` shall be returned. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_129: [** The released outcome shall be created by calling `messaging_delivery_released`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_128: [** When the RELEASED outcome is returned, an error shall be indicated by calling the `on_methods_error` callback passed to `iothubtransportamqp_methods_subscribe`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_042: [** When an error is indicated by calling the `on_methods_error`, it shall be called with the context being the `on_methods_error_context` argument passed to `iothubtransportamqp_methods_subscribe`. **]**

### on_message_sender_state_changed callback

```c
void on_message_sender_state_changed(void* context, MESSAGE_SENDER_STATE new_state, MESSAGE_SENDER_STATE previous_state)
```

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_059: [** When `on_message_sender_state_changed` is called with the `new_state` being `MESSAGE_SENDER_STATE_ERROR`, an error shall be indicated by calling the `on_methods_error` callback passed to `iothubtransportamqp_methods_subscribe`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_058: [** When an error is indicated by calling the `on_methods_error`, it shall be called with the context being the `on_methods_error_context` argument passed to `iothubtransportamqp_methods_subscribe`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_127: [** For the other state changes, on_message_sender_state_changed shall do nothing. **]**

```c
void on_message_receiver_state_changed(void* context, MESSAGE_RECEIVER_STATE new_state, MESSAGE_RECEIVER_STATE previous_state)
```

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_119: [** When `on_message_receiver_state_changed` is called with the `new_state` being `MESSAGE_RECEIVER_STATE_ERROR`, an error shall be indicated by calling the `on_methods_error` callback passed to `iothubtransportamqp_methods_subscribe`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_120: [** When an error is indicated by calling the `on_methods_error`, it shall be called with the context being the `on_methods_error_context` argument passed to `iothubtransportamqp_methods_subscribe`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_126: [** For the other state changes, on_message_receiver_state_changed shall do nothing. **]**

### on_message_send_complete

```c
void on_message_send_complete(void* context, MESSAGE_SEND_RESULT send_result);
```

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_083: [** If `send_result` is `MESSAGE_SEND_ERROR` then an error shall be indicated by calling the `on_methods_error` callback passed to `iothubtransportamqp_methods_subscribe`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_084: [** Otherwise no action shall be taken. **]**

### iothubtransportamqp_methods_respond

```c
int iothubtransportamqp_methods_respond(IOTHUBTRANSPORT_AMQP_METHOD_HANDLE method_handle, const unsigned char* response, size_t response_size, int status_code);
```

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_060: [** `iothubtransportamqp_methods_respond` shall construct a response message and on success it shall return 0. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_107: [** If the argument `method_handle` is NULL, `iothubtransportamqp_methods_respond` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_108: [** If `response_size` is greater than zero and `response` is NULL, `iothubtransportamqp_methods_respond` shall fail and return a non-zero value. **]**

The steps for creating the response message are:

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_061: [** - A new uAMQP message shall be created by calling `message_create`. **]**
**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_062: [** If the `message_create` call fails, `iothubtransportamqp_methods_respond` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_063: [** - A new properties handle shall be created by calling `properties_create`. **]**
**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_064: [** If the `properties_create call` fails, `iothubtransportamqp_methods_respond` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_124: [** - An AMQP value holding the correlation id associated with the `method_handle` handle shall be created by calling `amqpvalue_create_uuid`. **]**
**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_125: [** If `amqpvalue_create_uuid` fails, `iothubtransportamqp_methods_respond` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_065: [** - The correlation id on the message properties shall be set by calling `properties_set_correlation_id` and passing as argument already create correlation ID AMQP value. **]**
**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_066: [** If the `properties_set_correlation_id` call fails, `iothubtransportamqp_methods_respond` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_148: [** The properties shall be set on the message by calling `message_set_properties`. **]**
**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_149: [** If `message_set_properties` fails, `iothubtransportamqp_methods_respond` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_090: [** An AMQP map shall be created to hold the application properties for the response by calling `amqpvalue_create_map`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_091: [** A property key `IoThub-status` shall be created by calling `amqpvalue_create_string`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_097: [** A property value of type int shall be created from the `status_code` argument by calling `amqpvalue_create_int`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_093: [** A new entry shall be added in the application properties map by calling `amqpvalue_set_map_value` and passing the key and value that were previously created. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_094: [** The application properties map shall be set on the response message by calling `message_set_application_properties`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_095: [** The application property map and all intermediate values shall be freed after being passed to `message_set_application_properties`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_096: [** If any of the calls `amqpvalue_create_string`, `amqpvalue_create_int`, `amqpvalue_create_map`, `amqpvalue_set_map_value` or `message_set_application_properties` fails `iothubtransportamqp_methods_respond` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_078: [** The binary payload for the response shall be set by calling `message_add_body_amqp_data` for the newly created message handle. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_079: [** The field `bytes` of the `binary_data` argument shall be set to the `response` argument value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_080: [** The field `length` of the `binary_data` argument shall be set to the `response_size` argument value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_081: [** If the `message_add_body_amqp_data` call fails, `iothubtransportamqp_methods_respond` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_067: [** The message shall be handed over to the message_sender by calling `messagesender_send` and passing as arguments: **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_068: [** - The response message handle. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_069: [** - A send callback and its context for the `on_message_send_complete` callback. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_071: [** If the `messagesender_send` call fails, `iothubtransportamqp_methods_respond` shall fail and return a non-zero value. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_109: [** `iothubtransportamqp_methods_respond` shall be allowed to be called from the callback `on_method_request_received`. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_114: [** The handle `method_handle` shall be removed from the array used to track the method handles. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_111: [** The handle `method_handle` shall be freed (have no meaning) after `iothubtransportamqp_methods_respond` has been executed. **]**

### iothubtransportamqp_methods_unsubscribe

```c
void iothubtransportamqp_methods_unsubscribe(IOTHUBTRANSPORT_AMQP_METHODS_HANDLE iothubtransport_amqp_methods_handle);
```

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_072: [** If the argument `iothubtransport_amqp_methods_handle` is NULL, `iothubtransportamqp_methods_unsubscribe` shall do nothing. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_135: [** If subscribe was not called yet, `iothubtransportamqp_methods_unsubscribe` shall do nothing. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_136: [** `iothubtransportamqp_methods_unsubscribe` after `iothubtransportamqp_methods_unsubscribe` shall do nothing. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_073: [** Otherwise `iothubtransportamqp_methods_unsubscribe` shall free all resources allocated in `iothubtransportamqp_methods_subscribe`: **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_075: [** - It shall free the message receiver by calling `messagereceiver_destroy'. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_074: [** - It shall free the message sender by calling `messagesender_destroy'. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_076: [** - It shall free the sender link by calling `link_destroy'. **]**

**SRS_IOTHUBTRANSPORT_AMQP_METHODS_01_077: [** - It shall free the receiver link by calling `link_destroy'. **]**


text:
[![Build Status](https://poshsecurity.visualstudio.com/PowerShell/_apis/build/status/AzurePublicIPAddresses?branchName=master)](https://poshsecurity.visualstudio.com/PowerShell/_build/latest?definitionId=36&branchName=master)

## Description

Gets the IP ranges associated with Azure regions in CIDR format for all public regions.

Authored by Kieran Jacobsen

## Installing

The easiest way to get AzurePublicIPAddresses is using the [PowerShell Gallery](https://powershellgallery.com/packages/AzurePublicIPAddresses/)!

### Inspecting the module

Best practice is that you inspect modules prior to installing them. You can do this by saving the module to a local path:

``` PowerShell
PS> Save-Module -Name AzurePublicIPAddresses -Path <path>
```

### Installing the module

Once you trust a module, you can install it using:

``` PowerShell
PS> Install-Module -Name AzurePublicIPAddresses
```

### Updating AzurePublicIPAddresses

Once installed from the PowerShell Gallery, you can update it using:

``` PowerShell
PS> Update-Module -Name AzurePublicIPAddresses
```

### Removing AzurePublicIPAddresses

To remove AzurePublicIPAddresses:

``` PowerShell
PS> Uninstall-Module -Name AzurePublicIPAddresses
```

## Contributing to AzurePublicIPAddresses

Interested in contributing? Read how you can [Contribute](contributing.md) to AzurePublicIPAddresses

This project is maintains a [Code of Conduct](code-of-conduct.md) that establishes how the project is governed and how everyone involved is expected to behave. You can report unacceptable behavior to [code@poshsecurity.com](mailto:code@poshsecurity.com).

## Release History

A detailed release history is contained in the [Change Log](CHANGELOG.md).

## License

AzurePublicIPAddresses is provided under the [MIT license](LICENSE.md).

redpajama_set_name: RedPajamaGithub


text:
namespace Colorful
{
	using UnityEngine;

	[HelpURL("http://www.thomashourdel.com/colorful/doc/camera-effects/rgb-split.html")]
	[ExecuteInEditMode]
	[AddComponentMenu("Colorful FX/Camera Effects/RGB Split")]
	public class RGBSplit : BaseEffect
	{
		[Tooltip("RGB shifting amount.")]
		public float Amount = 0f;

		[Tooltip("Shift direction in radians.")]
		public float Angle = 0f;

		protected override void OnRenderImage(RenderTexture source, RenderTexture destination)
		{
			if (Amount == 0f)
			{
				Graphics.Blit(source, destination);
				return;
			}

			Material.SetVector("_Params", new Vector3(
					Amount * 0.001f,
					Mathf.Sin(Angle),
					Mathf.Cos(Angle)
				));

			Graphics.Blit(source, destination, Material);
		}

		protected override string GetShaderName()
		{
			return "Hidden/Colorful/RGB Split";
		}
	}
}


text:
module.exports = function (grunt) {

    // configure the tasks
    grunt.initConfig({
        copy: {
            build: {
                cwd: 'app',
                src: ['index.html', 'app.js', 'view1/*', 'components/**', '!**/*_test.js'],
                dest: 'build',
                expand: true
            }
        },
        clean: {
            build: {
                src: ['build']
            },
            stylesheets: {
                src: ['build/**/*.css', '!build/application.css']
            },
            scripts: {
                src: ['build/**/*.js', '!build/application.js']
            }
        },
        cssmin: {
            build: {
                files: {
                    'build/application.css': ['app/bower_components/html5-boilerplate/dist/css/normalize.css',
                        'app/bower_components/html5-boilerplate/dist/css/main.css',
                        'app/bower_components/bootstrap/dist/css/bootstrap.min.css', 'app/app.css']
                }
            }
        },
        uglify: {
            build: {
                options: {
                    mangle: false,
                    beautify: true
                },
                files: {
                    'build/application.js': [
                        //'app/bower_components/html5-boilerplate/dist/js/vendor/modernizr-2.8.3.min.js',
                        'app/bower_components/angular/angular.min.js',
                        'app/bower_components/angular-route/angular-route.min.js',
                        'app/bower_components/jquery/dist/jquery.min.js',
                        'app/bower_components/bootstrap/dist/js/bootstrap.min.js',
                        'build/app.js',
                        'build/**/*.js'
                    ]
                }
            }
        },
        cleanempty: {
            options: {},
            src: ['build/**']
        }
    });

    // load the tasks
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-cleanempty');

    // define the tasks

    grunt.registerTask(
        'stylesheets',
        'Compiles the stylesheets.',
        ['cssmin', 'clean:stylesheets']
    );

    grunt.registerTask(
        'scripts',
        'Compiles the JavaScript files.',
        ['uglify', 'clean:scripts']
    );

    grunt.registerTask(
        'build',
        'Compiles all of the assets and copies the files to the build directory.',
        ['clean:build', 'copy', 'stylesheets', 'scripts', 'cleanempty']
    );
};


text:
export class ShoppingList {
    id: number;
    name: string;
}


text:
package org.assertj.core.description;

import static java.util.UUID.randomUUID;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.rules.ExpectedException.none;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

/**
 * Tests for <code>{@link TextDescription#TextDescription(String)}</code>.
 *
 * @author Yvonne Wang
 * @author Alex Ruiz
 */
public class TextDescription_constructor_Test {

  @Rule
  public ExpectedException thrown = none();

  @Test
  public void should_set_value() {
    String value = randomText();
    TextDescription description = new TextDescription(value);
    assertThat(description.value).isEqualTo(value);
  }

  private static String randomText() {
    return randomUUID().toString();
  }

  @SuppressWarnings("unused")
  @Test
  public void should_throw_error_if_value_is_null() {
    thrown.expect(NullPointerException.class);
    new TextDescription(null);
  }
}


text:
This repository contains **Dockerbase** of [Nginx](http://nginx.org/) for [Docker](https://www.docker.com/)'s [Dockerbase build](https://registry.hub.docker.com/u/dockerbase/nginx/) published on the public [Docker Hub Registry](https://registry.hub.docker.com/).

### Depends on:

* [dockerbase/service](https://registry.hub.docker.com/u/library/service/)

### Installation

1. Install [Docker](https://docs.docker.com/installation/).

2. Download [Dockerbase build](https://registry.hub.docker.com/u/dockerbase/nginx/) from public [Docker Hub Registry](https://registry.hub.docker.com/): `docker pull dockerbase/nginx`

### Usage

    run:
        sudo docker run --restart=always -t --cidfile cidfile -d dockerbase/nginx /sbin/runit

    start:
        sudo docker start `cat cidfile`

    stop:
        sudo docker stop -t 10 `cat cidfile`

### Information
[Components & Versions](https://github.com/dockerbase/nginx/blob/master/COMPONENTS)


text:
using System;
using Tessin.Tin.Models.Extensions;

namespace Tessin.Tin
{

    public enum TinSeparatorPosition
    {
        None = 0,
        AfterDate = 1,
        AfterSerial = 2
    }

    public enum TinDateFormat
    {
        YearMonthDay = 1,
        DayMonthYear = 2
    }

    public enum TinYearFormat
    {
        Short = 1,
        Long = 0
    }

    public class TinParts
    {

        public TinParts()
        {
        }

        public TinParts(TinDateFormat dateFormat, TinYearFormat yearFormat)
        {
            DateFormat = dateFormat;
            YearFormat = yearFormat;
        }

        public int? LongYearNumeric => Century + YearNumeric;

        public string Year { get; set; }

        public string Month { get; set; }

        public string Day { get; set; }

        public int? Century { get; set; }

        public string Serial { get; set; }

        public int? YearNumeric => Year.ToNullableInteger();

        public int? MonthNumeric => Month.ToNullableInteger();

        public int? DayNumeric => Day.ToNullableInteger();

        public int SerialNumeric => Serial.ToInteger();

        public string Separator { get; set; }

        public string Checksum { get; set; }

        public TinYearFormat YearFormat { get; set; }

        public TinDateFormat DateFormat { get; set; }

        public TinSeparatorPosition SeparatorPosition { get; set; }

        public bool HasDate => !string.IsNullOrEmpty(Year) && !string.IsNullOrEmpty(Month) && !string.IsNullOrEmpty(Day);

        public override string ToString()
        {
            return ToString(true);
        }

        public string ToStringWithoutChecksum()
        {
            return ToString(false);
        }

        private string ToString(bool includeChecksum)
        {
            var year = YearFormat == TinYearFormat.Long ? LongYearNumeric?.ToString("0000") : YearNumeric?.ToString("00");
            string datePart = "";
            if (HasDate)
            {
                switch (DateFormat)
                {
                    case TinDateFormat.YearMonthDay:
                        datePart = $"{year}{Month}{Day}";
                        break;
                    case TinDateFormat.DayMonthYear:
                        datePart = $"{Day}{Month}{year}";
                        break;
                    default:
                        throw new Exception("Unknown date format.");
                }
            }
            var separatorAfterDate = SeparatorPosition == TinSeparatorPosition.AfterDate ? Separator : "";
            var separatorAfterSerial = SeparatorPosition == TinSeparatorPosition.AfterSerial ? Separator : "";
            var checksum = includeChecksum ? Checksum : "";
            return $"{datePart}{separatorAfterDate}{Serial}{separatorAfterSerial}{checksum}";
        }

        public DateTime? GetDate()
        {
            var year = LongYearNumeric;
            var month = MonthNumeric;
            var day = DayNumeric;
            if (year == null || month == null || day == null) return null;
            if (!Utils.IsValidDate(year.Value, month.Value, day.Value)) return null;
            return new DateTime(year.Value, month.Value, day.Value, 0, 0, 0);
        }

        public void SetDateInfo(string date, TinDateFormat format)
        {
            if (date.Length != 6) throw new ArgumentException("The datestring must be exactly 6 characters long.");

            var p1 = date.Substring(0, 2);
            var p2 = date.Substring(2, 2);
            var p3 = date.Substring(4, 2);
            switch (format)
            {
                case TinDateFormat.YearMonthDay:
                    Year = p1;
                    Month = p2;
                    Day = p3;
                    break;
                case TinDateFormat.DayMonthYear:
                    Year = p3;
                    Month = p2;
                    Day = p1;
                    break;
                default:
                    throw new ArgumentOutOfRangeException(nameof(format));
            }
        }

    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<colorTheme id="33164" name="Base16 Eighties" modified="2014-12-14 18:53:33" author="Gary Ash">
    <searchResultIndication color="#000000" />
    <filteredSearchResultIndication color="#000000" />
    <occurrenceIndication color="#000000" />
    <writeOccurrenceIndication color="#000000" />
    <findScope color="#111111" />
    <deletionIndication color="#D25252" />
    <sourceHoverBackground color="#000000" />
    <singleLineComment color="#747369" italic="false" />
    <multiLineComment color="#747369" italic="false" />
    <commentTaskTag color="#747369" italic="false" />
    <javadoc color="#747369" italic="false" />
    <javadocLink color="#747369" italic="false" />
    <javadocTag color="#747369" italic="false" />
    <javadocKeyword color="#D9E577" italic="false" />
    <class color="#FFCC66" bold="false" underline="false" strikethrough="false" />
    <interface color="#FFCC66" />
    <method color="#6699CC" />
    <methodDeclaration color="#6699CC" />
    <bracket color="#D8D8D8" />
    <number color="#F99157" />
    <string color="#D3D0C8" />
    <operator color="#D3D0C8" />
    <keyword color="#CC99CC" bold="false" />
    <annotation color="#D3D0C8" />
    <staticMethod color="#6699CC" />
    <localVariable color="#F2777A" />
    <localVariableDeclaration color="#F2777A" />
    <field color="#F2777A" />
    <staticField color="#EFC090" />
    <staticFinalField color="#EFC090" />
    <deprecatedMember color="#D25252" underline="false" strikethrough="true" />
    <enum color="#F99157" />
    <inheritedMethod color="#FFCC66" />
    <abstractMethod color="#FFCC66" />
    <parameterVariable color="#79ABFF" />
    <typeArgument color="#FFCC66" />
    <typeParameter color="#FFCC66" />
    <constant color="#F99157" />
    <background color="#2D2D2D" />
    <currentLine color="#2A2A2A" />
    <foreground color="#D3D0C8" />
    <lineNumber color="#D0D0D0" />
    <selectionBackground color="#515151" />
    <selectionForeground color="#D0D0D0" />
</colorTheme>


text:
<?php
namespace Users\Controller;

use Zend\View\Model\ViewModel;
use Users\Controller\BaseController;

class UploadManagerController extends BaseController{

    public function indexAction() {
        $uploadForm = $this->getUploadForm();
        $uploadForm->prepare();

        $isFileUploadRequested = $this->getRequest()->isPost();

        if ($isFileUploadRequested) {
            $this->uploadFile($uploadForm);
        }

        return new ViewModel(array('myUploads' => $this->getUploadedFiles(), 'form' => $uploadForm));
    }
    public function deleteAction(){
        $this->getServiceLocator()->get('UploadTable')->deleteUpload($this->params()->fromRoute('id'));
        return $this->redirect()->toRoute(null, array('controller' => 'upload-manager', 'action' => 'index'));
    }
    private function getUploadedFiles() {
        $uploadTable = $this->getServiceLocator()->get('UploadTable');
        return $uploadTable->getUploadsByUserId($this->getCurrentUserId());
    }

    private function getUploadForm() {
        $form = $this->getServiceLocator()->get('UploadForm');
        $form->setAttribute('action', $this->url()->fromRoute(null, array('controller' => 'upload-manager', 'action' => 'index')));
        $form->setAttribute('method', 'post');
        return $form;
    }

    private function uploadFile($uploadForm) {
        $uploadForm->setData($this->getRequest()->getPost());
        if (!$uploadForm->isValid()) {
            return;
        }

        $uploadFileName = $this->params()->fromFiles('fileupload')['name'];

        if ($this->receiveUploadFile($uploadFileName)) {
            $uploadTable = $this->getServiceLocator()->get('UploadTable');
            try {
                $uploadTable->saveUpload($this->createUploadModel($this->request->getPost()->get('label'), $uploadFileName));
            }
            catch (\Users\Model\DuplicateEntryException $e) {
                $uploadForm->MarkFilenameAsDublicate();
            }
        }
    }

    private function receiveUploadFile($uploadFileName) {
        $adapter = new \Zend\File\Transfer\Adapter\Http();
        $adapter->setDestination($this->getFileUploadLocation());

        return $adapter->receive($uploadFileName);
    }

    private function getFileUploadLocation(){
        $config = $this->getServiceLocator()->get('config');
        return $config['module_config']['upload_location'];
    }

    private function createUploadModel($label, $filename) {
        $upload = new \Users\Model\Upload();
        $upload->exchangeArray(array('label' => $label, 'filename' => $filename, 'user_id' => $this->getCurrentUserId()));
        return $upload;
    }

    private function getCurrentUserId() {
        return $this->getAuthService()->getStorage()->read()->getId();
    }
}


text:
require 'test_helper'

class SamuelTest < Test::Unit::TestCase

  context "logger configuration" do
    setup do
      Samuel.logger = nil
      if Object.const_defined?(:RAILS_DEFAULT_LOGGER)
        Object.send(:remove_const, :RAILS_DEFAULT_LOGGER)
      end
    end

    teardown do
      Samuel.logger = nil
    end

    context "when Rails's logger is available" do
      setup { Object.const_set(:RAILS_DEFAULT_LOGGER, :mock_logger) }

      should "use the same logger" do
        assert_equal :mock_logger, Samuel.logger
      end
    end

    context "when Rails's logger is not available" do
      should "use a new Logger instance pointed to STDOUT" do
        assert_instance_of Logger, Samuel.logger
        assert_equal STDOUT, Samuel.logger.instance_variable_get(:"@logdev").dev
      end
    end
  end

  context ".reset_config" do
    should "reset the config to default vaules" do
      Samuel.config = {:foo => "bar"}
      Samuel.reset_config
      assert_equal({:label => nil, :labels => {"" => "HTTP"}, :filtered_params => []}, Samuel.config)
    end
  end

end


text:
<?php

declare(strict_types=1);

namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\FakerData\String;

use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\FakerData\AbstractFakerDataProvider;
use Faker\Generator;
use Symfony\Component\Intl\Intl;

class UnicodeLanguageIdentifierFakerData extends AbstractFakerDataProvider
{
    /**
     * @var array
     */
    private $languages;

    public function __construct(Generator $generator)
    {
        parent::__construct($generator);
        $this->languages = Intl::getLanguageBundle()->getLanguageNames();
    }

    public function __invoke()
    {
        do {
            $language = $this->generator->languageCode;
        } while (!isset($this->languages[$language]));

        return $language;
    }
}


text:
package org.citygml4j.xml.reader;

import org.citygml4j.core.model.CityGMLObject;
import org.citygml4j.core.model.core.AbstractFeature;
import org.xml.sax.SAXException;
import org.xmlobjects.XMLObjects;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.builder.ObjectBuilder;
import org.xmlobjects.stream.EventType;
import org.xmlobjects.stream.XMLReadException;
import org.xmlobjects.stream.XMLReader;
import org.xmlobjects.stream.XMLReaderFactory;

import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.TransformerException;
import java.util.NoSuchElementException;

public class CityGMLSimpleReader extends CityGMLReader {
    private final XMLReaderFactory factory;

    private boolean hasNext = false;

    public CityGMLSimpleReader(XMLReader reader, XMLReaderFactory factory) {
        super(reader);
        this.factory = factory;
    }

    @Override
    public boolean hasNext() throws CityGMLReadException {
        if (!hasNext) {
            try {
                XMLObjects xmlObjects = reader.getXMLObjects();
                while (reader.hasNext()) {
                    if (reader.nextTag() == EventType.START_ELEMENT) {
                        QName name = reader.getName();
                        if (filter == null || filter.accept(name)) {
                            ObjectBuilder<AbstractFeature> builder = xmlObjects.getBuilder(name, AbstractFeature.class);
                            if (builder != null && CityGMLObject.class.isAssignableFrom(xmlObjects.getObjectType(name.getNamespaceURI(), builder))) {
                                hasNext = true;
                                break;
                            }
                        } else {
                            int skipUntil = reader.getDepth() - 1;
                            while (reader.getDepth() != skipUntil)
                                reader.nextTag();
                        }
                    }
                }
            } catch (XMLReadException e) {
                throw new CityGMLReadException("Caused by:", e);
            }
        }

        return hasNext;
    }

    @Override
    public AbstractFeature next() throws CityGMLReadException {
        if (hasNext()) {
            try {
                AbstractFeature feature;
                if (transformer == null) {
                    feature = reader.getObject(AbstractFeature.class);
                    if (feature != null && resolver != null)
                        resolver.resolveReferences(feature);
                } else
                    feature = nextChunk().build(true);

                return feature;
            } catch (ObjectBuildException | XMLReadException e) {
                throw new CityGMLReadException("Caused by:", e);
            } finally {
                hasNext = false;
            }
        }

        throw new NoSuchElementException();
    }

    @Override
    public CityGMLChunk nextChunk() throws CityGMLReadException {
        if (hasNext()) {
            try {
                XMLStreamReader reader = this.reader.getStreamReader();
                CityGMLChunk chunk = new CityGMLChunk(reader.getName(), factory, resolver);

                do {
                    chunk.bufferEvent(reader);
                    if (chunk.isComplete())
                        break;
                } while (reader.hasNext() && reader.next() >= 0);

                if (transformer != null)
                    chunk.transform(transformer);

                return chunk;
            } catch (XMLStreamException | SAXException | TransformerException e) {
                throw new CityGMLReadException("Caused by:", e);
            } finally {
                hasNext = false;
            }
        }

        throw new NoSuchElementException();
    }
}


text:
package kodkod.ast;

import kodkod.ast.operator.IntOperator;
import kodkod.ast.visitor.ReturnVisitor;
import kodkod.ast.visitor.VoidVisitor;

/**
 * A unary integer intExpr, e.g. -x.
 * @specfield intExpr: IntExpression
 * @specfield op: IntOperator
 * @invariant op.unary()
 * @invariant children = 0->intExpr
 * @author Emina Torlak
 */
public final class UnaryIntExpression extends IntExpression {
	private final IntOperator op;
	private final IntExpression intExpr;

	/**
	 * Constructs a new unary int formula: op intExpr
	 * @ensures this.op' = op && this.intExpr' = intExpr
	 */
	UnaryIntExpression(IntOperator op, IntExpression intExpr) {
		if (!op.unary()) throw new IllegalArgumentException("Not a unary operator: " + op);
		this.op = op;
		this.intExpr = intExpr;
	}

	/**
	 * Returns the operator of this.
	 * @return this.op
	 */
	public IntOperator op() {return op;}

	/**
	 * Returns this.intExpr.
	 * @return this.intExpr
	 */
	public IntExpression intExpr() {return intExpr;}

	/**
	 * {@inheritDoc}
	 * @see kodkod.ast.IntExpression#accept(kodkod.ast.visitor.ReturnVisitor)
	 */
	@Override
	public <E, F, D, I> I accept(ReturnVisitor<E, F, D, I> visitor) {
		return visitor.visit(this);
	}

	/**
	 * {@inheritDoc}
	 * @see kodkod.ast.IntExpression#accept(kodkod.ast.visitor.VoidVisitor)
	 */
	@Override
	public void accept(VoidVisitor visitor) {
		visitor.visit(this);
	}

	/**
     * {@inheritDoc}
     * @see kodkod.ast.Node#toString()
     */
	public String toString() {
		return (op==IntOperator.NEG||op==IntOperator.NOT) ? "(" + op + intExpr + ")" : op + "(" + intExpr + ")" ;
	}
}


text:
(function () {
    'use strict';

    function authorization(identity) {
        return {
            getAuthorizationHeader: function () {
                if (!identity.isAuthenticated()) {
                    return {};
                }

                return {
                    'Authorization': 'Bearer ' + identity.getCurrentUser()['access_token']
                }
            }
        }
    }

    angular.module('SourceControlSystem.services')
        .factory('authorization', ['identity', authorization]);
}());


text:
using Inflatable.ClassMapper;
using Inflatable.Interfaces;
using Inflatable.QueryProvider;
using Inflatable.QueryProvider.Enums;
using Inflatable.QueryProvider.Providers.SQLServer;
using Inflatable.QueryProvider.Providers.SQLServer.QueryGenerators;
using Inflatable.Schema;
using Inflatable.Tests.BaseClasses;
using Inflatable.Tests.MockClasses;
using Inflatable.Tests.TestDatabases.ComplexGraph;
using Inflatable.Tests.TestDatabases.ComplexGraph.Mappings;
using Inflatable.Tests.TestDatabases.ManyToManyProperties;
using Inflatable.Tests.TestDatabases.ManyToOneProperties;
using Inflatable.Tests.TestDatabases.ManyToOneProperties.Mappings;
using Inflatable.Tests.TestDatabases.SimpleTestWithDatabase;
using System.Data;
using System.Linq;
using Xunit;

namespace Inflatable.Tests.QueryProvider.Providers.SQLServer.QueryGenerators
{
    public class DeletePropertiesQueryTests : TestingFixture
    {
        [Fact]
        public void Creation()
        {
            var Mappings = new MappingSource(new IMapping[] {
                new BaseClass1Mapping(),
                new ConcreteClass1Mapping(),
                new ConcreteClass2Mapping(),
                new ConcreteClass3Mapping(),
                new IInterface1Mapping(),
                new IInterface2Mapping()
            },
                new MockDatabaseMapping(),
                new QueryProviderManager(new[] { new SQLServerQueryProvider(Configuration, ObjectPool, GetLogger<SQLHelperDB.SQLHelper>()) }, GetLogger<QueryProviderManager>()),
            GetLogger<MappingSource>(),
            ObjectPool);
            var TestObject = new DeletePropertiesQuery<ConcreteClass1>(Mappings, ObjectPool);
            Assert.Equal(typeof(ConcreteClass1), TestObject.AssociatedType);
            Assert.Same(Mappings, TestObject.MappingInformation);
            Assert.Equal(QueryType.JoinsDelete, TestObject.QueryType);
        }

        [Fact]
        public void GenerateDeclarations()
        {
            var Mappings = new MappingSource(new IMapping[] {
                new BaseClass1Mapping(),
                new ConcreteClass1Mapping(),
                new ConcreteClass2Mapping(),
                new ConcreteClass3Mapping(),
                new IInterface1Mapping(),
                new IInterface2Mapping()
            },
                   new MockDatabaseMapping(),
                   new QueryProviderManager(new[] { new SQLServerQueryProvider(Configuration, ObjectPool, GetLogger<SQLHelperDB.SQLHelper>()) }, GetLogger<QueryProviderManager>()),
               GetLogger<MappingSource>(),
               ObjectPool);
            var TestObject = new DeletePropertiesQuery<ConcreteClass1>(Mappings, ObjectPool);
            var Result = TestObject.GenerateDeclarations();
            Assert.Equal(CommandType.Text, Result[0].DatabaseCommandType);
            Assert.Empty(Result[0].Parameters);
            Assert.Equal("", Result[0].QueryString);
            Assert.Equal(QueryType.JoinsDelete, Result[0].QueryType);
        }

        [Fact]
        public void GenerateQuery()
        {
            var Mappings = new MappingSource(new IMapping[] {
                new BaseClass1Mapping(),
                new ConcreteClass1Mapping(),
                new ConcreteClass2Mapping(),
                new ConcreteClass3Mapping(),
                new IInterface1Mapping(),
                new IInterface2Mapping()
            },
                   new MockDatabaseMapping(),
                   new QueryProviderManager(new[] { new SQLServerQueryProvider(Configuration, ObjectPool, GetLogger<SQLHelperDB.SQLHelper>()) }, GetLogger<QueryProviderManager>()),
               GetLogger<MappingSource>(),
               ObjectPool);
            var TestObject = new DeletePropertiesQuery<ConcreteClass1>(Mappings, ObjectPool);
            var Result = TestObject.GenerateQueries(new ConcreteClass1 { ID = 10, BaseClassValue1 = 1, Value1 = 2 })[0];
            Assert.Equal(CommandType.Text, Result.DatabaseCommandType);
            Assert.Empty(Result.Parameters);
            Assert.Equal("", Result.QueryString);
            Assert.Equal(QueryType.JoinsDelete, Result.QueryType);
        }

        [Fact]
        public void GenerateQueryWithManyToManyProperties()
        {
            var Mappings = new MappingSource(new IMapping[] {
                new AllReferencesAndIDMappingWithDatabase(),
                new ManyToManyPropertiesMapping()
            },
                   new MockDatabaseMapping(),
                   new QueryProviderManager(new[] { new SQLServerQueryProvider(Configuration, ObjectPool, GetLogger<SQLHelperDB.SQLHelper>()) }, GetLogger<QueryProviderManager>()),
               GetLogger<MappingSource>(),
               ObjectPool);
            var ManyToManyProperty = Mappings.Mappings[typeof(ManyToManyProperties)].ManyToManyProperties.First();
            var TempDataModel = new Inflatable.Schema.DataModel(Mappings, Configuration, DataModeler, Sherlock, Helper, GetLogger<SchemaManager>());
            ManyToManyProperty.Setup(Mappings, TempDataModel.SourceSpec);
            var TestObject = new DeletePropertiesQuery<ManyToManyProperties>(Mappings, ObjectPool);
            var TempManyToMany = new ManyToManyProperties { ID = 10, BoolValue = true };
            TempManyToMany.ManyToManyClass.Add(new TestDatabases.SimpleTest.AllReferencesAndID { ID = 1 });
            TempManyToMany.ManyToManyClass.Add(new TestDatabases.SimpleTest.AllReferencesAndID { ID = 2 });
            var Result = TestObject.GenerateQueries(TempManyToMany, ManyToManyProperty)[0];
            Assert.Equal(CommandType.Text, Result.DatabaseCommandType);
            Assert.Single(Result.Parameters);
            Assert.Equal(10, Result.Parameters[0].InternalValue);
            Assert.Equal("ManyToManyProperties_ID_", Result.Parameters[0].ID);
            Assert.Equal("DELETE FROM [dbo].[AllReferencesAndID_ManyToManyProperties] WHERE ([dbo].[AllReferencesAndID_ManyToManyProperties].[ManyToManyProperties_ID_] = @ManyToManyProperties_ID_);", Result.QueryString);
            Assert.Equal(QueryType.JoinsDelete, Result.QueryType);
        }

        [Fact]
        public void GenerateQueryWithManyToOneManyProperties()
        {
            var Mappings = new MappingSource(new IMapping[] {
                new ManyToOneManyPropertiesMapping(),
                new ManyToOneOnePropertiesMapping()
            },
                   new MockDatabaseMapping(),
                   new QueryProviderManager(new[] { new SQLServerQueryProvider(Configuration, ObjectPool, GetLogger<SQLHelperDB.SQLHelper>()) }, GetLogger<QueryProviderManager>()),
               GetLogger<MappingSource>(),
               ObjectPool);
            var ManyToOneProperty = Mappings.Mappings[typeof(ManyToOneManyProperties)].ManyToOneProperties.First();
            var TempDataModel = new Inflatable.Schema.DataModel(Mappings, Configuration, DataModeler, Sherlock, Helper, GetLogger<SchemaManager>());
            ManyToOneProperty.Setup(Mappings, TempDataModel.SourceSpec);
            var TestObject = new DeletePropertiesQuery<ManyToOneManyProperties>(Mappings, ObjectPool);
            var TempManyToOne = new ManyToOneManyProperties { ID = 10, BoolValue = true };
            TempManyToOne.ManyToOneClass.Add(new ManyToOneOneProperties { ID = 1 });
            TempManyToOne.ManyToOneClass.Add(new ManyToOneOneProperties { ID = 2 });
            var Result = TestObject.GenerateQueries(TempManyToOne, ManyToOneProperty);
            Assert.Empty(Result);
        }

        [Fact]
        public void GenerateQueryWithManyToOneSingleProperties()
        {
            var Mappings = new MappingSource(new IMapping[] {
                new ManyToOneManyPropertiesMapping(),
                new ManyToOneOnePropertiesMapping()
            },
                   new MockDatabaseMapping(),
                   new QueryProviderManager(new[] { new SQLServerQueryProvider(Configuration, ObjectPool, GetLogger<SQLHelperDB.SQLHelper>()) }, GetLogger<QueryProviderManager>()),
               GetLogger<MappingSource>(),
               ObjectPool);
            var ManyToOneProperty = Mappings.Mappings[typeof(ManyToOneOneProperties)].ManyToOneProperties.First();
            var TempDataModel = new Inflatable.Schema.DataModel(Mappings, Configuration, DataModeler, Sherlock, Helper, GetLogger<SchemaManager>());
            ManyToOneProperty.Setup(Mappings, TempDataModel.SourceSpec);
            var TestObject = new DeletePropertiesQuery<ManyToOneOneProperties>(Mappings, ObjectPool);
            var TempManyToOne = new ManyToOneOneProperties { ID = 10, BoolValue = true };
            TempManyToOne.ManyToOneClass = new ManyToOneManyProperties { ID = 1 };
            var Result = TestObject.GenerateQueries(TempManyToOne, ManyToOneProperty);
            Assert.Empty(Result);
        }
    }
}


text:
Just like super man :octocat:

String[] operator = {"refresh", "loading", "loadingMore", "loadFinish", "emptyView", "errorView", "dragSort", "swipe_inbox", "swipe_qq", "group", "itemanimate","stopAll"};


text:
<?php

namespace Peakium;

abstract class Version
{
	const VERSION = '0.0.0';
}


text:
<?php

namespace common\models\pgmbilling\lists;

use Yii;

/**
 * This is the model class for table "list_boolean".
 *
 * @property integer $id
 * @property string $label
 * @property integer $value
 */
class ListBooleanHelper extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'list_boolean';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['label', 'value'], 'required'],
            [['value'], 'integer'],
            [['label'], 'string', 'max' => 8]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('pgmuser', 'ID'),
            'label' => Yii::t('pgmuser', 'Label'),
            'value' => Yii::t('pgmuser', 'Value'),
        ];
    }
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"https://www.w3.org/TR/html4/loose.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>FreeType-2.9.1 API Reference</title>

[Index]	[TOC]

FreeType-2.9.1 API Reference

The TrueType driver

While FreeType's TrueType driver doesn't expose API functions by itself, it is possible to control its behaviour with FT_Property_Set and FT_Property_Get. The following lists the available properties together with the necessary macros and structures.

The TrueType driver's module name is ‘truetype’.

A single property interpreter-version is available, as documented in the ‘Driver properties’ section.

We start with a list of definitions, kindly provided by Greg Hitchcock.

Bi-Level Rendering

Monochromatic rendering, exclusively used in the early days of TrueType by both Apple and Microsoft. Microsoft's GDI interface supported hinting of the right-side bearing point, such that the advance width could be non-linear. Most often this was done to achieve some level of glyph symmetry. To enable reasonable performance (e.g., not having to run hinting on all glyphs just to get the widths) there was a bit in the head table indicating if the side bearing was hinted, and additional tables, ‘hdmx’ and ‘LTSH’, to cache hinting widths across multiple sizes and device aspect ratios.

Font Smoothing

Microsoft's GDI implementation of anti-aliasing. Not traditional anti-aliasing as the outlines were hinted before the sampling. The widths matched the bi-level rendering.

ClearType Rendering

Technique that uses physical subpixels to improve rendering on LCD (and other) displays. Because of the higher resolution, many methods of improving symmetry in glyphs through hinting the right-side bearing were no longer necessary. This lead to what GDI calls ‘natural widths’ ClearType, see http://www.beatstamm.com/typography/RTRCh4.htm#Sec21. Since hinting has extra resolution, most non-linearity went away, but it is still possible for hints to change the advance widths in this mode.

ClearType Compatible Widths

One of the earliest challenges with ClearType was allowing the implementation in GDI to be selected without requiring all UI and documents to reflow. To address this, a compatible method of rendering ClearType was added where the font hints are executed once to determine the width in bi-level rendering, and then re-run in ClearType, with the difference in widths being absorbed in the font hints for ClearType (mostly in the white space of hints); see http://www.beatstamm.com/typography/RTRCh4.htm#Sec20. Somewhat by definition, compatible width ClearType allows for non-linear widths, but only when the bi-level version has non-linear widths.

ClearType Subpixel Positioning

One of the nice benefits of ClearType is the ability to more crisply display fractional widths; unfortunately, the GDI model of integer bitmaps did not support this. However, the WPF and Direct Write frameworks do support fractional widths. DWrite calls this ‘natural mode’, not to be confused with GDI's ‘natural widths’. Subpixel positioning, in the current implementation of Direct Write, unfortunately does not support hinted advance widths, see http://www.beatstamm.com/typography/RTRCh4.htm#Sec22. Note that the TrueType interpreter fully allows the advance width to be adjusted in this mode, just the DWrite client will ignore those changes.

ClearType Backward Compatibility

This is a set of exceptions made in the TrueType interpreter to minimize hinting techniques that were problematic with the extra resolution of ClearType; see http://www.beatstamm.com/typography/RTRCh4.htm#Sec1 and https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx. This technique is not to be confused with ClearType compatible widths. ClearType backward compatibility has no direct impact on changing advance widths, but there might be an indirect impact on disabling some deltas. This could be worked around in backward compatibility mode.

Native ClearType Mode

(Not to be confused with ‘natural widths’.) This mode removes all the exceptions in the TrueType interpreter when running with ClearType. Any issues on widths would still apply, though.


text:
SYNONYM

#### According to
Index Fungorum

#### Published in
null

#### Original name
Lichen cycloselis Ach.

### Remarks
null


text:
package org.scalatest.examples.refspec.composingwithfixture

import org.scalatest._
import refspec.RefSpec
import collection.mutable.ListBuffer

trait Builder extends TestSuiteMixin { this: TestSuite =>

  val builder = new StringBuilder

  abstract override def withFixture(test: NoArgTest) = {
    builder.append("ScalaTest is ")
    try super.withFixture(test) // To be stackable, must call super.withFixture
    finally builder.clear()
  }
}

trait Buffer extends TestSuiteMixin { this: TestSuite =>

  val buffer = new ListBuffer[String]

  abstract override def withFixture(test: NoArgTest) = {
    try super.withFixture(test) // To be stackable, must call super.withFixture
    finally buffer.clear()
  }
}

class ExampleSpec extends RefSpec with Builder with Buffer {

  object `Testing ` {
    def `should be easy` {
      builder.append("easy!")
      assert(builder.toString === "ScalaTest is easy!")
      assert(buffer.isEmpty)
      buffer += "sweet"
    }

    def `should be fun` {
      builder.append("fun!")
      assert(builder.toString === "ScalaTest is fun!")
      assert(buffer.isEmpty)
      buffer += "clear"
    }
  }
}


text:
"""Functions and classes for parsing XPath expressions into abstract syntax
trees and serializing them back to strings.

This module exports two key functions, :func:`parse` and :func:`serialize`.

.. function:: parse(xpath_str)

   Parse a string XPath expression into an abstract syntax tree. The AST
   will be built from the classes defined in :mod:`eulcore.xpath.ast`.

.. function:: serialize(xpath_ast)

   Serialize an XPath AST expressed in terms of :mod:`eulcore.xpath.ast`
   objects into a valid XPath string.

This module does not support evaluating XPath expressions.
"""

from eulcore.xpath.core import parse, serialize


text:
template <class DataType, class RandomEngine, class SwapFunctor = DefaultSwap<DataType>>
class OneSwapMixer : public RandomMixer<DataType, RandomEngine, SwapFunctor> {
public:
    OneSwapMixer(size_t array_size, uint_fast32_t seed, SwapFunctor swap_functor = {})
            : RandomMixer<DataType, RandomEngine, SwapFunctor>(seed, swap_functor),
              distribution_(1, array_size - 1) {}

    void Mix(std::vector<DataType>& array) override {
        size_t i = distribution_(this->random_engine_);
        this->swap_functor_(array, 0, i);
    }

private:
    std::uniform_int_distribution<size_t> distribution_;
};


text:
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require File.expand_path(File.dirname(__FILE__) + '/friend_spec_helper')

# Acceptanceの作成にモデルを利用しているため、このテストでは両端のUserモデルが必要。
# Acceptanceをfixtureで作成すれば必要ではないがUserなしで衝突しないfixtureを作るのが逆に難しい。
describe Friend::Rejection do
  fixtures :users
  before do
    @user = users(:friend_permission_test_user)
    @target = users(:friend_permission_test_target_user)
  end

  describe "create" do
    it "Acceptanceが存在する場合は事前に削除する" do
      new_acceptance(@user.id, @target.id).save!

      new_rejection(@user.id, @target.id).save!

      expect(Friend::Acceptance.find_by(user_id: @user.id, target_id: @target.id)).to be_nil
      # 相手側のRequestはAcceptanceを削除した時についでに削除される
    end
    it "Rejectionが存在する場合は検証エラー" do
      new_rejection(@user.id, @target.id).save!

      expect(new_rejection(@user.id, @target.id).save).to be_falsey
    end
  end

end


text:
namespace examples {

class SingleSplitViewExample : public ExampleBase {
 public:
  explicit SingleSplitViewExample(ExamplesMain* main);
  virtual ~SingleSplitViewExample();

  // Overridden from ExampleBase:
  virtual std::wstring GetExampleTitle();
  virtual void CreateExampleView(views::View* container);

 private:
  // SingleSplitView's content, which draws gradient color on background.
  class SplittedView : public views::View {
   public:
    SplittedView();
    virtual ~SplittedView();

    void SetColor(SkColor from, SkColor to);

    // Overridden from views::View:
    virtual gfx::Size GetPreferredSize();
    virtual gfx::Size GetMinimumSize();
    virtual void Layout();

   private:
    DISALLOW_COPY_AND_ASSIGN(SplittedView);
  };

  // The SinleSplitView to test.
  views::SingleSplitView* single_split_view_;

  DISALLOW_COPY_AND_ASSIGN(SingleSplitViewExample);
};

}  // namespace examples

#endif  // VIEWS_EXAMPLES_SINGLE_SPLIT_VIEW_EXAMPLE_H_


text:
package org.spongepowered.api.data.manipulator.entity;

import org.spongepowered.api.data.manipulator.SingleValueData;
import org.spongepowered.api.data.type.Career;
import org.spongepowered.api.entity.living.Villager;

/**
 * Represents the {@link Career} for a {@link Villager}.
 */
public interface CareerData extends SingleValueData<Career, CareerData> {

    /**
     * Gets the current {@link Career}.
     *
     * @return The current career
     */
    Career getCareer();

    /**
     * Sets the career.
     *
     * @param career The career to set
     * @return This instance, for chaining
     */
    CareerData setCareer(Career career);

}


text:
@implementation Category (CoreDataProperties)

@dynamic categoryID;
@dynamic name;
@dynamic order;
@dynamic type;

@end


text:
Timer = new Mongo.Collection("timer");
var TIMER_VALUE = 30 * 1000;

Clicks = new Mongo.Collection("clicks");

if(Meteor.isClient){
  Accounts.ui.config({
    passwordSignupFields: 'USERNAME_ONLY'
  });

  Template.timer.helpers({
    s: function () {
      return Timer.findOne().value/1000;
    }
  });

  Template.thebutton.helpers({
    loggedIn: function () {
      return Meteor.user();
    },
    didClick: function(){
      return !!Clicks.findOne({userId: Meteor.userId()});
    },
    pushedAt: function(){
      if(!!Clicks.findOne({userId: Meteor.userId()})){
        return Clicks.findOne({userId: Meteor.userId()}).time;
      } else return "PUSH";
    }
  });

  Template.thebutton.events({
    'click': function () {
      Clicks.insert({
        userId: Meteor.userId(),
        username: Meteor.user().username,
        time: Timer.findOne().value/1000
      });
      Timer.update(Timer.findOne()._id, {
        $set: {value: TIMER_VALUE}
      })
    }
  });

  Template.leaders.helpers({
    clickers: function () {
      return Clicks.find({}, {sort: {time: 1}});
    }
  });
}

if(Meteor.isServer){
  Meteor.startup(function(){
    if(!Timer.findOne()){
      Timer.insert({value: TIMER_VALUE});
    }

    Meteor.setInterval(function(){
      var timer = Timer.findOne();
      timer.value -= 1000;
      timer.value = timer.value < 0 ? TIMER_VALUE : timer.value;
      Timer.update(timer._id, {value: timer.value});
    }, 1000);
  });
}


text:
================================
IBM Storage Driver for OpenStack
================================

Introduction
~~~~~~~~~~~~
The IBM Storage Driver for OpenStack is a software component of the
OpenStack cloud environment that enables utilization of storage
resources provided by supported IBM storage systems.

The driver was validated on the following storage systems:

* IBM DS8000 Family
* IBM FlashSystem A9000
* IBM FlashSystem A9000R
* IBM Spectrum Accelerate
* IBM XIV Storage System

After the driver is configured on the OpenStack Cinder nodes, storage volumes
can be allocated by the Cinder nodes to the Nova nodes. Virtual machines on
the Nova nodes can then utilize these storage resources.

.. note::
    Unless stated otherwise, all references to XIV storage
    system in this guide relate all members of the Spectrum Accelerate
    Family (XIV, Spectrum Accelerate and FlashSystem A9000/A9000R).

Concept diagram
---------------
This figure illustrates how an IBM storage system is connected
to the OpenStack cloud environment and provides storage resources when the
IBM Storage Driver for OpenStack is configured on the OpenStack Cinder nodes.
The OpenStack cloud is connected to the IBM storage system over Fibre
Channel or iSCSI (DS8000 systems support only Fibre Channel connections).
Remote cloud users can issue requests for storage resources from the
OpenStack cloud. These requests are transparently handled by the IBM Storage
Driver, which communicates with the IBM storage system and controls the
storage volumes on it. The IBM storage resources are then provided to the
Nova nodes in the OpenStack cloud.

.. figure:: ../../figures/ibm-storage-nova-concept.png

Configuration
~~~~~~~~~~~~~

Configure the driver manually by changing the ``cinder.conf`` file as
follows:

.. code-block:: ini

  volume_driver = cinder.volume.drivers.ibm.ibm_storage.IBMStorageDriver

.. include:: ../../tables/cinder-ibm_storage.inc

Security
~~~~~~~~

The following information provides an overview of security for the IBM
Storage Driver for OpenStack.

Avoiding man-in-the-middle attacks
----------------------------------

When using a Spectrum Accelerate Family product, you can prevent
man-in-the-middle (MITM) attacks by following these rules:

* Upgrade to IBM XIV storage system version 11.3 or later.

* If working in a secure mode, do not work insecurely against another storage
  system in the same environment.

* Validate the storage certificate. If you are using an XIV-provided
  certificate, use the CA file that was provided with your storage system
  (``XIV-CA.pem``). The certificate files should be copied to one of the following
  directories:

  * ``/etc/ssl/certs``
  * ``/etc/ssl/certs/xiv``
  * ``/etc/pki``
  * ``/etc/pki/xiv``

If you are using your own certificates, copy them to the same directories
with the prefix "XIV" and in the ``.pem`` format. For example: XIV-my_cert.pem.

* In order to prevent the CVE-2014-3566 MITM attack, follow the OpenStack
  community directions:
  (http://osdir.com/ml/openstack-dev/2014-10/msg01349.html).

Troubleshooting
~~~~~~~~~~~~~~~

Refer to this information to troubleshoot technical problems that you
might encounter when using the IBM Storage Driver for OpenStack.

Checking the Cinder node log files
----------------------------------

The Cinder log files record operation information that might be useful
for troubleshooting.

To achieve optimal and clear logging of events, activate the verbose
logging level in the cinder.conf file, located in the ``/etc/cinder``
folder. Add the following line in the file, save the file, and then
restart the cinder-volume service:

.. code-block:: console

    verbose = True
    debug = True

To turn off the verbose logging level, change ``True`` to ``False``,
save the file, and then restart the cinder-volume service.

Check the log files on a periodic basis to ensure that the IBM
Storage Driver is functioning properly.

To check the log file on a Cinder node:
Go to the /var/log/cinder folder and open the activity log file named
cinder-volume.log or volume.log. The IBM Storage Driver writes to this
log file using the [IBM DS8K STORAGE] or [IBM XIV STORAGE] prefix
(depending on the relevant storage system) for each event that it
records in the file.

Best practices
~~~~~~~~~~~~~~

This section contains the general guidance and best practices.

Working with multi-tenancy
--------------------------
The XIV storage systems, running microcode version 11.5 or later, Spectrum
Accelerate and FlashSystem A9000/A9000R can employ multi-tenancy.

In order to use multi-tenancy with the IBM Storage Driver for OpenStack:

* For each storage system, verify that all predefined storage pools are
  in the same domain or, that all are not in a domain.

* Use either storage administrator or domain administrator user's
  credentials, as long as the credentials grant a full access to the relevant
  pool.
* If the user is a domain administrator, the storage system domain
  access policy can be CLOSED (``domain_policy: access=CLOSED``).
  Otherwise, verify that the storage system domain access policy is
  OPEN (``domain_policy: access=OPEN``).
* If the user is not a domain administrator, the host management policy
  of the storage system domain can be BASIC (``domain_policy:
  host_management=BASIC``). Otherwise, verify that the storage
  system domain host management policy is EXTENDED
  (``domain_policy: host_management=EXTENDED``).

Working with IBM Real-time Compression™
---------------------------------------
XIV storage systems running microcode version 11.6 or later,
Spectrum Accelerate and FlashSystem A9000/A9000R can employ IBM
Real-time Compression™.

Follow these guidelines when working with compressed storage
resources using the IBM Storage Driver for OpenStack:

* Compression mode cannot be changed for storage volumes, using
  the IBM Storage Driver for OpenStack. The volumes are created
  according to the default compression mode of the pool. For example,
  any volume created in a compressed pool will be compressed as well.

* The minimum size for a compressed storage volume is 87 GB.

Working with QoS
----------------
The IBM Storage Driver for OpenStack provides QoS per volume for
IBM FlashSystem A9000/A9000R storage systems, running microcode
version of 12.0 or later. With QoS classes, the user can control
the maximum bandwidth and I/O operations for each volume.

See IBM Spectrum Accelerate Family Storage Configuration and Usage
for IBM FlashSystem A9000, IBM FlashSystem A9000R and IBM XIV Gen3,
SG24-8376 for information about how to set QoS by defining
performance classes in terms of IOPS and bandwidth limitation

QoS class types:

* Shared (default). Limits the combined rates of all of the volumes
  in the same QoS class. The maximum rate is the sum of the
  combined rate for each volume. For example, two volumes under
  a QoS class of maximum 100 Gbps are allocated a combined
  maximum bandwidth rate of 100 Gbps.

* Independent. Sets the maximum rate separately for each volume
  in the QoS class. For example, for two volumes under a QoS
  class of maximum 100 Gbps, each volume is limited to a rate
  of 100 Gbps. Thus, the combined maximum bandwidth rate is up
  to 200 Gbps.

To define a QoS class:

1. Create the QoS class:

   .. code-block:: console

        cinder qos-create <class_name> <class_specs: bw=#, iops=#>

2. Create a type:

   .. code-block:: console

       cinder type-create type_<qos_class_name>

3. Associate the QoS class with the type:

   .. code-block:: console

       cinder qos-associate <qos uuid> <type uuid>

4. Announce that the type is supporting QoS:

   .. code-block:: console

       cinder type-key <type_name or UUID> set QoS_support=True

5. Create a volume:

   .. code-block:: console

       cinder create 1 --volume-type <type_name>


text:
/**************************************************************************/
/*                                                                        */
/*      Copyright (c) 2005-2014 by ITTIA L.L.C. All rights reserved.      */
/*                                                                        */
/*  This software is copyrighted by and is the sole property of ITTIA     */
/*  L.L.C.  All rights, title, ownership, or other interests in the       */
/*  software remain the property of ITTIA L.L.C.  This software may only  */
/*  be used in accordance with the corresponding license agreement.  Any  */
/*  unauthorized use, duplication, transmission, distribution, or         */
/*  disclosure of this software is expressly forbidden.                   */
/*                                                                        */
/*  This Copyright notice may not be removed or modified without prior    */
/*  written consent of ITTIA L.L.C.                                       */
/*                                                                        */
/*  ITTIA L.L.C. reserves the right to modify this software without       */
/*  notice.                                                               */
/*                                                                        */
/*  info@ittia.com                                                        */
/*  http://www.ittia.com                                                  */
/*                                                                        */
/*                                                                        */
/**************************************************************************/

/** @file
 *
 * Command line example program demonstrating the ITTIA DB C++ API
 */

#include "phonebook.h"
#include "dbs_error_info.h"

#include <iostream>
#include <stdio.h>

#ifdef __embedded_cplusplus
#define cerr cout
#else
using std::cerr;
using std::cout;
using std::endl;
#endif

/**
 * Helper function to print error messages.
 */
int print_error(int rc)
{
    if (DB_FAILED(rc)) {
        dbs_error_info_t info = dbs_get_error_info( rc );
        cerr << "ERROR " << info.name << ": " << info.description << endl;
    }
    return rc;
}

/**
 * Create database tables, assuming an empty database has been created.
 *
 * @return database error code
 *
 * Demonstrates:
 * - DB_SUCCESS macro
	 * - DB_NOERROR status code
	 */
int PhoneBook::create_tables(bool with_picture)
{
	if (DB_SUCCESS(create_table_contact(with_picture)) &&
			DB_SUCCESS(create_table_phone_number())) {
		// Success
		return DB_NOERROR;
	} else {
		// Table error
		return DB_ETABLE;
	}
}

/**
 * Create the table "contact", which lists contacts in the phone book.
 *
 * Demonstrates:
 * - defining table schema: fields and indexes
 * - unique and non-unique indexes
 * - add_datatype() functions return FieldDesc so they can be chained together
 * - add_index() functions return IndexDesc so they can be chained together
 */
int PhoneBook::create_table_contact(bool with_picture)
{
	db::FieldDescSet fields;
	db::IndexDescSet indexes;

	// Create fields

	// Unique contact id number
	fields.add_uint("id");
	// Contacts's name
	fields.add_wstring("name", 50);
	// Ring tone to use when this contact calls
	fields.add_uint("ring_id", sizeof(db_uint), true);
	// Picture name
	fields.add_string("picture_name", 50, true);
    if (with_picture) {
	    // Picture of this contact
	    fields.add_blob("picture");
    }

	// Create a primary key index named "$PK" on the field "id"
	indexes.add_index("by_id", db::DB_PRIMARY)
				 .add_field("id");

	// Create an index on name
	indexes.add_index("by_name", db::DB_MULTISET)
				 .add_field("name");

	return db.create_table("contact", fields, indexes);
}

/**
 * Create the table "phone_number", which lists all known telephone numbers.
 */
int PhoneBook::create_table_phone_number()
{
	db::FieldDescSet fields;
	db::IndexDescSet indexes;
    db::ForeignKeyDescSet foreign_keys;

	// Foreign key into the "contact" table
	fields.add_uint("contact_id");
	// The telephone number, stored as a string
	fields.add_string("number", 20);
	// The type of device
	fields.add_uint("type");
	fields.add_sint("speed_dial", sizeof(db_sint), true);

	indexes.add_index("by_contact_id", db::DB_MULTISET)
				 .add_field("contact_id");

    foreign_keys.add_foreign_key("contact_ref", "contact", DB_FK_MATCH_SIMPLE, DB_FK_ACTION_RESTRICT, DB_FK_ACTION_RESTRICT)
        .add_field("contact_id", "id");

	return db.create_table("phone_number", fields, indexes, foreign_keys);
}

/**
 * Create sequences. Sequences are used to generate unique identifiers.
 *
 * Demonstrates:
 * - defining sequences
 */
int PhoneBook::create_sequences()
{
	if (DB_SUCCESS(db.create_sequence("contact_id", 1))) {
		// Success
		return DB_NOERROR;
	} else {
		// Sequence error
		return DB_ESEQ;
	}
}

/**
 * Open the database if it exists, otherwise create an empty database.
 *
 * @return database error code
 *
 * Demonstrates:
 * - opening a database
 * - the DB_FAILED macro
 */
int PhoneBook::open_database(int file_mode, const char* database_name)
{
	// Return code
	int rc;

	// Default database storage mode options
	db::StorageMode mode;
    mode.file_mode = file_mode;

	rc = db.open(database_name, mode);

	if (DB_FAILED(rc)) {
		cerr << "Error opening database."<< endl;
        print_error(rc);
		return rc;
	}

	return DB_NOERROR;
}

/**
 * Create an empty database.
	 *
	 * Demonstrates:
	 * - creation of an empty database
	 * - StorageMode parameter
	 */
int PhoneBook::create_database(int file_mode, const char* database_name)
{
	int rc;
	db::StorageMode mode;
    mode.file_mode = file_mode;
    if (file_mode == db::DB_MEMORY_STORAGE) {
        mode.memory_storage_size = MEMORY_STORAGE_SIZE;
        cout << "Creating " << mode.memory_storage_size << " byte memory storage." << endl;
    }

	// Create a new empty database, overwriting existing files
	rc = db.create(database_name, mode);

	if (DB_FAILED(rc)) {
		cerr << "Error creating new database." << endl;
        print_error(rc);
		return rc;
	}

	rc = create_tables(file_mode != db::DB_MEMORY_STORAGE);
	if (DB_FAILED(rc)) {
		cerr << "Error creating tables." << endl;
        print_error(rc);
		return rc;
	}

	rc = create_sequences();
	if (DB_FAILED(rc)) {
		cerr << "Error creating sequences." << endl;
        print_error(rc);
		return rc;
	}

	return rc;
}

/**
 * Close the database.
 *
 * @return database error code
 */
int PhoneBook::close_database()
{
	return db.close();
}

/**
 * Insert a contact into the database.
 *
 * Demonstrates:
 * - use of a sequence
 * - opening of a table
 * - insert mode
 * - assigning data to a row
 * - posting data to the database
 * - closing a table
 * - inserting data into a BLOB field
	 */
db_uint PhoneBook::insert_contact(const wchar_t *name, db_uint ring_id, const char *picture_name)
{
	db::Table t;
	db::Sequence id_sequence;
	db_uint id;

	id_sequence.open(db, "contact_id");
	print_error(id_sequence.get_next_value(id));

	t.open(db, "contact");

	// Put table in insert mode
	t.insert();
	// Store values for each field in a temporary buffer
	t["id"] = id;
	t["name"] = name;
	t["ring_id"] = ring_id;
	t["picture_name"] = picture_name;
	// Post the row data. This does not commit the current transaction.
	if (DB_FAILED(print_error(t.post())))
		id = 0;

	// Open picture file
	FILE *picture_file;
	if ((picture_file = fopen(picture_name, "rb")) != NULL) {

		// Prepare BLOB variables
		int picture_field = t.find_field("picture");
		int num_chunks = 0;
		int bytes_read = 0;
		const db_len_t data_size = 256;
		char data[data_size];

		// Store picture into BLOB field
		while((bytes_read = (int)fread(data, 1, data_size, picture_file)) > 0)
		{
			t.write_blob (picture_field, data_size * num_chunks, data, bytes_read);
			num_chunks++;
		}
		fclose(picture_file);

	} else {
		cerr << "Cannot open " << picture_name << endl;
	}

	t.close();

	return id;
}

/**
 * Insert a phone entry into the database.
 */
void PhoneBook::insert_phone_number(db_uint contact_id, const char *number, PhoneNumberType type, db_sint speed_dial)
{
	db::Table t;

	t.open(db, "phone_number");

	t.insert();
	t["contact_id"] = contact_id;
	t["number"] = number;
	t["type"] = type;
	t["speed_dial"] = speed_dial;
	if (DB_FAILED(print_error(t.post())))
		cerr << "Could not enter new phone number" << endl;

	t.close();
}

/**
 * Update an existing contact's name.
	 *
	 * Demonstrates:
	 * - searching for existence of a record using an index
	 * - edit mode
	 */
void PhoneBook::update_contact_name(db_uint id, const wchar_t *newname)
{
	db::Table contact;

	contact.open(db, "contact");

	// Sort with the "$PK" index to avoid a table scan.
	contact.set_sort_order("$PK");
    // Filter by the "id" column.
    contact.begin_filter(db::DB_SEEK_EQUAL);
	contact["id"] = id;
	if (DB_SUCCESS(print_error(contact.apply_filters()))) {
		// Edit the current row
		contact.edit();
		contact["name"] = newname;
		contact.post();
	} else {
		cerr << "Could not find contact with id " << (long) id << endl;
	}

	contact.close();
}

/**
 * Remove contact record from the database.
	 *
 * Demonstrates:
	 * - deleting a record
	 * - parent/child removal
	 * - range search loop using seek_next()
	 * - seek_next() returns OK on end, so must explicitly check for is_eof()
 */
void PhoneBook::remove_contact(db_uint id)
{
	db::Table contact;
	db::Table phone_number;

	contact.open(db, "contact");

	// Sort with the "$PK" index to avoid a table scan.
	contact.set_sort_order("$PK");
    // Filter by the "id" column.
	contact.begin_filter(db::DB_SEEK_EQUAL);
	contact["id"] = id;
	if (DB_SUCCESS(print_error(contact.apply_filters()))) {
		db_uint id = contact["id"].as_int();

        // Optimization: prevent others from reading this contact while its
        // phone numbers are removed.
        contact.lock_row(db::DB_LOCK_EXCLUSIVE);

        // Remove related telephone numbers

		phone_number.open(db, "phone_number");
		phone_number.set_sort_order("by_contact_id");

		// Filter phone numbers by the "contact_id" column.
		phone_number.begin_filter(db::DB_SEEK_EQUAL);
		phone_number["contact_id"] = id;
		phone_number.apply_filters();

        // Remove all matching phone numbers.
        for (phone_number.seek_first(); !phone_number.is_eof(); phone_number.seek_next())
			phone_number.remove();

		// Remove the current contact
		contact.remove();

		phone_number.close();
	} else {
		cerr << "Could not find contact with id " << (long) id << endl;
	}

	contact.close();
}

/**
 * Briefly list all contacts in the database.
 */
void PhoneBook::list_contacts_brief()
{
	db::Table contact;

	contact.open(db, "contact");
	contact.set_sort_order("by_name");

	for (contact.seek_first(); !contact.is_eof(); contact.seek_next()) {
		db_uint id = contact["id"].as_int();
		db::WString name = contact["name"].as_wstring();
        char name_mbs[50];

        wcstombs(name_mbs, name.c_str(), sizeof name_mbs/sizeof name_mbs[0]);

		cout << (long) id << '\t';
		cout << name_mbs << endl;
	}

	contact.close();
}

/**
 * List all contacts in the database with full phone numbers
 *
 * Demonstrates:
 * - parent/child relationships
 */
void PhoneBook::list_contacts(int sort)
{
	db::Table contact;
	db::Table phone_number;

	contact.open(db, "contact");
	contact.set_sort_order("by_name");

    db::IndexFieldSet sort_fields;
    switch (sort) {
        case 0:
            sort_fields.add("id");
            break;
        case 1:
            sort_fields.add("name");
            break;
        case 2:
            sort_fields.add("ring_id");
            sort_fields.add("name");
            break;
    }
    contact.sort(sort_fields);

	for (contact.seek_first(); !contact.is_eof(); contact.seek_next()) {
		db_uint id = contact["id"].as_int();

		db::WString name = contact["name"].as_wstring();
        char name_mbs[50];
		db_uint ring_id = contact["ring_id"].as_int();
		db::String picture_name = contact["picture_name"].as_string();
        wcstombs(name_mbs, name.c_str(), sizeof name_mbs/sizeof name_mbs[0]);

		// Output the contact's name and ring tone
		cout << "Id: " << (long) id << endl;
		cout << "Name: " << name_mbs << endl;
        if (!contact["ring_id"].is_null())
    		cout << "Ring tone id: " << (int) ring_id << endl;
        if (!contact["picture_name"].is_null())
    		cout << "Picture name: " << picture_name.c_str() << endl;

		phone_number.open(db, "phone_number");
		phone_number.set_sort_order("by_contact_id");

		// List the contact's phone numbers
		phone_number.begin_filter(db::DB_SEEK_EQUAL);
		phone_number["contact_id"] = id;
		phone_number.apply_filters();
        for (phone_number.seek_first(); !phone_number.is_eof(); phone_number.seek_next()) {
			db::String number = phone_number["number"].as_string();
			PhoneNumberType type = (PhoneNumberType) (db_uint) phone_number["type"].as_int();
			int speed_dial = phone_number["speed_dial"].as_int();

			cout << "Phone number: " << number.c_str() << " (";
			switch (type) {
				case HOME:   cout << "Home"; break;
				case MOBILE: cout << "Mobile"; break;
				case WORK:   cout << "Work"; break;
				case FAX:    cout << "Fax"; break;
				case PAGER:  cout << "Pager"; break;
			}
			if (speed_dial >= 0)
				cout << ", speed dial " << speed_dial;
			cout << ")" << endl;
		}

		phone_number.close();

		cout << endl;
	}

	contact.close();
}

/**
 * Retrieve picture_name field from a contact
 */
db::String PhoneBook::get_picture_name(db_uint id)
{
	db::Table contact;

	contact.open(db, "contact");

	// Seek using the "$PK" index
	contact.set_sort_order("$PK");
	contact.begin_seek(db::DB_SEEK_EQUAL);
	contact["id"] = id;
	db::String picture_name;

	if (DB_SUCCESS(print_error(contact.apply_seek()))) {
		picture_name = contact["picture_name"].as_string();
	} else {
		cerr << "Could not find contact with id " << (long) id << endl;
	}

	contact.close();
	return picture_name;
}

/**
 * Export picture file to disk
 *
 * Demonstrates:
 * - reading the contents of a BLOB
 */
void PhoneBook::export_picture(db_uint id, const char *file_name)
{
	db::Table contact;

	contact.open(db, "contact");

	// Seek using the "$PK" index
	contact.set_sort_order("$PK");
	contact.begin_filter(db::DB_SEEK_EQUAL);
	contact["id"] = id;
    contact.apply_filters();
	if (DB_SUCCESS(print_error(contact.seek_first()))) {

		// Open file
		FILE *picture_file;
		if ((picture_file = fopen(file_name, "wb")) != NULL) {

			// Prepare BLOB variables
			int offset, bytes_read;
			int picture_field = contact.find_field("picture");
			db_len_t blob_size = contact.get_blob_size(picture_field);
			const db_len_t data_size = 256;
			char data[data_size];

			// Export file from BLOB to disk
			for(offset = 0; offset < blob_size; offset += data_size)
			{
				DB_SUCCESS(bytes_read = contact.read_blob(picture_field, offset, data, data_size));
				fwrite(data, bytes_read, 1, picture_file);
			}

			fclose(picture_file);

		} else {
			cerr << "Cannot open " << file_name << endl;
		}

	} else {
		cerr << "Could not find contact with id " << (long) id << endl;
	}

	contact.close();
}

/**
 * Start transaction
 */
void PhoneBook::tx_start()
{
	db.tx_begin();
}

/**
 * Commit transaction
 */
void PhoneBook::tx_commit()
{
	if (DB_FAILED(db.tx_commit())) {
		cerr << "Failed to commit transaction." << endl;
		return;
	}
}


text:
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import isi_mip.climatemodels.models

class Migration(migrations.Migration):

    dependencies = [
        ('climatemodels', '0087_datapublicationconfirmation_confirmed_license'),
    ]

    operations = [
        migrations.CreateModel(
            name='Attachment',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('attachment1', models.FileField(upload_to=isi_mip.climatemodels.models.impact_model_path)),
                ('attachment2', models.FileField(upload_to=isi_mip.climatemodels.models.impact_model_path)),
                ('attachment3', models.FileField(upload_to=isi_mip.climatemodels.models.impact_model_path)),
                ('attachment4', models.FileField(upload_to=isi_mip.climatemodels.models.impact_model_path)),
                ('attachment5', models.FileField(upload_to=isi_mip.climatemodels.models.impact_model_path)),
                ('impact_model', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='climatemodels.ImpactModel')),
            ],
        ),
    ]