Read mixins from database.

@param cid
- Item id (internal)
@return MixinInfo
@throws SQLException
database error
@throws IllegalNameException
if nodetype name in mixin record is wrong
325742
protected MixinInfo readMixins(String cid) throws SQLException, IllegalNameException
   {
      ResultSet mtrs = findPropertyByName(cid, Constants.JCR_MIXINTYPES.getAsString());

      try
      {
         List<InternalQName> mts = null;
         boolean owneable = false;
         boolean privilegeable = false;
         if (mtrs.next())
         {
            mts = new ArrayList<InternalQName>();
            do
            {
               byte[] mxnb = mtrs.getBytes(COLUMN_VDATA);
               if (mxnb != null)
               {
                  InternalQName mxn = InternalQName.parse(new String(mxnb));
                  mts.add(mxn);

                  if (!privilegeable && Constants.EXO_PRIVILEGEABLE.equals(mxn))
                  {
                     privilegeable = true;
                  }
                  else if (!owneable && Constants.EXO_OWNEABLE.equals(mxn))
                  {
                     owneable = true;
                  }
               } // else, if SQL NULL - skip it
            }
            while (mtrs.next());
         }

         return new MixinInfo(mts, owneable, privilegeable);
      }
      finally
      {
         try
         {
            mtrs.close();
         }
         catch (SQLException e)
         {
            LOG.error("Can't close the ResultSet: " + e.getMessage());
         }
      }
   }
326658
def get(self, cid1, cid2, annotator_id):
        '''
        '''
        t = (cid1, cid2, annotator_id)
        for k, v in self.kvl.scan(self.TABLE, (t, t)):
            return self._label_from_kvlayer(k, v)
40674
@Override
    public final void initialize(MixinImplementor mixinImplementor) {
        checkState(this.mixinImplementor == null, "Re-entry is not allowed.");

        this.mixinImplementor = checkNotNull(mixinImplementor, "mixinImplementor");
        try {
          initialize();
        }
        finally {
            this.mixinImplementor = null;
        }
    }
1191044
public PropertyDefinitionDatas getPropertyDefinitions(final InternalQName propertyName,
      final InternalQName... nodeTypeNames) throws RepositoryException
   {

      PropertyDefinitionDatas propertyDefinitions =
         this.nodeTypeRepository.getPropertyDefinitions(propertyName, nodeTypeNames);

      // Try super
      if (propertyDefinitions == null)
      {
         for (int i = 0; i < nodeTypeNames.length && propertyDefinitions == null; i++)
         {
            final InternalQName[] supers =
               this.nodeTypeRepository.getNodeType(nodeTypeNames[i]).getDeclaredSupertypeNames();
            propertyDefinitions = getPropertyDefinitions(propertyName, supers);

         }
      }

      // try residual def
      if (propertyDefinitions == null && !propertyName.equals(Constants.JCR_ANY_NAME))
      {
         propertyDefinitions = getPropertyDefinitions(Constants.JCR_ANY_NAME, nodeTypeNames);
      }

      return propertyDefinitions;
   }
119301
private void createVersion(Node fileNode, InputStream inputStream, String autoVersion, List<String> mixins) throws RepositoryException
   {
      if (!fileNode.isNodeType(VersionHistoryUtils.MIX_VERSIONABLE))
      {
         if (fileNode.canAddMixin(VersionHistoryUtils.MIX_VERSIONABLE))
         {
            fileNode.addMixin(VersionHistoryUtils.MIX_VERSIONABLE);
            fileNode.getSession().save();
         }
         if (!(CHECKIN_CHECKOUT.equals(autoVersion)))
         {
            fileNode.checkin();
            fileNode.getSession().save();
         }
      }
      if (CHECKIN_CHECKOUT.equals(autoVersion))
      {
         fileNode.checkin();
         fileNode.checkout();
         fileNode.getSession().save();
         updateContent(fileNode, inputStream, mixins);
         fileNode.getSession().save();
      }
      else
      {
         createVersion(fileNode, inputStream, mixins);
      }
   }
