Updates all the process definition entities to have the correct diagram resource name.  Must
be called after createAndPersistNewDiagramsAsNeeded to ensure that any newly-created diagrams
already have their resources attached to the deployment.
503412
protected void setProcessDefinitionDiagramNames(ParsedDeployment parsedDeployment) {
        Map<String, ResourceEntity> resources = parsedDeployment.getDeployment().getResources();

        for (ProcessDefinitionEntity processDefinition : parsedDeployment.getAllProcessDefinitions()) {
            String diagramResourceName = ResourceNameUtil.getProcessDiagramResourceNameFromDeployment(processDefinition,
                                                                                                      resources);
            processDefinition.setDiagramResourceName(diagramResourceName);
        }
    }
1327543
def _post_create(self, auto_refresh=False):

		'''
		
		'''

		# set PCDM triple as Object
		self.add_triple(self.rdf.prefixes.rdf.type, self.rdf.prefixes.pcdm.Object)
		self.update(auto_refresh=auto_refresh)

		# create /files child resource
		files_child = PCDMFilesContainer(
			self.repo,
			'%s/files' % self.uri_as_string(),
			membershipResource=self.uri,
			hasMemberRelation=self.rdf.prefixes.pcdm.hasFile)
		files_child.create(specify_uri=True)

		# create /members child resource
		members_child = PCDMMembersContainer(
			self.repo,
			'%s/members' % self.uri_as_string(),
			membershipResource=self.uri,
			hasMemberRelation=self.rdf.prefixes.pcdm.hasMember,
			insertedContentRelation=self.rdf.prefixes.ore.proxyFor)
		members_child.create(specify_uri=True)

		# create /related child resource
		related_child = PCDMRelatedContainer(
			self.repo,
			'%s/related' % self.uri_as_string(),
			membershipResource=self.uri,
			hasMemberRelation=self.rdf.prefixes.ore.aggregates,
			insertedContentRelation=self.rdf.prefixes.ore.proxyFor)
		related_child.create(specify_uri=True)

		# create /associated child resource
		associated_child = PCDMAssociatedContainer(
			self.repo,
			'%s/associated' % self.uri_as_string(),
			membershipResource=self.uri,
			hasMemberRelation=self.rdf.prefixes.pcdm.hasRelatedFile)
		associated_child.create(specify_uri=True)
205100
@Override
    public void updateProperties(final IdentifierConverter<Resource, FedoraResource> idTranslator,
                                 final String sparqlUpdateStatement, final RdfStream originalTriples)
            throws MalformedRdfException, AccessDeniedException {

        final Model model = originalTriples.collect(toModel());

        final FedoraResource described = getDescribedResource();
        final String describedURI = idTranslator.reverse().convert(described).toString();

        final UpdateRequest request = create(sparqlUpdateStatement, describedURI);

        final Collection<ConstraintViolationException> errors = validateUpdateRequest(request);

        final NamespaceRegistry namespaceRegistry = getNamespaceRegistry(getSession());

        request.getPrefixMapping().getNsPrefixMap().forEach(
            (k,v) -> {
                try {
                    LOGGER.debug("Prefix mapping is key:{} -> value:{}", k, v);
                    if (Arrays.asList(namespaceRegistry.getPrefixes()).contains(k)
                        &&  !v.equals(namespaceRegistry.getURI(k))) {

                        final String namespaceURI = namespaceRegistry.getURI(k);
                        LOGGER.debug("Prefix has already been defined: {}:{}", k, namespaceURI);
                        throw new InvalidPrefixException("Prefix already exists as: " + k + " -> " + namespaceURI);
                   }

                } catch (final RepositoryException e) {
                    throw new RepositoryRuntimeException(e);
                }
           });

        throwConstraintErrorsIfPresent(errors);

        checkInteractionModel(request);

        final FilteringJcrPropertyStatementListener listener = new FilteringJcrPropertyStatementListener(
                idTranslator, getSession(), idTranslator.reverse().convert(described).asNode());

        model.register(listener);

        // If this resource's structural parent is an IndirectContainer, check whether the
        // ldp:insertedContentRelation property is present in the stream of changed triples.
        // If so, set the propertyChanged value to true.
        final AtomicBoolean propertyChanged = new AtomicBoolean();
        ldpInsertedContentProperty(getNode()).ifPresent(resource -> {
            model.register(new PropertyChangedListener(resource, propertyChanged));
        });

        model.setNsPrefixes(request.getPrefixMapping());
        execute(request, model);

        removeEmptyFragments();

        ensureInteractionModelDefaults(describedURI, model);

        listener.assertNoExceptions();

        try {
            touch(propertyChanged.get(), listener.getAddedCreatedDate(), listener.getAddedCreatedBy(),
                    listener.getAddedModifiedDate(), listener.getAddedModifiedBy());
        } catch (final RepositoryException e) {
            throw new RuntimeException(e);
        }
    }
