<commit_before><?php
/** RawMaterial Entity
 *
 * @package    Core
 * @subpackage Entity
 * @author     lhe<<EMAIL>>
 */
class RawMaterial extends InfoEntityAbstract
{
	/**
	 * (non-PHPdoc)
	 * @see BaseEntity::__loadDaoMap()
	 */
	public function __loadDaoMap()
	{
		DaoMap::begin($this, 'raw_mat');

		parent::__loadDaoMap();

		DaoMap::commit();
	}
	/**
	 * Gets ServeMeasurement
	 *
	 * @param bool  $activeOnly
	 * @param int   $pageNo
	 * @param int   $pageSize
	 * @param array $orderBy
	 * @param array $stats
	 * @return Ambigous <Ambigous, multitype:, multitype:BaseEntityAbstract >
	 */
	public function getServeMeasurements($activeOnly = true, $pageNo = null, $pageSize = DaoQuery::DEFAUTL_PAGE_SIZE, $orderBy = array(), &$stats = array())
	{
		$objArray = array();
		$array = RawMaterialInfo::getAllByCriteria('rawMaterialId = ? and typeId = ?', array($this->getId(), RawMaterialInfoType::ID_SERVEMESUREMENT), $activeOnly, $pageNo, $pageSize, $orderBy, $stats);
		if (count($array) > 0) {
		    $ids = array();
			foreach($array as $infoObj)
				$ids[] = ((trim($infoObj->getEntityId()) !== '') ? trim($infoObj->getEntityId()) : trim($infoObj->getValue()));
			$ids = array_unique($ids);
			$objArray = ServeMeasurement::getAllByCriteria('id IN (' . implode(", ", array_fill(0, count($ids), '?')) . ')', $ids);
		}
		return $objArray;
	}

	/**
	 * Clear all the ServeMeasurements of the RawMaterial
	 * @return RawMaterial
	 */
	public function clearServeMeasurements()
	{
		RawMaterialInfo::deleteByCriteria('rawMaterialId = ? and typeId = ?', array($this->getId(), RawMaterialInfoType::ID_SERVEMESUREMENT));
		return $this;
	}
	/**
	 * add a ServeMeasurement to self
	 *
	 * @param ServeMeasurement $serveMeasurement The measurement; BOX, BAG, KG...
	 * @param string           $value            The price of the raw material
	 *
	 * @return RawMaterial
	 */
	public function addServeMeasurement(ServeMeasurement $serveMeasurement, $value = '')
	{
		$this->addInfo(RawMaterialInfoType::get(RawMaterialInfoType::ID_SERVEMESUREMENT), $serveMeasurement, $value, false);
		return $this;
	}
	/**
	 * (non-PHPdoc)
	 * @see InfoEntityAbstract::getJson()
	 */
	public function getJson($extra = array(), $reset = false)
	{
		$array = $extra;
		$measurement = $unitPrice = null;
		if (count($measurements = $this->getServeMeasurements(true, 1, 1)) > 0) {
		    $measurement = $measurements[0]->getJson();
		    $unitPrice = StringUtilsAbstract::getValueFromCurrency($measurements[0]->getValue());
		}
		$array['serverMeasurement'] = $measurement;
		$array['unitPrice'] = $unitPrice;
		return parent::getJson($array, $reset);
	}
	/**
	 * (non-PHPdoc)
	 * @see InfoEntityAbstract::create()
	 * @return RawMaterial
	 */
	public static function create($name, $description = '')
	{
		return parent::create($name, $description);
	}
}<commit_msg>fixing bug: getJson() of RawMaterial<commit_after><?php
/** RawMaterial Entity
 *
 * @package    Core
 * @subpackage Entity
 * @author     lhe<<EMAIL>>
 */
class RawMaterial extends InfoEntityAbstract
{
	/**
	 * (non-PHPdoc)
	 * @see BaseEntity::__loadDaoMap()
	 */
	public function __loadDaoMap()
	{
		DaoMap::begin($this, 'raw_mat');

		parent::__loadDaoMap();

		DaoMap::commit();
	}
	/**
	 * Gets ServeMeasurement
	 *
	 * @param bool  $activeOnly
	 * @param int   $pageNo
	 * @param int   $pageSize
	 * @param array $orderBy
	 * @param array $stats
	 * @return Ambigous <Ambigous, multitype:, multitype:BaseEntityAbstract >
	 */
	public function getServeMeasurements($activeOnly = true, $pageNo = null, $pageSize = DaoQuery::DEFAUTL_PAGE_SIZE, $orderBy = array(), &$stats = array())
	{
		$objArray = array();
		$array = RawMaterialInfo::getAllByCriteria('rawMaterialId = ? and typeId = ?', array($this->getId(), RawMaterialInfoType::ID_SERVEMESUREMENT), $activeOnly, $pageNo, $pageSize, $orderBy, $stats);
		if (count($array) > 0) {
		    $ids = array();
			foreach($array as $infoObj)
				$ids[] = ((trim($infoObj->getEntityId()) !== '') ? trim($infoObj->getEntityId()) : trim($infoObj->getValue()));
			$ids = array_unique($ids);
			$objArray = ServeMeasurement::getAllByCriteria('id IN (' . implode(", ", array_fill(0, count($ids), '?')) . ')', $ids);
		}
		return $objArray;
	}

	/**
	 * Clear all the ServeMeasurements of the RawMaterial
	 * @return RawMaterial
	 */
	public function clearServeMeasurements()
	{
		RawMaterialInfo::deleteByCriteria('rawMaterialId = ? and typeId = ?', array($this->getId(), RawMaterialInfoType::ID_SERVEMESUREMENT));
		return $this;
	}
	/**
	 * add a ServeMeasurement to self
	 *
	 * @param ServeMeasurement $serveMeasurement The measurement; BOX, BAG, KG...
	 * @param string           $value            The price of the raw material
	 *
	 * @return RawMaterial
	 */
	public function addServeMeasurement(ServeMeasurement $serveMeasurement, $value = '')
	{
		$this->addInfo(RawMaterialInfoType::get(RawMaterialInfoType::ID_SERVEMESUREMENT), $serveMeasurement, $value, false);
		return $this;
	}
	/**
	 * (non-PHPdoc)
	 * @see InfoEntityAbstract::getJson()
	 */
	public function getJson($extra = array(), $reset = false)
	{
		$array = $extra;
		$measurement = $unitPrice = null;
		if (count($rawMaterialInfo = RawMaterialInfo::getAllByCriteria('rawMaterialId = ? and typeId = ? and entityName=>', array($this->getId(), RawMaterialInfoType::ID_SERVEMESUREMENT, 'ServeMeasurement'), true, 1,1)) > 0) {
		    $measurement = $rawMaterialInfo[0]->getJson();
		    $unitPrice = StringUtilsAbstract::getValueFromCurrency($rawMaterialInfo[0]->getValue());
		}
		$array['serverMeasurement'] = $measurement;
		$array['unitPrice'] = $unitPrice;
		return parent::getJson($array, $reset);
	}
	/**
	 * (non-PHPdoc)
	 * @see InfoEntityAbstract::create()
	 * @return RawMaterial
	 */
	public static function create($name, $description = '')
	{
		return parent::create($name, $description);
	}
}
{'fraction_non_alphanumeric': 0.16496076424428524, 'fraction_numerical': 0.002388263391334016, 'mean_word_length': 4.552083333333333, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2752406', 'n_tokens_mistral': 2035, 'n_tokens_neox': 1892, 'n_words': 393}