1126034
private Object[] readIdentities(Class pObjClass, Hashtable pMapping, 
                                    Hashtable pWhere, ObjectMapper pOM) 
        throws SQLException {
        sCacheUn++;
        // Build SQL query string
        if (pWhere == null)
            pWhere = new Hashtable();
	
        String[] keys = new String[pWhere.size()];
        int i = 0;
        for (Enumeration en = pWhere.keys(); en.hasMoreElements(); i++) {
            keys[i] = (String) en.nextElement();
        }

        // Get SQL for reading identity column
        String sql = pOM.buildIdentitySQL(keys)
            + buildWhereClause(keys, pMapping);

        // Log?
        mLog.logDebug(sql + " (" + pWhere + ")");

        // Prepare statement and set values
        PreparedStatement statement = mConnection.prepareStatement(sql);	
        for (int j = 0; j < keys.length; j++) {
            Object key =  pWhere.get(keys[j]);
	    
            if (key instanceof Integer)
                statement.setInt(j + 1, ((Integer) key).intValue());
            else if (key instanceof BigDecimal)
                statement.setBigDecimal(j + 1, (BigDecimal) key);
            else
                statement.setString(j + 1, key.toString());
        }
	
        // Execute query
        ResultSet rs = null;
        try {
            rs = statement.executeQuery();
        }
        catch (SQLException e) {
            mLog.logError(sql + " (" + pWhere + ")", e);
            throw e;
        }
        Vector result = new Vector();

        // Map query to objects
        while (rs.next()) {
            Object obj = null;
	    
            try {
                obj = pObjClass.newInstance();
            }
            catch (IllegalAccessException iae) {
                iae.printStackTrace();
            }
            catch (InstantiationException ie) {
                ie.printStackTrace();
            }
	    
            // Map it
            pOM.mapColumnProperty(rs, 1, 
                                  pOM.getProperty(pOM.getPrimaryKey()), obj);
            result.addElement(obj);
        }

        // Return array of identifiers
        return result.toArray((Object[]) Array.newInstance(pObjClass, 
                                                           result.size()));
    }
1260099
function getMixinsFromFile(file, data) {

    /* Step 1: get all includes and insert them, so that at least empty mixins exist. */
    let regex = /@include ([a-z0-9-]+)/g;
    let match = regex.exec(data);

    while (match) {
        if (!(match[1] in themeMixins)) { themeMixins[match[1]] = `@mixin ${match[1]}(){}`; }
        if (!(match[1] in coreMixins)) { coreMixins[match[1]] = `@mixin ${match[1]}(){}`; }

        match = regex.exec(data);
    }

    /* Step 2: get all multiline mixins */
    regex = /@mixin ([\w-]*)\s*\((.*)\)\s*{\n(\s+[\w\W]+?)(?=\n})\n}/g;
    match = regex.exec(data);

    while (match) {
        themeMixins[match[1]] = match[0];
        if (file.indexOf('theme/') < 0) {
            coreMixins[match[1]] = match[0];
        }
        match = regex.exec(data);
    }

    /* Step 3: get all singleline mixins */
    regex = /@mixin ([\w-]*)\s*\((.*)\)\s*{( [^\n]+)}/g;
    match = regex.exec(data);

    while (match) {
        themeMixins[match[1]] = match[0];
        if (file.indexOf('theme/') < 0) {
            coreMixins[match[1]] = match[0];
        }

        match = regex.exec(data);
    }

    /* Step 4: remove the mixins from the file, so that users can overwrite them in their custom code. */
    return data
        .replace(/@mixin ([\w-]*)\s*\((.*)\)\s*{\n(\s+[\w\W]+?)(?=\n})\n}/g, '')
        .replace(/@mixin ([\w-]*)\s*\((.*)\)\s*{( [^\n]+)}/g, '');
}
130800
@Override
	public synchronized RecordScan read(int scanId) throws DatabaseException {
		try {
			psRead.setInt(1, scanId);
			
			try (ResultSet rs = psRead.executeQuery()) {
				RecordScan result = build(rs);
				return result;
			}
		} catch (SQLException e) {
			throw new DatabaseException(e);
		}
	}
