Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function put_webservice_initial(){
- $arraycall = json_decode($_POST['my_object']);
- $prefixORsufix = $arraycall->prefixORsufix;
- $id_asset = $arraycall->id_asset;
- $id_resource = $arraycall->id_resource;
- $prefix = $arraycall->prefix;
- $suffix = $arraycall->suffix;
- $parameter = $arraycall->parameter;
- //para ir buscar o id da entidade que está selecionada na dropdown na TopBar
- $member = Member::currentUser();
- $entity_ID_at_moment = $member->entity_in_workID;
- $asset_current = ttAsset::get()->ByID($id_asset);
- $endpoint_id = $asset_current->endpoint_id;
- //obter os contratos da entidade que estabeleceu o contrato e que ainda esteja ativo
- $contracts = ttContract::get()->filter(array('entity_establishedID' => $entity_ID_at_moment, 'valid' => 1));
- $list = ArrayList::create();
- if($contracts->Count()!=0){
- foreach ($contracts as $contract) { //os contractos que têm webservices associados
- $webservice=$contract->webservices()->filter(array('recycled' => 0))
- ->sort("date_doc DESC")
- ->limit(1);
- $list->merge($webservice);
- }
- //como o array ja esta ordenado de forma descendente pela start_date, basta obter os values da posicao 0.
- $recent_contract = $list[0];
- //echo "<pre>";print_r($recent_contract);die();
- foreach($recent_contract as $contract){
- $url = $contract->url;
- $port = $contract->port;
- $user = $contract->user;
- }
- $resources = ttSCResource::get()->ByID($id_resource);
- $res_verb = $resources->verbs()->ByID(2);
- $list = ArrayList::create();
- $valor_dis=null;
- $object_send = new stdClass;
- $variables=$resources->variable();
- foreach($variables as $variable){
- $validations = $variable->validation();
- foreach($validations as $validation){
- $className = $validation->ClassName;
- $valid = $className::get()->ByID($validation->ID);
- if($valid->ClassName == 'ttValidationDecimal'){
- $object_send->minimum = $valid->min_decimal;
- $object_send->maximum = $valid->max_decimal;
- $object_send->type = "decimal";
- }
- else if($valid->ClassName == 'ttValidationInt'){
- $object_send->minimum = $valid->min_integer;
- $object_send->maximum = $valid->max_integer;
- $object_send->type = "int";
- }
- else if($valid->ClassName == 'ttSetDisjoint'){
- $values_disjoint = ttSetValuesDisjoint::get()->filter(array('set_disjointID' => $valid->variableID));
- foreach($values_disjoint as $value_dis){
- $valor_dis = $valor_dis.$value_dis->Title . "|";
- }
- $object_send->disjoint = $valor_dis;
- }
- }
- }
- foreach($res_verb as $res){
- $msg_body=$res->msg_body;
- $value=$this->convert_json_to_object($msg_body);
- $object_send->json = $value;
- }
- return json_encode($object_send);
- }
- else {
- $value=_t("ttRealTimeControlHolder.ERRORCONTRACT", "É necessário ter um contrato válido.");
- return json_encode($value);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement