view src/main/java/org/mpi/openmind/scripts/PublicCodices.java @ 112:933d17f95016

new script MigratePrimeAliases to migrate is_prime_alias_X_of.
author Robert Casties <casties@mpiwg-berlin.mpg.de>
date Wed, 14 Aug 2019 20:48:02 +0200
parents 615d27dce9b3
children
line wrap: on
line source

package org.mpi.openmind.scripts;

import java.util.ArrayList;
import java.util.List;

import org.mpi.openmind.cache.WrapperService;
import org.mpi.openmind.repository.bo.Attribute;
import org.mpi.openmind.repository.bo.Entity;
import org.mpi.openmind.repository.bo.Node;
import org.mpi.openmind.repository.services.ServiceRegistry;

public class PublicCodices {

	
	private static String ATT_NAME = "public";
	private static String CLASS_NAME = "CODEX";
	
	
	private static List<Long> codexIdList = new ArrayList<Long>();
	public static String userName = "public-codices-script";
	static{
		codexIdList.add(new Long(27543));
		codexIdList.add(new Long(36745));
		codexIdList.add(new Long(58453));
		codexIdList.add(new Long(87298));
		codexIdList.add(new Long(259646));
		codexIdList.add(new Long(35093));
		codexIdList.add(new Long(22863));
		codexIdList.add(new Long(34870));
		codexIdList.add(new Long(36882));
		codexIdList.add(new Long(101488));
		codexIdList.add(new Long(36696));
		codexIdList.add(new Long(31794));
		codexIdList.add(new Long(37240));
		codexIdList.add(new Long(35014));
		codexIdList.add(new Long(35583));
		codexIdList.add(new Long(37025));
		codexIdList.add(new Long(35960));
		codexIdList.add(new Long(172492));
		codexIdList.add(new Long(98286));
		codexIdList.add(new Long(165721));
		codexIdList.add(new Long(260111));
		codexIdList.add(new Long(90980));
		codexIdList.add(new Long(36316));
		codexIdList.add(new Long(260120));
		codexIdList.add(new Long(36241));
		codexIdList.add(new Long(260129));
		codexIdList.add(new Long(260138));
		codexIdList.add(new Long(38860));
		codexIdList.add(new Long(176694));
		codexIdList.add(new Long(72545));
		codexIdList.add(new Long(36185));
		codexIdList.add(new Long(36575));
		codexIdList.add(new Long(260146));
		codexIdList.add(new Long(31672));
		codexIdList.add(new Long(37739));
		codexIdList.add(new Long(89861));
		codexIdList.add(new Long(176778));
		codexIdList.add(new Long(180743));
		codexIdList.add(new Long(86328));
		codexIdList.add(new Long(260150));
		codexIdList.add(new Long(90658));
		codexIdList.add(new Long(58423));
		codexIdList.add(new Long(181058));
		codexIdList.add(new Long(105948));
		codexIdList.add(new Long(35526));
		codexIdList.add(new Long(74078));
		codexIdList.add(new Long(260158));
		codexIdList.add(new Long(181096));
		codexIdList.add(new Long(31606));
		codexIdList.add(new Long(31568));
		codexIdList.add(new Long(27872));
		codexIdList.add(new Long(36938));
		codexIdList.add(new Long(4836));
		codexIdList.add(new Long(34668));
		codexIdList.add(new Long(76866));
		codexIdList.add(new Long(102230));
		codexIdList.add(new Long(76888));
		codexIdList.add(new Long(74070));
		codexIdList.add(new Long(73757));
		codexIdList.add(new Long(182685));
		codexIdList.add(new Long(260162));
		codexIdList.add(new Long(260170));
		codexIdList.add(new Long(1102));
		codexIdList.add(new Long(172888));
		codexIdList.add(new Long(260174));
		codexIdList.add(new Long(34806));
		codexIdList.add(new Long(28088));
		codexIdList.add(new Long(36713));
		codexIdList.add(new Long(37323));
		codexIdList.add(new Long(34551));
		codexIdList.add(new Long(35943));
		codexIdList.add(new Long(98095));
		codexIdList.add(new Long(260178));
		codexIdList.add(new Long(260182));
		codexIdList.add(new Long(182770));
		codexIdList.add(new Long(260186));
		codexIdList.add(new Long(260190));
		codexIdList.add(new Long(260194));
		codexIdList.add(new Long(36114));
		codexIdList.add(new Long(85003));
		codexIdList.add(new Long(31630));
		codexIdList.add(new Long(157290));
		codexIdList.add(new Long(37153));
		codexIdList.add(new Long(37213));
		codexIdList.add(new Long(172952));
		codexIdList.add(new Long(86871));
		codexIdList.add(new Long(64406));
		codexIdList.add(new Long(102590));
		codexIdList.add(new Long(82615));
		codexIdList.add(new Long(58245));
		codexIdList.add(new Long(179791));
		codexIdList.add(new Long(179550));
		codexIdList.add(new Long(12419));
		codexIdList.add(new Long(95861));
		codexIdList.add(new Long(36429));
		codexIdList.add(new Long(36099));
		codexIdList.add(new Long(74237));
		codexIdList.add(new Long(36065));
		codexIdList.add(new Long(74822));
		codexIdList.add(new Long(87549));
		codexIdList.add(new Long(83765));
		codexIdList.add(new Long(36733));
		codexIdList.add(new Long(19259));
		codexIdList.add(new Long(260198));
		codexIdList.add(new Long(34986));
		codexIdList.add(new Long(88041));
		codexIdList.add(new Long(260202));
		codexIdList.add(new Long(36550));
		codexIdList.add(new Long(260206));
		codexIdList.add(new Long(37228));
		codexIdList.add(new Long(39880));
		codexIdList.add(new Long(36318));
		codexIdList.add(new Long(36597));
		codexIdList.add(new Long(35035));
		codexIdList.add(new Long(58328));
		codexIdList.add(new Long(80831));
		codexIdList.add(new Long(58354));
		codexIdList.add(new Long(74277));
		codexIdList.add(new Long(36529));
		codexIdList.add(new Long(36380));
		codexIdList.add(new Long(69450));
		codexIdList.add(new Long(200246));
		codexIdList.add(new Long(260222));
		codexIdList.add(new Long(81178));
		codexIdList.add(new Long(260226));
		codexIdList.add(new Long(199952));
		codexIdList.add(new Long(262557));
		codexIdList.add(new Long(87212));
		codexIdList.add(new Long(99059));
		codexIdList.add(new Long(64270));
		codexIdList.add(new Long(81811));
		codexIdList.add(new Long(65785));
		codexIdList.add(new Long(36645));
	}

	
	public static void prepareDefinitions(WrapperService ws) throws Exception{
		
		Entity codex = ws.getDefinition(CLASS_NAME);

		Attribute attPublic = ws.getDefAttributeByOwnValue(CLASS_NAME, ATT_NAME);
		
		if(attPublic == null){
			attPublic = new Attribute(Node.TYPE_TBOX, "boolean", ATT_NAME);
			attPublic.setSourceId(codex.getId());
			attPublic.setSourceObjectClass(Node.TYPE_TBOX);
			attPublic.setSourceModif(codex.getModificationTime());
			attPublic.setSystemStatus(Node.SYS_STATUS_CURRENT_VERSION);
			ws.saveDefAttribute(attPublic, userName);	
		}
	}
	
	public static void makeCodicesPublic(WrapperService ws) throws Exception{
		
		for(Long codexId : codexIdList){
			Entity codex = ws.getEntityByIdWithContent(codexId);
			if(codex != null){
				if(codex.getAttributeByName(ATT_NAME) == null){
					Attribute att = new Attribute(ATT_NAME, "boolean", "true");
					codex.addAttribute(att);
				}else{
					codex.getAttributeByName(ATT_NAME).setValue("true");
				}
			}
			ws.saveAssertion(codex, userName);
		}
	}

	
	
	public static void main(String[] args){
		ServiceRegistry services = new ServiceRegistry();
		
		try {
			prepareDefinitions(services.getWrapper());
			makeCodicesPublic(services.getWrapper());
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		System.exit(0);
	}
	
	
}