773185
public boolean hasMixinType( AstNode node,
                                 String mixinType ) {
        CheckArg.isNotNull(node, "node");
        CheckArg.isNotNull(mixinType, "mixinType");
        return node.getMixins().contains(mixinType);
    }
1197057
public static void registerMixinType(Session session, String mixin) throws RepositoryException {
        NodeTypeManager nodeTypeManager = session.getWorkspace().getNodeTypeManager();
        if (!nodeTypeManager.hasNodeType(mixin)) {
            NodeTypeTemplate nodeTypeTemplate = nodeTypeManager.createNodeTypeTemplate();
            nodeTypeTemplate.setMixin(true);
            nodeTypeTemplate.setName(mixin);

            NodeTypeDefinition[] nodeTypes = new NodeTypeDefinition[]{nodeTypeTemplate};
            nodeTypeManager.registerNodeTypes(nodeTypes, true);
        }
    }
980168
public static function getByID($cID, $cvID = 'RECENT')
    {
        $c = parent::getByID($cID, $cvID);

        if (static::isValidStack($c)) {
            return $c;
        }

        return null;
    }
947044
protected function getCollection(Select $sql, $cid)
    {
        $this->triggerBeforeSelect(
            $sql,
            $this->getRepository()->getEntityDescriptor()
        );
        $data = $this->adapter->query($sql, $sql->getParameters());
        $collection = $this->repository->getEntityMapper()
            ->createFrom($data);
        $this->triggerAfterSelect(
            $data,
            $collection
        );
        $this->registerEventsTo($collection, $cid);
        $this->getCollectionsMap()->set($cid, $collection);
        $this->updateIdentityMap($collection);
        
        return $collection;
    }
227175
public static ArrayList<String> getMixinTypes(String mixinTypes)
   {
      return mixinTypes == null ? new ArrayList<String>() : new ArrayList<String>(Arrays.asList(mixinTypes.split(",")));
   }
