Adds the cp instance to the database. Also notifies the appropriate model listeners.

@param cpInstance the cp instance
@return the cp instance that was added
489041
@Override
	public com.liferay.commerce.product.model.CPInstance addCPInstance(
		com.liferay.commerce.product.model.CPInstance cpInstance) {
		return _cpInstanceLocalService.addCPInstance(cpInstance);
	}
822765
@Override
	public List<CPInstance> findByCPDefinitionId(long CPDefinitionId) {
		return findByCPDefinitionId(CPDefinitionId, QueryUtil.ALL_POS,
			QueryUtil.ALL_POS, null);
	}
741732
@Override
	@Transactional(enabled = false)
	public CPAttachmentFileEntry createCPAttachmentFileEntry(
		long CPAttachmentFileEntryId) {
		return cpAttachmentFileEntryPersistence.create(CPAttachmentFileEntryId);
	}
1212793
public void setCPInstanceLocalService(
		com.liferay.commerce.product.service.CPInstanceLocalService cpInstanceLocalService) {
		this.cpInstanceLocalService = cpInstanceLocalService;
	}
786909
public static com.liferay.commerce.product.model.CPOptionValue addCPOptionValue(
		long cpOptionId, java.util.Map<java.util.Locale, String> titleMap,
		double priority, String key,
		com.liferay.portal.kernel.service.ServiceContext serviceContext)
		throws com.liferay.portal.kernel.exception.PortalException {
		return getService()
				   .addCPOptionValue(cpOptionId, titleMap, priority, key,
			serviceContext);
	}
1138609
public synchronized void addSoftwareIdentifier(Identifier identifier) {
        //todo the following assertion should be removed after initial testing and implementation
        assert !(identifier instanceof CpeIdentifier) : "vulnerability identifier cannot be added to software identifiers";

        final Optional<Identifier> found = softwareIdentifiers.stream().filter(id
                -> id.getValue().equals(identifier.getValue())).findFirst();
        if (found.isPresent()) {
            //TODO - should we check for type of identifier?  I.e. could we see a Purl and GenericIdentifier with the same value
            final Identifier existing = found.get();
            if (existing.getConfidence().compareTo(identifier.getConfidence()) < 0) {
                existing.setConfidence(identifier.getConfidence());
            }
            if (existing.getNotes() != null && identifier.getNotes() != null) {
                existing.setNotes(existing.getNotes() + " " + identifier.getNotes());
            } else if (identifier.getNotes() != null) {
                existing.setNotes(identifier.getNotes());
            }
            if (existing.getUrl() == null && identifier.getUrl() != null) {
                existing.setUrl(identifier.getUrl());
            }
        } else {
            this.softwareIdentifiers.add(identifier);
        }
    }
621044
@Override
	public int countByC_C(long CPDefinitionId, String CPInstanceUuid) {
		FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C;

		Object[] finderArgs = new Object[] { CPDefinitionId, CPInstanceUuid };

		Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);

		if (count == null) {
			StringBundler query = new StringBundler(3);

			query.append(_SQL_COUNT_CPINSTANCE_WHERE);

			query.append(_FINDER_COLUMN_C_C_CPDEFINITIONID_2);

			boolean bindCPInstanceUuid = false;

			if (CPInstanceUuid == null) {
				query.append(_FINDER_COLUMN_C_C_CPINSTANCEUUID_1);
			}
			else if (CPInstanceUuid.equals("")) {
				query.append(_FINDER_COLUMN_C_C_CPINSTANCEUUID_3);
			}
			else {
				bindCPInstanceUuid = true;

				query.append(_FINDER_COLUMN_C_C_CPINSTANCEUUID_2);
			}

			String sql = query.toString();

			Session session = null;

			try {
				session = openSession();

				Query q = session.createQuery(sql);

				QueryPos qPos = QueryPos.getInstance(q);

				qPos.add(CPDefinitionId);

				if (bindCPInstanceUuid) {
					qPos.add(CPInstanceUuid);
				}

				count = (Long)q.uniqueResult();

				finderCache.putResult(finderPath, finderArgs, count);
			}
			catch (Exception e) {
				finderCache.removeResult(finderPath, finderArgs);

				throw processException(e);
			}
			finally {
				closeSession(session);
			}
		}

		return count.intValue();
	}
523325
@Override
	public CPSpecificationOption create(long CPSpecificationOptionId) {
		CPSpecificationOption cpSpecificationOption = new CPSpecificationOptionImpl();

		cpSpecificationOption.setNew(true);
		cpSpecificationOption.setPrimaryKey(CPSpecificationOptionId);

		String uuid = PortalUUIDUtil.generate();

		cpSpecificationOption.setUuid(uuid);

		cpSpecificationOption.setCompanyId(companyProvider.getCompanyId());

		return cpSpecificationOption;
	}