810548
def update(self, resource, resource_id, data):
        '''
        
        '''
        service_def, resource_def, path = self._get_service_information(
            resource)

        update_path = "{0}{1}/" . format(path, resource_id)
        return self.call(path=update_path, data=data, method='patch')
182829
def update_resources_from_datafile(self, srcpath, type_, names=None, 
                                       languages=None):
        
        UpdateResourcesFromDataFile(self.filename, srcpath, type_, names, 
                                    languages)
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);
        }
    }
738566
private function updateSteps()
    {
        $this->log('Initializing resource node of steps...');

        /** @var ObjectManager $om */
        $om = $this->container->get('claroline.persistence.object_manager');
        $steps = $om->getRepository('Innova\PathBundle\Entity\Step')->findAll();

        $om->startFlushSuite();
        $i = 0;

        /** @var Step $step */
        foreach ($steps as $step) {
            /** @var Activity $activity */
            $activity = $step->getActivity();

            if (!empty($activity)) {
                if (!empty($activity->getPrimaryResource())) {
                    $step->setResource($activity->getPrimaryResource());
                }
                $step->setTitle($activity->getResourceNode()->getName());
                $step->setDescription($activity->getDescription());

                $parameters = $activity->getParameters();

                if (!empty($parameters)) {
                    $order = 0;

                    foreach ($parameters->getSecondaryResources() as $resource) {
                        $secondaryResource = new SecondaryResource();
                        $secondaryResource->setResource($resource);
                        $secondaryResource->setOrder($order);
                        $step->addSecondaryResource($secondaryResource);
                        $om->persist($secondaryResource);
                        ++$order;
                    }
                }
                $om->persist($step);
            }
            ++$i;

            if ($i % 250 === 0) {
                $om->forceFlush();
            }
        }

        $om->endFlushSuite();
    }
1128267
function _updateSingleton() {
    if (!options.singletons) {
      return;
    }
    if (process.rebusinstances[folder]) {
      // Somebody added instance already.
      return;
    }
    // Save this instance to return the same for the same folder.
    process.rebusinstances[folder] = instance;
  }
224650
@Override
    public CreateUpdateEntitiesResult updateEntities(String entityInstanceDefinition) throws AtlasException {
        entityInstanceDefinition = ParamChecker.notEmpty(entityInstanceDefinition, "Entity instance definition");
        ITypedReferenceableInstance[] typedInstances = deserializeClassInstances(entityInstanceDefinition);

        CreateUpdateEntitiesResult result = repository.updateEntities(typedInstances);
        onEntitiesAddedUpdated(result.getEntityResult());
        return result;
    }
913948
def update(self):
        '''
        
        '''
        self.updateIncomeProcess()
        self.updateAssetsGrid()
        self.updatepLvlNextFunc()
        self.updatepLvlGrid()
        self.updateMedShockProcess()
        self.updateSolutionTerminal()
