* @param serviceModel Service model to get prefix for.
* @return Prefix to use when writing model files (service and intermediate).
165792
public static String getFileNamePrefix(ServiceModel serviceModel, CustomizationConfig customizationConfig) {
        if (customizationConfig.isUseUidAsFilePrefix() && serviceModel.getMetadata().getUid() != null) {
            return serviceModel.getMetadata().getUid();
        }

        return String.format("%s-%s", serviceModel.getMetadata().getEndpointPrefix(), serviceModel.getMetadata().getApiVersion());
    }
1233659
@Override
    public void preprocess(ServiceModel serviceModel) {

        if (renameShapes == null || renameShapes.isEmpty()) return;
        // sanity check
        for (Entry<String, String> entry : renameShapes.entrySet()) {

            String originalName = entry.getKey();
            String newName = entry.getValue();
            Shape originalShape = serviceModel.getShapes().get(originalName);

            if (originalShape == null) {
                throw new IllegalStateException(
                        String.format("Cannot find shape [%s] in the model when processing "
                                + "customization config renameShapes.%s", originalName, originalName));
            }
            if (serviceModel.getShapes().containsKey(newName)) {
                throw new IllegalStateException(
                        String.format("The shape [%s] for the new name is already in the model when processing "
                                + "customization config renameShapes.%s", newName, originalName));
            }
        }

        for (Entry<String, Shape> entry : serviceModel.getShapes().entrySet()) {
            String shapeName = entry.getKey();
            Shape shape = entry.getValue();

            preprocess_RenameMemberShapes(shapeName, shape);
        }
        for (Operation operation : serviceModel.getOperations().values()) {

            if (operation.getInput() != null) {
                preprocess_RenameInputShape(operation.getInput());
            }
            if (operation.getOutput() != null) {
                preprocess_RenameOutputShape(operation.getOutput());
            }
            if (operation.getErrors() != null) {
                for (ErrorMap error : operation.getErrors()) {
                    preprocess_RenameErrorShape(error);
                }
            }
        }
        for (Entry<String, String> entry : renameShapes.entrySet()) {
            String originalName = entry.getKey();
            String newName = entry.getValue();

            Shape shape = serviceModel.getShapes().remove(originalName);
            serviceModel.getShapes().put(newName, shape);
        }
    }
121024
public static CommerceWarehouse toModel(CommerceWarehouseSoap soapModel) {
		if (soapModel == null) {
			return null;
		}

		CommerceWarehouse model = new CommerceWarehouseImpl();

		model.setCommerceWarehouseId(soapModel.getCommerceWarehouseId());
		model.setGroupId(soapModel.getGroupId());
		model.setCompanyId(soapModel.getCompanyId());
		model.setUserId(soapModel.getUserId());
		model.setUserName(soapModel.getUserName());
		model.setCreateDate(soapModel.getCreateDate());
		model.setModifiedDate(soapModel.getModifiedDate());
		model.setName(soapModel.getName());
		model.setDescription(soapModel.getDescription());
		model.setActive(soapModel.isActive());
		model.setStreet1(soapModel.getStreet1());
		model.setStreet2(soapModel.getStreet2());
		model.setStreet3(soapModel.getStreet3());
		model.setCity(soapModel.getCity());
		model.setZip(soapModel.getZip());
		model.setCommerceRegionId(soapModel.getCommerceRegionId());
		model.setCommerceCountryId(soapModel.getCommerceCountryId());
		model.setLatitude(soapModel.getLatitude());
		model.setLongitude(soapModel.getLongitude());
		model.setPrimary(soapModel.isPrimary());

		return model;
	}
662840
public ArrayList<OvhModel> serviceName_models_GET(String serviceName) throws IOException {
		String qPath = "/vps/{serviceName}/models";
		StringBuilder sb = path(qPath, serviceName);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, t6);
	}
25497
public static ServiceInstance toServiceInstance(
            ModelServiceInstance modelInstance) {
        if (modelInstance==null) throw new NullPointerException();
        Map<String, String> meta = new HashMap<>();
        if (modelInstance.getMetadata() != null) {
            for (Entry<String, String> en : modelInstance.getMetadata()
                    .entrySet()) {
                meta.put(en.getKey(), en.getValue());
            }
        }
        return new ServiceInstance(modelInstance.getServiceName(),
                modelInstance.getUri(),
                modelInstance.isMonitorEnabled(), modelInstance.getStatus(),
                modelInstance.getAddress(),meta, modelInstance.getPort(), modelInstance.getTls_port(), modelInstance.getProtocol());
    }
16899
public ServiceFactory getServiceFactory(AppContextWrapper sc) {
		ContainerWrapper containerWrapper = containerFinder.findContainer(sc);
		ServiceFactory serviceFactory = (ServiceFactory) containerWrapper.lookup(ComponentKeys.WEBSERVICE_FACTORY);
		return serviceFactory;
	}