1092451
@Override
    public ManagedServiceFactory addingService(ServiceReference<ManagedServiceFactory> reference) {
        String[] factoryPids = getServicePid(reference);
        if (factoryPids == null) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "handleRegistration(): Invalid service.pid type: " + reference);
            }

            return null;
        }

        ManagedServiceFactory msf = context.getService(reference);
        if (msf == null)
            return null;

        synchronized (caFactory.getConfigurationStore()) {

            for (String factoryPid : factoryPids) {
                add(reference, factoryPid, msf);
            }
        }

        return msf;
    }
969422
@Override
	public int countByCPI_CPIU(long CProductId, String CPInstanceUuid) {
		FinderPath finderPath = FINDER_PATH_COUNT_BY_CPI_CPIU;

		Object[] finderArgs = new Object[] { CProductId, CPInstanceUuid };

		Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);

		if (count == null) {
			StringBundler query = new StringBundler(3);

			query.append(_SQL_COUNT_COMMERCEWAREHOUSEITEM_WHERE);

			query.append(_FINDER_COLUMN_CPI_CPIU_CPRODUCTID_2);

			boolean bindCPInstanceUuid = false;

			if (CPInstanceUuid == null) {
				query.append(_FINDER_COLUMN_CPI_CPIU_CPINSTANCEUUID_1);
			}
			else if (CPInstanceUuid.equals("")) {
				query.append(_FINDER_COLUMN_CPI_CPIU_CPINSTANCEUUID_3);
			}
			else {
				bindCPInstanceUuid = true;

				query.append(_FINDER_COLUMN_CPI_CPIU_CPINSTANCEUUID_2);
			}

			String sql = query.toString();

			Session session = null;

			try {
				session = openSession();

				Query q = session.createQuery(sql);

				QueryPos qPos = QueryPos.getInstance(q);

				qPos.add(CProductId);

				if (bindCPInstanceUuid) {
					qPos.add(CPInstanceUuid);
				}

				count = (Long)q.uniqueResult();

				finderCache.putResult(finderPath, finderArgs, count);
			}
			catch (Exception e) {
				finderCache.removeResult(finderPath, finderArgs);

				throw processException(e);
			}
			finally {
				closeSession(session);
			}
		}

		return count.intValue();
	}
1174516
@Override
	public com.liferay.commerce.model.CPDAvailabilityEstimate createCPDAvailabilityEstimate(
		long CPDAvailabilityEstimateId) {
		return _cpdAvailabilityEstimateLocalService.createCPDAvailabilityEstimate(CPDAvailabilityEstimateId);
	}
238609
public static com.liferay.commerce.model.CPDefinitionInventory updateCPDefinitionInventory(
		com.liferay.commerce.model.CPDefinitionInventory cpDefinitionInventory) {
		return getService().updateCPDefinitionInventory(cpDefinitionInventory);
	}
1313164
public static com.liferay.commerce.product.type.virtual.model.CPDefinitionVirtualSetting addCPDefinitionVirtualSetting(
		String className, long classPK, long fileEntryId, String url,
		int activationStatus, long duration, int maxUsages, boolean useSample,
		long sampleFileEntryId, String sampleUrl, boolean termsOfUseRequired,
		java.util.Map<java.util.Locale, String> termsOfUseContentMap,
		long termsOfUseJournalArticleResourcePrimKey, boolean override,
		com.liferay.portal.kernel.service.ServiceContext serviceContext)
		throws com.liferay.portal.kernel.exception.PortalException {
		return getService()
				   .addCPDefinitionVirtualSetting(className, classPK,
			fileEntryId, url, activationStatus, duration, maxUsages, useSample,
			sampleFileEntryId, sampleUrl, termsOfUseRequired,
			termsOfUseContentMap, termsOfUseJournalArticleResourcePrimKey,
			override, serviceContext);
	}
897376
@Indexable(type = IndexableType.REINDEX)
	@Override
	public CPDAvailabilityEstimate addCPDAvailabilityEstimate(
		CPDAvailabilityEstimate cpdAvailabilityEstimate) {
		cpdAvailabilityEstimate.setNew(true);

		return cpdAvailabilityEstimatePersistence.update(cpdAvailabilityEstimate);
	}
226993
@Indexable(type = IndexableType.REINDEX)
	@Override
	public CPDefinition updateCPDefinition(CPDefinition cpDefinition) {
		return cpDefinitionPersistence.update(cpDefinition);
	}
897645
@Override
	public com.liferay.commerce.product.model.CPMeasurementUnit createCPMeasurementUnit(
		long CPMeasurementUnitId) {
		return _cpMeasurementUnitLocalService.createCPMeasurementUnit(CPMeasurementUnitId);
	}
1233631
public static com.liferay.commerce.product.type.grouped.model.CPDefinitionGroupedEntry addCPDefinitionGroupedEntry(
		com.liferay.commerce.product.type.grouped.model.CPDefinitionGroupedEntry cpDefinitionGroupedEntry) {
		return getService().addCPDefinitionGroupedEntry(cpDefinitionGroupedEntry);
	}