Post process metadata: - Select label attributes that are not defined in EMX - Select lookup
attributes that are not defined in EMX

@param intermediateResults intermediate parse results
761667
private static void postProcessMetadata(IntermediateParseResults intermediateResults) {
    intermediateResults
        .getEntityTypes()
        .forEach(
            entityType -> {
              setDefaultLabel(entityType);

              // in case no lookup attributes were defined:
              // try to set own id attribute and own label attribute as lookup attributes
              if (Iterables.size(entityType.getLookupAttributes()) == 0) {
                setDefaultLookupAttributes(entityType, 0);
              }
            });
  }
956695
def parse_labels(result):
    '''
    '''

    if "data" in result:
        labels = result['data']['attributes'].get('labels') or {}

    elif 'attributes' in result:
        labels = result['attributes'].get('labels') or {}

    # If labels included, try parsing to json

    try:
        labels = jsonp.loads(labels)
    except:
        pass

    if "data" in result:
        result['data']['attributes']['labels'] = labels
    else:
        result['attributes']['labels'] = labels

    return result
1079194
private void reiterateToMapRefEntity(
      Repository<Entity> attributeRepo, IntermediateParseResults intermediateResults) {
    int rowIndex = 1;
    for (Entity attributeEntity : attributeRepo) {
      final String entityTypeId = attributeEntity.getString(EMX_ATTRIBUTES_ENTITY);
      final String attributeName = attributeEntity.getString(EMX_ATTRIBUTES_NAME);
      final String refEntityName = (String) attributeEntity.get(EMX_ATTRIBUTES_REF_ENTITY);
      final String mappedByAttrName = (String) attributeEntity.get(EMX_ATTRIBUTES_MAPPED_BY);
      EntityType entityType = intermediateResults.getEntityType(entityTypeId);
      Attribute attribute = entityType.getAttribute(attributeName);

      if (attribute.getDataType().equals(FILE)) {
        // If attribute is of type file, set refEntity to file meta and continue to the next
        // attribute
        attribute.setRefEntity(dataService.getEntityType(FILE_META));
        continue;
      }

      rowIndex++;
      if (refEntityName != null) {
        processAttrRefEntityName(
            intermediateResults, rowIndex, refEntityName, mappedByAttrName, attribute);
      }
    }
  }
367355
def _process_layperson_results(self, results):
        

        payload = {
            'results': []
        }

        for doc in results.docs:
            hl = self._process_highlight(results, doc)
            highlight = {
                'id': doc['id'],
                'highlight': hl.highlight,
                'label': doc['label'],
                'matched_synonym': hl.match
            }
            payload['results'].append(highlight)

        logging.debug('Docs: {}'.format(len(results.docs)))

        return payload
1283696
List<String> getColumnList(EntityMetadata m, String[] results, EmbeddableType compoundKey)
    {
        List<String> columns = new ArrayList<String>();
        if (results != null && results.length > 0)
        {
            MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                    m.getPersistenceUnit());
            EntityType entity = metaModel.entity(m.getEntityClazz());

            for (int i = 1; i < results.length; i++)
            {
                if (results[i] != null)
                {
                    Attribute attribute = entity.getAttribute(results[i]);

                    if (attribute == null)
                    {
                        throw new QueryHandlerException("column type is null for: " + results);
                    }
                    else if (m.getIdAttribute().equals(attribute) && compoundKey != null)
                    {
                        Field[] fields = m.getIdAttribute().getBindableJavaType().getDeclaredFields();
                        for (Field field : fields)
                        {
                            if (!ReflectUtils.isTransientOrStatic(field))
                            {
                                Attribute compositeColumn = compoundKey.getAttribute(field.getName());
                                columns.add(((AbstractAttribute) compositeColumn).getJPAColumnName());
                            }
                        }
                    }
                    else
                    {
                        columns.add(((AbstractAttribute) attribute).getJPAColumnName());
                    }
                }
            }
            return columns;
        }

        if (log.isInfoEnabled())
        {
            log.info("No record found, returning null.");
        }
        return null;
    }
1293697
public List<MetaDataResult> getMetaDataResultList() {
    JSONArray jsonArray = null;
    try {
      jsonArray = _jsonObject.getJSONArray(DATASETS_ARRAY_FIELD);
      List<MetaDataResult> metaDataResults = new ArrayList<MetaDataResult>(jsonArray.length());
      for (int i = 0; i < jsonArray.length(); i++) {
        metaDataResults.add(MetaDataResult.of(jsonArray.getJSONObject(i)));
      }
      return metaDataResults;
    } catch (JSONException ex) {
      s_logger.error("Metadata had unexpected structure - could not extract datasets field, was:\n{}", _jsonObject.toString());
      throw new QuandlRuntimeException("Metadata had unexpected structure", ex);
    }
  }