167932
public static List<CPDefinitionOptionRel> toModels(
		CPDefinitionOptionRelSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<CPDefinitionOptionRel> models = new ArrayList<CPDefinitionOptionRel>(soapModels.length);

		for (CPDefinitionOptionRelSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}
515254
public static List<CPDefinitionOptionValueRel> toModels(
		CPDefinitionOptionValueRelSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<CPDefinitionOptionValueRel> models = new ArrayList<CPDefinitionOptionValueRel>(soapModels.length);

		for (CPDefinitionOptionValueRelSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}
1141335
function getModel(service, mixins) {

        // model constructor takes in data and saves it along with the model mixins
        var Model = function (data) {
            _.extend(this, data, mixins);
        };

        if (service.save) {
            Model.prototype.save = function () {
                if (this._id) {
                    return service.save({ where: { _id: this._id }, data: this });
                }
                else {
                    return service.save({ data: this });
                }
            };
        }
        else if (service.create && service.update) {
            Model.prototype.save = function () {
                if (this._id) {
                    return service.update({ where: { _id: this._id }, data: this });
                }
                else {
                    return service.create({ data: this });
                }
            };
        }

        if (service.remove) {
            Model.prototype.remove = function () {
                return service.remove({ where: { _id: this._id } });
            };
        }

        // the service methods are added as static references on the model
        _.each(service, function (method, methodName) {
            Model[methodName] = function () {
                return service[methodName].apply(service, arguments);
            };
        });

        return Model;
    }
339161
@Override
    public ServiceReference<?> getServiceReference(String clazz) {
    	Collection<ServiceReference<?>> servrefs = serviceRegistrations.get(clazz);
    	if (servrefs == null || servrefs.size() == 0) {
            return null;
    	}

        return servrefs.iterator().next();
    }
657877
public ModelService getModelService(String serviceName){
        ModelService service = getDirectoryServiceClient().getService(serviceName, null);
        return service;
    }
745429
public static List<CommerceNotificationQueueEntry> toModels(
		CommerceNotificationQueueEntrySoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<CommerceNotificationQueueEntry> models = new ArrayList<CommerceNotificationQueueEntry>(soapModels.length);

		for (CommerceNotificationQueueEntrySoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}
720200
public static List<CPDefinitionSpecificationOptionValue> toModels(
		CPDefinitionSpecificationOptionValueSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<CPDefinitionSpecificationOptionValue> models = new ArrayList<CPDefinitionSpecificationOptionValue>(soapModels.length);

		for (CPDefinitionSpecificationOptionValueSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}
797971
@Override
    public synchronized IServiceImplementation getServiceImplementation() throws ModelException
    {
        if (null == this.serviceImplementation)
        {
            IServiceFunctionality advFunc = this.getAdvertisedFunctionality();
            if (advFunc instanceof ServiceFunctionality)
            {
                IFunctionalityImplementation functionalityImplementation = ((ServiceFunctionality) advFunc).getFunctionalityImplementation();
                if (null != functionalityImplementation)
                {
                    this.serviceImplementation = functionalityImplementation.getServiceImplementation();
                }
            }
        }
        return this.serviceImplementation;
    }
282798
protected final FluentModelTImpl prepareInlineDefine(FluentModelTImpl model) {
        FluentModelTImpl childResource = find(model.childResourceKey());
        if (childResource != null) {
            throw new IllegalArgumentException(pendingOperationMessage(model.name(), model.childResourceKey()));
        }
        model.setPendingOperation(ExternalChildResourceImpl.PendingOperation.ToBeCreated);
        this.childCollection.put(model.childResourceKey(), model);
        return super.prepareForFutureCommitOrPostRun(model);
    }
727039
public static CommerceAddressRestriction toModel(
		CommerceAddressRestrictionSoap soapModel) {
		if (soapModel == null) {
			return null;
		}

		CommerceAddressRestriction model = new CommerceAddressRestrictionImpl();

		model.setCommerceAddressRestrictionId(soapModel.getCommerceAddressRestrictionId());
		model.setGroupId(soapModel.getGroupId());
		model.setCompanyId(soapModel.getCompanyId());
		model.setUserId(soapModel.getUserId());
		model.setUserName(soapModel.getUserName());
		model.setCreateDate(soapModel.getCreateDate());
		model.setModifiedDate(soapModel.getModifiedDate());
		model.setClassNameId(soapModel.getClassNameId());
		model.setClassPK(soapModel.getClassPK());
		model.setCommerceCountryId(soapModel.getCommerceCountryId());

		return model;
	}
301060
private static Map<String, Method> serviceMethods(Class<?> serviceInterface) {
    Map<String, Method> methods =
        Arrays.stream(serviceInterface.getMethods())
            .filter(method -> method.isAnnotationPresent(ServiceMethod.class))
            .collect(
                Collectors.toMap(
                    method -> {
                      ServiceMethod methodAnnotation = method.getAnnotation(ServiceMethod.class);
                      return isNullOrEmpty(methodAnnotation.value())
                          ? method.getName()
                          : methodAnnotation.value();
                    },
                    Function.identity()));

    return Collections.unmodifiableMap(methods);
  }