42855
private void updateInstaceTypeDescriptionMap() {

		// this.registeredHosts.values().iterator()
		this.instanceTypeDescriptionMap.clear();

		final List<InstanceTypeDescription> instanceTypeDescriptionList = new ArrayList<InstanceTypeDescription>();

		// initialize array which stores the availability counter for each instance type
		final int[] numberOfInstances = new int[this.availableInstanceTypes.length];
		for (int i = 0; i < numberOfInstances.length; i++) {
			numberOfInstances[i] = 0;
		}

		// Shuffle through instance types
		for (int i = 0; i < this.availableInstanceTypes.length; i++) {

			final InstanceType currentInstanceType = this.availableInstanceTypes[i];
			int numberOfMatchingInstances = 0;
			int minNumberOfCPUCores = Integer.MAX_VALUE;
			long minSizeOfPhysicalMemory = Long.MAX_VALUE;
			long minSizeOfFreeMemory = Long.MAX_VALUE;
			final Iterator<ClusterInstance> it = this.registeredHosts.values().iterator();
			while (it.hasNext()) {
				final ClusterInstance clusterInstance = it.next();
				if (clusterInstance.getType().equals(currentInstanceType)) {
					++numberOfMatchingInstances;
					final HardwareDescription hardwareDescription = clusterInstance.getHardwareDescription();
					minNumberOfCPUCores = Math.min(minNumberOfCPUCores, hardwareDescription.getNumberOfCPUCores());
					minSizeOfPhysicalMemory = Math.min(minSizeOfPhysicalMemory,
						hardwareDescription.getSizeOfPhysicalMemory());
					minSizeOfFreeMemory = Math.min(minSizeOfFreeMemory, hardwareDescription.getSizeOfFreeMemory());
				}
			}

			// Update number of instances
			int highestAccommodationNumber = -1;
			int highestAccommodationIndex = -1;
			for (int j = 0; j < this.availableInstanceTypes.length; j++) {
				final int accommodationNumber = canBeAccommodated(j, i);
				// LOG.debug(this.availableInstanceTypes[j].getIdentifier() + " fits into "
				// + this.availableInstanceTypes[i].getIdentifier() + " " + accommodationNumber + " times");
				if (accommodationNumber > 0) {
					numberOfInstances[j] += numberOfMatchingInstances * accommodationNumber;
					if (accommodationNumber > highestAccommodationNumber) {
						highestAccommodationNumber = accommodationNumber;
						highestAccommodationIndex = j;
					}
				}
			}

			// Calculate hardware description
			HardwareDescription pessimisticHardwareDescription = null;
			if (minNumberOfCPUCores < Integer.MAX_VALUE && minSizeOfPhysicalMemory < Long.MAX_VALUE
				&& minSizeOfFreeMemory < Long.MAX_VALUE) {

				pessimisticHardwareDescription = HardwareDescriptionFactory.construct(minNumberOfCPUCores,
					minSizeOfPhysicalMemory, minSizeOfFreeMemory);

			} else {

				if (highestAccommodationIndex < i) { // Since highestAccommodationIndex smaller than my index, the
														// target instance must be more powerful

					final InstanceTypeDescription descriptionOfLargerInstanceType = instanceTypeDescriptionList
						.get(highestAccommodationIndex);
					if (descriptionOfLargerInstanceType.getHardwareDescription() != null) {
						final HardwareDescription hardwareDescriptionOfLargerInstanceType = descriptionOfLargerInstanceType
							.getHardwareDescription();

						final int numCores = hardwareDescriptionOfLargerInstanceType.getNumberOfCPUCores()
							/ highestAccommodationNumber;
						final long physMem = hardwareDescriptionOfLargerInstanceType.getSizeOfPhysicalMemory()
							/ highestAccommodationNumber;
						final long freeMem = hardwareDescriptionOfLargerInstanceType.getSizeOfFreeMemory()
							/ highestAccommodationNumber;

						pessimisticHardwareDescription = HardwareDescriptionFactory.construct(numCores, physMem,
							freeMem);
					}
				}
			}

			instanceTypeDescriptionList.add(InstanceTypeDescriptionFactory.construct(currentInstanceType,
				pessimisticHardwareDescription, numberOfInstances[i]));
		}

		final Iterator<InstanceTypeDescription> it = instanceTypeDescriptionList.iterator();
		while (it.hasNext()) {

			final InstanceTypeDescription itd = it.next();
			this.instanceTypeDescriptionMap.put(itd.getInstanceType(), itd);
		}
	}
540228
public void addStep(Diagram diagram) {
		if (diagram.getFigureCount() != figures.size()) {
			throw new RuntimeException("Mismatched diagrams, missing ids");
		}
		for (int i=0;i<diagram.getFigureCount();i++) {
			Figure figure = diagram.getFigure(i);
			String id = figure.getData().getMetaData();
			
			for (int j=0;j<figures.size();j++) {
				Figure existing = (Figure) figures.get(j);
				if (existing.getData().getMetaData().equals(id)) {
					MorphShape morph = (MorphShape) existing.getShape();
					morph.addShape(figure.getShape());
					break;
				}
			}
		}
	}