159322
static void validateLabelAttribute(EntityType entityType) {
    if (entityType.getLabelAttribute() != null && !entityType.getLabelAttribute().isVisible()) {
      throw new MolgenisValidationException(
          new ConstraintViolation(
              format(
                  "Label attribute [%s] of EntityType [%s] must be visible.",
                  entityType.getLabelAttribute().getName(), entityType.getId())));
    }

    if (!entityType.isAbstract()
        && !entityType.getIdAttribute().isVisible()
        && (entityType.getLabelAttribute() == null)) {
      throw new MolgenisValidationException(
          new ConstraintViolation(
              format(
                  "EntityType [%s] must define a label attribute because the identifier is hidden",
                  entityType.getId())));
    }
  }
730431
private MyEntitiesValidationReport generateEntityValidationReport(
      RepositoryCollection source,
      MyEntitiesValidationReport report,
      Map<String, EntityType> metaDataMap) {
    for (String sheet : source.getEntityTypeIds()) {
      if (EMX_PACKAGES.equals(sheet)) {
        IntermediateParseResults parseResult = parseTagsSheet(source.getRepository(EMX_TAGS));
        parsePackagesSheet(source.getRepository(sheet), parseResult);
        parseResult.getPackages().keySet().forEach(report::addPackage);
      } else if (!EMX_ENTITIES.equals(sheet)
          && !EMX_ATTRIBUTES.equals(sheet)
          && !EMX_TAGS.equals(sheet)
          && !EMX_LANGUAGES.equals(sheet)
          && !EMX_I18NSTRINGS.equals(sheet)) {
        // check if sheet is known
        report = report.addEntity(sheet, metaDataMap.containsKey(sheet));

        // check the fields
        Repository<Entity> sourceRepository = source.getRepository(sheet);
        EntityType target = metaDataMap.get(sheet);

        if (target != null) {
          report = getAttributeValidationReport(report, sheet, sourceRepository, target);
        }
      }
    }
    return report;
  }
509890
private void assignReferenceToProxy(List results)
    {
        if (results != null)
        {
            for (Object obj : results)
            {
                kunderaMetadata.getCoreMetadata().getLazyInitializerFactory().setProxyOwners(getEntityMetadata(), obj);
            }
        }
    }
773347
public  void showBooleanActionResultInTextInfo(String title, BooleanOWLResultSet result) throws OWLException {

		AskQueryInfoSetter alter_result_panel = new AskQueryInfoSetter(title, result);
		SwingUtilities.invokeLater(alter_result_panel);
	}
1097842
private void process(Object entity, MetamodelImpl metamodel, Row row, Set<Attribute> attributes, Table schemaTable,
            EntityMetadata metadata)
    {

        for (Attribute attribute : attributes)
        {
            // by pass association.
            if (!attribute.isAssociation())
            {
                // in case of embeddable id.
                if (attribute.equals(metadata.getIdAttribute())
                        && metamodel.isEmbeddable(((AbstractAttribute) attribute).getBindableJavaType()))
                {
                    processEmbeddableAttribute(entity, metamodel, row, schemaTable, metadata, attribute);
                }
                else
                {
                    if (metamodel.isEmbeddable(((AbstractAttribute) attribute).getBindableJavaType()))
                    {
                        processEmbeddableAttribute(entity, metamodel, row, schemaTable, metadata, attribute);
                    }
                    else
                    {
                        setField(row, schemaTable, entity, attribute);
                    }
                }
            }
        }
    }
962779
private void closeResultSet
        (CodeBuilder b, LocalVariable rsVar, Label tryAfterRs)
    {
        Label contLabel = b.createLabel();
        Label endFinallyLabel = b.createLabel().setLocation();

        b.loadLocal(rsVar);
        b.invokeInterface(TypeDesc.forClass(ResultSet.class), "close", null, null);
        b.branch(contLabel);

        b.exceptionHandler(tryAfterRs, endFinallyLabel, null);
        b.loadLocal(rsVar);
        b.invokeInterface(TypeDesc.forClass(ResultSet.class), "close", null, null);
        b.throwObject();

        contLabel.setLocation();
    }
102342
static Set<String> labels(final ResultSet results) throws SQLException {
        final ResultSetMetaData metadata = results.getMetaData();
        final int count = metadata.getColumnCount();
        final Set<String> labels = new HashSet<>(count);
        for (int i = 1; i <= count; i++) {
            labels.add(metadata.getColumnLabel(i).toUpperCase());
        }
        return labels;
    }
1219811
public void setResultProperties(AbstractWrapperIdPages results) {
        // There are no values to copy
        results.setId(0);
        results.setPage(0);
        results.setTotalPages(0);
        results.setTotalResults(0);
    }
939573
public int resolveLabel(int idx) {
        int trueIdx;

        if (idx < 0) {
            trueIdx = labels.get(-idx);
            if (trueIdx < 0) {
                throw new RuntimeException("undefined label: " + idx);
            }
            return trueIdx;
        } else {
            return idx;
        }
    }
393899
public Object wrapFindResult(Map<String, Object> searchResults, EntityType entityType, Object result,
            EntityMetadata metadata, boolean b)
    {
        return wrap(searchResults, entityType, result, metadata, b);
    }
952637
private ImmutableSet<Label> scopeTypeLabels(GraqlCompute query) {
        return scopeTypes(query).map(SchemaConcept::label).collect(CommonUtil.toImmutableSet());
    }