409628
private PersistedNodeData loadNodeRecord(QPath parentPath, String cname, String cid, String cpid, int cindex,
      int cversion, int cnordernumb, Map<String, SortedSet<TempPropertyData>> properties, AccessControlList parentACL)
      throws RepositoryException, SQLException, IOException
   {
      try
      {
         InternalQName qname = InternalQName.parse(cname);

         QPath qpath;
         String parentCid;
         if (parentPath != null)
         {
            // get by parent and name
            qpath = QPath.makeChildPath(parentPath, qname, cindex, getIdentifier(cid));
            parentCid = cpid;
         }
         else
         {
            // get by id
            if (cpid.equals(Constants.ROOT_PARENT_UUID))
            {
               // root node
               qpath = Constants.ROOT_PATH;
               parentCid = null;
            }
            else
            {
               qpath = QPath.makeChildPath(traverseQPath(cpid), qname, cindex, getIdentifier(cid));
               parentCid = cpid;
            }
         }

         // PRIMARY
         SortedSet<TempPropertyData> primaryType = properties.get(Constants.JCR_PRIMARYTYPE.getAsString());
         if (primaryType == null || primaryType.isEmpty())
         {
            throw new PrimaryTypeNotFoundException("FATAL ERROR primary type record not found. Node "
               + qpath.getAsString() + ", id " + getIdentifier(cid) + ", container " + this.containerConfig.containerName, null);
         }

         InternalQName ptName = InternalQName.parse(ValueDataUtil.getString(primaryType.first().getValueData()));

         // MIXIN
         InternalQName[] mts;
         boolean owneable = false;
         boolean privilegeable = false;
         Set<TempPropertyData> mixTypes = properties.get(Constants.JCR_MIXINTYPES.getAsString());
         if (mixTypes != null)
         {
            List<InternalQName> mNames = new ArrayList<InternalQName>();
            for (TempPropertyData mxnb : mixTypes)
            {
               InternalQName mxn = InternalQName.parse(ValueDataUtil.getString(mxnb.getValueData()));
               mNames.add(mxn);

               if (!privilegeable && Constants.EXO_PRIVILEGEABLE.equals(mxn))
               {
                  privilegeable = true;
               }
               else if (!owneable && Constants.EXO_OWNEABLE.equals(mxn))
               {
                  owneable = true;
               }
            }
            mts = new InternalQName[mNames.size()];
            mNames.toArray(mts);
         }
         else
         {
            mts = new InternalQName[0];
         }

         try
         {
            // ACL
            AccessControlList acl; // NO DEFAULT values!

            if (owneable)
            {
               // has own owner
               if (privilegeable)
               {
                  // and permissions
                  acl = new AccessControlList(readACLOwner(cid, properties), readACLPermisions(cid, properties));
               }
               else if (parentACL != null)
               {
                  // use permissions from existed parent
                  acl =
                     new AccessControlList(readACLOwner(cid, properties), parentACL.hasPermissions()
                        ? parentACL.getPermissionEntries() : null);
               }
               else
               {
                  // have to search nearest ancestor permissions in ACL manager
                  acl = new AccessControlList(readACLOwner(cid, properties), null);
               }
            }
            else if (privilegeable)
            {
               // has own permissions
               if (owneable)
               {
                  // and owner
                  acl = new AccessControlList(readACLOwner(cid, properties), readACLPermisions(cid, properties));
               }
               else if (parentACL != null)
               {
                  // use owner from existed parent
                  acl = new AccessControlList(parentACL.getOwner(), readACLPermisions(cid, properties));
               }
               else
               {
                  // have to search nearest ancestor owner in ACL manager
                  // acl = new AccessControlList(traverseACLOwner(cpid), readACLPermisions(cid));
                  acl = new AccessControlList(null, readACLPermisions(cid, properties));
               }
            }
            else
            {
               if (parentACL != null)
               {
                  // construct ACL from existed parent ACL
                  acl =
                     new AccessControlList(parentACL.getOwner(), parentACL.hasPermissions()
                        ? parentACL.getPermissionEntries() : null);
               }
               else
               {
                  // have to search nearest ancestor owner and permissions in ACL manager
                  // acl = traverseACL(cpid);
                  acl = null;
               }
            }

            return new PersistedNodeData(getIdentifier(cid), qpath, getIdentifier(parentCid), cversion, cnordernumb,
               ptName, mts, acl);

         }
         catch (IllegalACLException e)
         {
            throw new RepositoryException("FATAL ERROR Node " + getIdentifier(cid) + " " + qpath.getAsString()
               + " has wrong formed ACL. ", e);
         }
      }
      catch (IllegalNameException e)
      {
         throw new RepositoryException(e);
      }
   }
614708
protected List<AccessControlEntry> readACLPermisions(String cid) throws SQLException, IllegalACLException
   {
      List<AccessControlEntry> naPermissions = new ArrayList<AccessControlEntry>();
      ResultSet exoPerm = findPropertyByName(cid, Constants.EXO_PERMISSIONS.getAsString());
      try
      {
         if (exoPerm.next())
         {
            do
            {
               naPermissions.add(AccessControlEntry.parse(new String(exoPerm.getBytes(COLUMN_VDATA))));
            }
            while (exoPerm.next());

            return naPermissions;
         }
         else
         {
            throw new IllegalACLException("Property exo:permissions is not found for node with id: "
               + getIdentifier(cid));
         }
      }
      finally
      {
         try
         {
            exoPerm.close();
         }
         catch (SQLException e)
         {
            LOG.error("Can't close the ResultSet: " + e.getMessage());
         }
      }
   }
334921
public static void registerAndAddMixinType(Session session, Node node, String mixin) throws RepositoryException {
        registerMixinType(session, mixin);
        if (!Arrays.asList(node.getMixinNodeTypes()).contains(mixin)) {
            node.addMixin(mixin);
        }
    }
141805
private Mixin parseMixin() {
        tokenizer.consumeExpectedKeyword(KEYWORD_MIXIN);
        Mixin mixin = new Mixin();
        parseName(mixin);
        parseParameterNames(mixin);
        parseMixinAttributes(mixin);

        return mixin;
    }