1030096
def update_resource_properties(r, orig_columns={}, force=False):
    

    added = []

    schema_term = r.schema_term

    if not schema_term:
        warn("No schema term for ", r.name)
        return

    rg = r.raw_row_generator

    # Get columns information from the schema, or, if it is a package reference,
    # from the upstream schema

    upstream_columns = {e['name'].lower() if e['name'] else '': e for e in r.columns() or {}}

    # Just from the local schema
    schema_columns = {e['name'].lower() if e['name'] else '': e for e in r.schema_columns or {}}

    # Ask the generator if it can provide column descriptions and types
    generator_columns = {e['name'].lower() if e['name'] else '': e for e in rg.columns or {}}

    def get_col_value(col_name, value_name):

        v = None

        if not col_name:
            return None

        for d in [generator_columns, upstream_columns, orig_columns, schema_columns]:
            v_ = d.get(col_name.lower(), {}).get(value_name)
            if v_:
                v = v_

        return v



    # Look for new properties
    extra_properties = set()
    for d in [generator_columns, upstream_columns, orig_columns, schema_columns]:
        for k, v in d.items():
            for kk, vv in v.items():
                extra_properties.add(kk)

    # Remove the properties that are already accounted for
    extra_properties = extra_properties - {'pos', 'header', 'name', ''}

    # Add any extra properties, such as from upstream packages, to the schema.

    for ep in extra_properties:
        r.doc['Schema'].add_arg(ep)

    for c in schema_term.find('Table.Column'):

        for ep in extra_properties:
            t = c.get_or_new_child(ep)
            v = get_col_value(c.name, ep)
            if v:
                t.value = v
                added.append((c.name, ep, v))

    prt('Updated schema for {}. Set {} properties'.format(r.name, len(added)))
1341525
protected void makeProcessDefinitionsConsistentWithPersistedVersions(ParsedDeployment parsedDeployment) {
        for (ProcessDefinitionEntity processDefinition : parsedDeployment.getAllProcessDefinitions()) {
            ProcessDefinitionEntity persistedProcessDefinition =
                    bpmnDeploymentHelper.getPersistedInstanceOfProcessDefinition(processDefinition);

            if (persistedProcessDefinition != null) {
                processDefinition.setId(persistedProcessDefinition.getId());
                processDefinition.setVersion(persistedProcessDefinition.getVersion());
                processDefinition.setSuspensionState(persistedProcessDefinition.getSuspensionState());
            }
        }
    }
133518
def addResource(self, pid):
        
        self._check_initialized()
        try:
            # is entry already in place?
            self.getObjectByPid(pid)
            return
        except IndexError:
            pass
        # Entry not present, add it to the graph
        oid = self._pid_to_id(pid)
        obj = rdflib.URIRef(oid)
        ag = self.getAggregation()
        self.add((ag, ORE.aggregates, obj))
        self.add((obj, ORE.isAggregatedBy, ag))
        self.add((obj, DCTERMS.identifier, rdflib.term.Literal(pid)))
994381
def add_project(project,**kwargs):
    
    user_id = kwargs.get('user_id')

    existing_proj = get_project_by_name(project.name,user_id=user_id)

    if len(existing_proj) > 0:
        raise HydraError("A Project with the name \"%s\" already exists"%(project.name,))

    #check_perm(user_id, 'add_project')
    proj_i = Project()
    proj_i.name = project.name
    proj_i.description = project.description
    proj_i.created_by = user_id

    attr_map = hdb.add_resource_attributes(proj_i, project.attributes)
    db.DBSession.flush() #Needed to get the resource attr's ID
    proj_data = _add_project_attribute_data(proj_i, attr_map, project.attribute_data)
    proj_i.attribute_data = proj_data

    proj_i.set_owner(user_id)

    db.DBSession.add(proj_i)
    db.DBSession.flush()

    return proj_i
873937
public void updateProcessDefinitionSuspensionStateById(String processDefinitionId, SuspensionState suspensionState) {
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("processDefinitionId", processDefinitionId);
    parameters.put("suspensionState", suspensionState.getStateCode());
    getDbEntityManager().update(ProcessDefinitionEntity.class, "updateProcessDefinitionSuspensionStateByParameters", configureParameterizedQuery(parameters));
  }